Class 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.

    • Constructor Detail

      • NatsConsumer

        public NatsConsumer()
    • Method Detail

      • 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()
      • 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