Class BasicNatsConnection
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisConnection,ComponentLifecycle,ComponentLifecycleExtension,StateManagedComponent
This connection assumes that Nats#connect(String) is sufficient configuration for connecting to your NATS server (i.e. everything
you need is configurable via the URL). Generally put your 'closest' NATS server as the URL, since it will discover other servers after it
initially connects and use those as required.
Configuring any kind of ConnectionErrorHandler has 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. By default outgoing messages will be buffered in memory;
pending reconnection and subsequent redelivery.
In the adapter configuration file this class is aliased as nats-server-basic-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 -
Method Summary
Modifier and TypeMethodDescriptionprotected io.nats.client.Connectionconnect()protected StringgetUrl()The URL to the nats server assuming thatNats#connect(String)is sufficient configuration for connecting to your NATS server.protected voidvoidThe URL to the nats server assuming thatNats#connect(String)is sufficient configuration for connecting to your NATS server.<T extends BasicNatsConnection>
TMethods inherited from class com.adaptris.interlok.nats.NatsConnection
clientConnection, close, closeConnection, createDispatcher, exceedsMaxAttempts, initConnection, startConnection, stopConnection, withConnectionRetriesMethods inherited from class com.adaptris.core.AllowsRetriesConnection
connectionAttempts, connectionRetryInterval, createLoggingStatement, getConnectionAttempts, getConnectionRetryInterval, logWarning, setConnectionAttempts, setConnectionRetryIntervalMethods 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
-
Constructor Details
-
BasicNatsConnection
public BasicNatsConnection()
-
-
Method Details
-
prepareConnection
- Overrides:
prepareConnectionin classNatsConnection- Throws:
CoreException
-
connect
- Specified by:
connectin classNatsConnection- Throws:
Exception
-
withUrl
-
connectionName
- Specified by:
connectionNamein classNatsConnection
-
getUrl
The URL to the nats server assuming thatNats#connect(String)is sufficient configuration for connecting to your NATS server.The Java client generally expects URLs of the form
nats://hostname:portbut has support for the additional forms (it can be a list that is comma separated):nats://user:pass@hostname:portnats://token@hostname:portopentls://hostname:portwhich will use TLS but accept "any certificates"tls://hostname:portwhich will use TLS using the default SSL Context and may require client certificates
-
setUrl
The URL to the nats server assuming thatNats#connect(String)is sufficient configuration for connecting to your NATS server.The Java client generally expects URLs of the form
nats://hostname:portbut has support for the additional forms (it can be a list that is comma separated):nats://user:pass@hostname:portnats://token@hostname:portopentls://hostname:portwhich will use TLS but accept "any certificates"tls://hostname:portwhich will use TLS using the default SSL Context and may require client certificates
-