Class NatsConsumer
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageConsumerImp
-
- com.adaptris.interlok.nats.NatsConsumer
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,StateManagedComponent
@ComponentProfile(summary="Consumer implementation for NATS.io", tag="nats.io, nats", since="3.9.3") public class NatsConsumer extends AdaptrisMessageConsumerImp
Consumer implementation for NATS.io.This uses the NATS core API, and as a result does not offer anything similar to JMS Topic durable susbscribers; NATS core offers an at most once quality of service. If a subscriber is not listening on the subject (no subject match), or is not active when the message is sent, the message is not received. This is the same level of guarantee that TCP/IP provides. By default, NATS is a fire-and-forget messaging system.
When the consumer is stopped; then we automatically unsubscribe from the subscription
In the adapter configuration file this class is aliased as nats-standard-consumer which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description NatsConsumer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
consumeLocationKey()
java.lang.String
getQueueGroup()
Specify the queue group for this consumer if it is required.java.lang.String
getSubject()
The Subject for the NATS subscriptionprotected java.lang.String
newThreadName()
void
prepare()
void
setQueueGroup(java.lang.String queueGroup)
Specify the queue group for this consumer if it is required.void
setSubject(java.lang.String subject)
The Subject for the NATS subscriptionvoid
start()
void
stop()
NatsConsumer
withQueueGroup(java.lang.String s)
NatsConsumer
withSubject(java.lang.String s)
-
Methods inherited from class com.adaptris.core.AdaptrisMessageConsumerImp
changeState, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
-
-
-
Method Detail
-
prepare
public void prepare() throws CoreException
- Throws:
CoreException
-
start
public void start() throws CoreException
- Throws:
CoreException
-
stop
public void stop()
-
withQueueGroup
public NatsConsumer withQueueGroup(java.lang.String s)
-
withSubject
public NatsConsumer withSubject(java.lang.String s)
-
consumeLocationKey
public java.lang.String consumeLocationKey()
-
newThreadName
protected java.lang.String newThreadName()
- Overrides:
newThreadName
in classAdaptrisMessageConsumerImp
-
getQueueGroup
public java.lang.String getQueueGroup()
Specify the queue group for this consumer if it is required.By specifying a queue group you implicitly enable built-in load balancing feature called distributed queues. this will balance message delivery across a group of subscribers. All subscribers with the same queue name form the queue group. As messages on the registered subject are published, one member of the group is chosen randomly to receive the message. Although queue groups have multiple subscribers, each message is consumed by only one.
-
setQueueGroup
public void setQueueGroup(java.lang.String queueGroup)
Specify the queue group for this consumer if it is required.By specifying a queue group you implicitly enable built-in load balancing feature called distributed queues. this will balance message delivery across a group of subscribers. All subscribers with the same queue name form the queue group. As messages on the registered subject are published, one member of the group is chosen randomly to receive the message. Although queue groups have multiple subscribers, each message is consumed by only one.
-
getSubject
public java.lang.String getSubject()
The Subject for the NATS subscription
-
setSubject
public void setSubject(java.lang.String subject)
The Subject for the NATS subscription
-
-