Class NatsConnectionFromProperties
- java.lang.Object
-
- com.adaptris.core.AdaptrisConnectionImp
-
- com.adaptris.core.AllowsRetriesConnection
-
- com.adaptris.interlok.nats.NatsConnection
-
- com.adaptris.interlok.nats.NatsConnectionFromProperties
-
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,StateManagedComponent
@ComponentProfile(summary="connection to a NATS server", tag="nats.io, nats", since="3.9.3") public class NatsConnectionFromProperties extends NatsConnectionConnection to a NATS server.Uses
io.nats.client#Options#Builder()to build the connection via the properties; no validation of properties is done, we just convert the configuration into properties and pass it into theBuilderobject.Configuring any kind of
ConnectionErrorHandlerhas no effect on this type of connection, as we will be relying on the automatic reconnection that happens behind the seens from the NATS core java client.In the adapter configuration file this class is aliased as nats-server-properties-connection which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.AdaptrisConnectionImp
log
-
-
Constructor Summary
Constructors Constructor Description NatsConnectionFromProperties()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected io.nats.client.Connectionconnect()protected java.lang.StringconnectionName()protected static java.lang.StringfindConnectionName(KeyValuePairSet p)KeyValuePairSetgetConnectionProperties()The connection properties.protected voidprepareConnection()voidsetConnectionProperties(KeyValuePairSet connectionProperties)The connection properties.<T extends NatsConnectionFromProperties>
TwithConnectionProperties(KeyValuePairSet p)-
Methods inherited from class com.adaptris.interlok.nats.NatsConnection
clientConnection, close, closeConnection, createDispatcher, exceedsMaxAttempts, initConnection, startConnection, stopConnection, withConnectionRetries
-
Methods inherited from class com.adaptris.core.AllowsRetriesConnection
connectionAttempts, connectionRetryInterval, createLoggingStatement, getConnectionAttempts, getConnectionRetryInterval, logWarning, setConnectionAttempts, setConnectionRetryInterval
-
Methods inherited from class com.adaptris.core.AdaptrisConnectionImp
addExceptionListener, addMessageConsumer, addMessageProducer, changeState, cloneForTesting, close, connectionErrorHandler, getConnectionErrorHandler, getUniqueId, getWorkersFirstOnShutdown, init, prepare, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, retrieveConnection, retrieveExceptionListeners, retrieveMessageConsumers, retrieveMessageProducers, setConnectionErrorHandler, setUniqueId, setWorkersFirstOnShutdown, start, stop, workersFirstOnShutdown
-
-
-
-
Method Detail
-
prepareConnection
protected void prepareConnection() throws CoreException- Overrides:
prepareConnectionin classNatsConnection- Throws:
CoreException
-
connect
protected io.nats.client.Connection connect() throws java.lang.Exception- Specified by:
connectin classNatsConnection- Throws:
java.lang.Exception
-
withConnectionProperties
public <T extends NatsConnectionFromProperties> T withConnectionProperties(KeyValuePairSet p)
-
connectionName
protected java.lang.String connectionName()
- Specified by:
connectionNamein classNatsConnection
-
findConnectionName
protected static java.lang.String findConnectionName(KeyValuePairSet p)
-
getConnectionProperties
public KeyValuePairSet getConnectionProperties()
The connection properties.You will probably need to refer to the NATS.io documentation to figure out the available properties; they will be passed in as-is to
new Options.Builder(Properties)with no verification. Generally the configuration properties will start withio.nats.client.but may change between releases.For instance if you wanted to control the URL / Username + Password then you might have
io.nats.client.url=nats://localhost:1234 io.nats.client.username=MyUsername io.nats.client.password=MyPassword io.nats.client.verbose=true
-
setConnectionProperties
public void setConnectionProperties(KeyValuePairSet connectionProperties)
The connection properties.You will probably need to refer to the NATS.io documentation to figure out the available properties; they will be passed in as-is to
new Options.Builder(Properties)with no verification. Generally the configuration properties will start withio.nats.client.but may change between releases.For instance if you wanted to control the URL / Username + Password then you might have
io.nats.client.url=nats://localhost:1234 io.nats.client.username=MyUsername io.nats.client.password=MyPassword io.nats.client.verbose=true
-
-