Package berlin.yuna.natsserver.logic
Class Nats
java.lang.Object
berlin.yuna.natsserver.logic.NatsBase
berlin.yuna.natsserver.logic.Nats
- All Implemented Interfaces:
AutoCloseable
- Since:
- 1.0
- Author:
- Yuna Morgenstern
- See Also:
-
SystemUtilNats
-
Field Summary
Fields inherited from class berlin.yuna.natsserver.logic.NatsBase
NATS_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()config()GetNatServerConfigconfig(NatsConfig key, String value) Configures the nats serverConfigures the nats serverconfig(Map<NatsConfig, String> config) Configures the nats serverstart()Starts the server inProcessBuilderwith the given configconfig(String...)start(long timeoutMs) Starts the server inProcessBuilderwith the given configconfig(String...)stop()Stops theProcessBuilderand kills theNatsOnly a log error will occur if theNatswere never startedstop(long timeoutMs) Stops theProcessBuilderand kills theNatsOnly a log error will occur if theNatswere never startedtryStart()Starts the server inProcessBuilderwith the given parameterConfigconfig(String...)Throws all exceptions asRuntimeExceptiontryStart(long timeoutMs) Starts the server inProcessBuilderwith the given configconfig(String...)Throws all exceptions asRuntimeExceptionMethods inherited from class berlin.yuna.natsserver.logic.NatsBase
args, args, binaryFile, downloadUrl, getConfigFile, getValue, getValue, pid, pidFile, port, toString, url
-
Constructor Details
-
Nats
public Nats()CreateNatswithout any start able configuration -
Nats
CreateNatswith custom args -
Nats
public Nats(int port) CreateNatswith the simplest start able configuration- Parameters:
port- start port, -1 = random, default is 4222
-
Nats
Create customNatswith the simplest configurationconfig(String...)- Parameters:
kv- passes the original parameters to the server. example: port:4222, user:admin, password:admin
-
-
Method Details
-
config
GetNatServerConfig- Returns:
- the
Natsconfiguration
-
config
Configures the nats server- Returns:
- the
Natsconfiguration
-
config
Configures the nats server- Parameters:
config- passes the original parameters to the server.- Returns:
Nats- See Also:
-
config
Configures the nats server- Parameters:
kv- example: port, 4222, user, admin, password, admin- Returns:
Nats- See Also:
-
tryStart
Starts the server inProcessBuilderwith the given parameterConfigconfig(String...)Throws all exceptions asRuntimeException- Returns:
Nats
-
tryStart
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:
Nats
-
start
Starts the server inProcessBuilderwith the given configconfig(String...)- Returns:
Nats- Throws:
IOException- ifNatsis not found or unsupported on theSystemUtilBindException- if port is already takenPortUnreachableException- ifNatsis not starting cause port is not freeException
-
start
Starts the server inProcessBuilderwith the given configconfig(String...)- Parameters:
timeoutMs- defines the start-up timeout-1no timeout, else waits until port up- Returns:
Nats- Throws:
IOException- ifNatsis not found or unsupported on theSystemUtilBindException- if port is already takenPortUnreachableException- ifNatsis not starting cause port is not freeException
-
close
public void close() -
stop
Stops theProcessBuilderand kills theNatsOnly a log error will occur if theNatswere never started- Returns:
Nats
-
stop
Stops theProcessBuilderand kills theNatsOnly a log error will occur if theNatswere never started- Parameters:
timeoutMs- defines the tear down timeout,-1no timeout, else waits until port is free again- Returns:
Nats
-