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()CreateNatsStreamingwithout any start able configurationNatsStreaming(int port)CreateNatsStreamingwith the simplest start able configurationNatsStreaming(String... kv)Create customNatsStreamingwith the simplest configurationconfig(String...)NatsStreaming(List<String> customArgs)CreateNatsStreamingwith custom args
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Map<NatsStreamingConfig,MapValue>config()GetNatServerConfigNatsStreamingconfig(NatsStreamingConfig key, String value)Configures the nats serverNatsStreamingconfig(String... kv)Configures the nats serverNatsStreamingconfig(Map<NatsStreamingConfig,String> config)Configures the nats serverNatsStreamingstart()Starts the server inProcessBuilderwith the given configconfig(String...)NatsStreamingstart(long timeoutMs)Starts the server inProcessBuilderwith the given configconfig(String...)NatsStreamingstop()Stops theProcessBuilderand kills theNatsStreamingOnly a log error will occur if theNatsStreamingwere never startedNatsStreamingstop(long timeoutMs)Stops theProcessBuilderand kills theNatsStreamingOnly a log error will occur if theNatsStreamingwere never startedNatsStreamingtryStart()Starts the server inProcessBuilderwith the given parameterConfigconfig(String...)Throws all exceptions asRuntimeExceptionNatsStreamingtryStart(long timeoutMs)Starts the server inProcessBuilderwith the given configconfig(String...)Throws all exceptions asRuntimeException
-
-
-
Constructor Detail
-
NatsStreaming
public NatsStreaming()
CreateNatsStreamingwithout any start able configuration
-
NatsStreaming
public NatsStreaming(List<String> customArgs)
CreateNatsStreamingwith custom args
-
NatsStreaming
public NatsStreaming(int port)
CreateNatsStreamingwith the simplest start able configuration- Parameters:
port- start port, -1 = random, default is 4222
-
NatsStreaming
public NatsStreaming(String... kv)
Create customNatsStreamingwith 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
NatsStreamingconfiguration
-
config
public NatsStreaming config(NatsStreamingConfig key, String value)
Configures the nats server- Returns:
- the
NatsStreamingconfiguration
-
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 inProcessBuilderwith the given parameterConfigconfig(String...)Throws all exceptions asRuntimeException- Returns:
NatsStreaming
-
tryStart
public NatsStreaming tryStart(long timeoutMs)
Starts the server inProcessBuilderwith the given configconfig(String...)Throws all exceptions asRuntimeException- Parameters:
timeoutMs- defines the start-up timeout-1no timeout, else waits until port up- Returns:
NatsStreaming
-
start
public NatsStreaming start() throws Exception
Starts the server inProcessBuilderwith the given configconfig(String...)- Returns:
NatsStreaming- Throws:
IOException- ifNatsStreamingis not found or unsupported on theSystemUtilBindException- if port is already takenPortUnreachableException- ifNatsStreamingis not starting cause port is not freeException
-
start
public NatsStreaming start(long timeoutMs) throws Exception
Starts the server inProcessBuilderwith the given configconfig(String...)- Parameters:
timeoutMs- defines the start-up timeout-1no timeout, else waits until port up- Returns:
NatsStreaming- Throws:
IOException- ifNatsStreamingis not found or unsupported on theSystemUtilBindException- if port is already takenPortUnreachableException- ifNatsStreamingis not starting cause port is not freeException
-
close
public void close()
-
stop
public NatsStreaming stop()
Stops theProcessBuilderand kills theNatsStreamingOnly a log error will occur if theNatsStreamingwere never started- Returns:
NatsStreaming
-
stop
public NatsStreaming stop(long timeoutMs)
Stops theProcessBuilderand kills theNatsStreamingOnly a log error will occur if theNatsStreamingwere never started- Parameters:
timeoutMs- defines the tear down timeout,-1no timeout, else waits until port is free again- Returns:
NatsStreaming
-
-