Class BasicNatsConnection
- java.lang.Object
-
- com.adaptris.core.AdaptrisConnectionImp
-
- com.adaptris.core.AllowsRetriesConnection
-
- com.adaptris.interlok.nats.NatsConnection
-
- com.adaptris.interlok.nats.BasicNatsConnection
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisConnection
,ComponentLifecycle
,ComponentLifecycleExtension
,StateManagedComponent
@ComponentProfile(summary="Basic connection to a NATS server", tag="nats.io, nats", since="3.9.3") public class BasicNatsConnection extends NatsConnection
Basic Connection to a NATS server.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 Constructor Description BasicNatsConnection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected io.nats.client.Connection
connect()
protected java.lang.String
connectionName()
java.lang.String
getUrl()
The URL to the nats server assuming thatNats#connect(String)
is sufficient configuration for connecting to your NATS server.protected void
prepareConnection()
void
setUrl(java.lang.String url)
The URL to the nats server assuming thatNats#connect(String)
is sufficient configuration for connecting to your NATS server.<T extends BasicNatsConnection>
TwithUrl(java.lang.String u)
-
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:
prepareConnection
in classNatsConnection
- Throws:
CoreException
-
connect
protected io.nats.client.Connection connect() throws java.lang.Exception
- Specified by:
connect
in classNatsConnection
- Throws:
java.lang.Exception
-
withUrl
public <T extends BasicNatsConnection> T withUrl(java.lang.String u)
-
connectionName
protected java.lang.String connectionName()
- Specified by:
connectionName
in classNatsConnection
-
getUrl
public java.lang.String 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:port
but has support for the additional forms (it can be a list that is comma separated):nats://user:pass@hostname:port
nats://token@hostname:port
opentls://hostname:port
which will use TLS but accept "any certificates"tls://hostname:port
which will use TLS using the default SSL Context and may require client certificates
-
setUrl
public void setUrl(java.lang.String url)
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:port
but has support for the additional forms (it can be a list that is comma separated):nats://user:pass@hostname:port
nats://token@hostname:port
opentls://hostname:port
which will use TLS but accept "any certificates"tls://hostname:port
which will use TLS using the default SSL Context and may require client certificates
-
-