Package berlin.yuna.natsserver.logic
Class NatsStreaming
- java.lang.Object
-
- berlin.yuna.natsserver.logic.NatsBase
-
- berlin.yuna.natsserver.logic.NatsStreaming
-
- All Implemented Interfaces:
AutoCloseable
public class NatsStreaming extends NatsBase
-
-
Field Summary
-
Fields inherited from class berlin.yuna.natsserver.logic.NatsBase
NATS_PREFIX
-
-
Constructor Summary
Constructors Constructor Description NatsStreaming()
CreateNatsStreaming
without any start able configurationNatsStreaming(int port)
CreateNatsStreaming
with the simplest start able configurationNatsStreaming(String... kv)
Create customNatsStreaming
with the simplest configurationconfig(String...)
NatsStreaming(List<String> customArgs)
CreateNatsStreaming
with custom args
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Map<NatsStreamingConfig,MapValue>
config()
GetNatServerConfigNatsStreaming
config(NatsStreamingConfig key, String value)
Configures the nats serverNatsStreaming
config(String... kv)
Configures the nats serverNatsStreaming
config(Map<NatsStreamingConfig,String> config)
Configures the nats serverNatsStreaming
start()
Starts the server inProcessBuilder
with the given configconfig(String...)
NatsStreaming
start(long timeoutMs)
Starts the server inProcessBuilder
with the given configconfig(String...)
NatsStreaming
stop()
Stops theProcessBuilder
and kills theNatsStreaming
Only a log error will occur if theNatsStreaming
were never startedNatsStreaming
stop(long timeoutMs)
Stops theProcessBuilder
and kills theNatsStreaming
Only a log error will occur if theNatsStreaming
were never startedNatsStreaming
tryStart()
Starts the server inProcessBuilder
with the given parameterConfigconfig(String...)
Throws all exceptions asRuntimeException
NatsStreaming
tryStart(long timeoutMs)
Starts the server inProcessBuilder
with the given configconfig(String...)
Throws all exceptions asRuntimeException
-
-
-
Constructor Detail
-
NatsStreaming
public NatsStreaming()
CreateNatsStreaming
without any start able configuration
-
NatsStreaming
public NatsStreaming(List<String> customArgs)
CreateNatsStreaming
with custom args
-
NatsStreaming
public NatsStreaming(int port)
CreateNatsStreaming
with the simplest start able configuration- Parameters:
port
- start port, -1 = random, default is 4222
-
NatsStreaming
public NatsStreaming(String... kv)
Create customNatsStreaming
with the simplest configurationconfig(String...)
- Parameters:
kv
- passes the original parameters to the server. example: port:4222, user:admin, password:admin
-
-
Method Detail
-
config
public Map<NatsStreamingConfig,MapValue> config()
GetNatServerConfig- Returns:
- the
NatsStreaming
configuration
-
config
public NatsStreaming config(NatsStreamingConfig key, String value)
Configures the nats server- Returns:
- the
NatsStreaming
configuration
-
config
public NatsStreaming config(Map<NatsStreamingConfig,String> config)
Configures the nats server- Parameters:
config
- passes the original parameters to the server.- Returns:
NatsStreaming
- See Also:
config(String...)
,NatsStreamingConfig
-
config
public NatsStreaming config(String... kv)
Configures the nats server- Parameters:
kv
- example: port, 4222, user, admin, password, admin- Returns:
NatsStreaming
- See Also:
NatsStreamingConfig
-
tryStart
public NatsStreaming tryStart()
Starts the server inProcessBuilder
with the given parameterConfigconfig(String...)
Throws all exceptions asRuntimeException
- Returns:
NatsStreaming
-
tryStart
public NatsStreaming tryStart(long timeoutMs)
Starts the server inProcessBuilder
with the given configconfig(String...)
Throws all exceptions asRuntimeException
- Parameters:
timeoutMs
- defines the start-up timeout-1
no timeout, else waits until port up- Returns:
NatsStreaming
-
start
public NatsStreaming start() throws Exception
Starts the server inProcessBuilder
with the given configconfig(String...)
- Returns:
NatsStreaming
- Throws:
IOException
- ifNatsStreaming
is not found or unsupported on theSystemUtil
BindException
- if port is already takenPortUnreachableException
- ifNatsStreaming
is not starting cause port is not freeException
-
start
public NatsStreaming start(long timeoutMs) throws Exception
Starts the server inProcessBuilder
with the given configconfig(String...)
- Parameters:
timeoutMs
- defines the start-up timeout-1
no timeout, else waits until port up- Returns:
NatsStreaming
- Throws:
IOException
- ifNatsStreaming
is not found or unsupported on theSystemUtil
BindException
- if port is already takenPortUnreachableException
- ifNatsStreaming
is not starting cause port is not freeException
-
close
public void close()
-
stop
public NatsStreaming stop()
Stops theProcessBuilder
and kills theNatsStreaming
Only a log error will occur if theNatsStreaming
were never started- Returns:
NatsStreaming
-
stop
public NatsStreaming stop(long timeoutMs)
Stops theProcessBuilder
and kills theNatsStreaming
Only a log error will occur if theNatsStreaming
were never started- Parameters:
timeoutMs
- defines the tear down timeout,-1
no timeout, else waits until port is free again- Returns:
NatsStreaming
-
-