Package com.adaptris.interlok.nats
Class NatsProducer
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageProducerImp
-
- com.adaptris.core.RequestReplyProducerBase
-
- com.adaptris.core.RequestReplyProducerImp
-
- com.adaptris.interlok.nats.NatsProducer
-
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisMessageProducer,AdaptrisMessageSender,AdaptrisMessageWorker,ComponentLifecycle,ComponentLifecycleExtension,MessageEventGenerator
@ComponentProfile(summary="Send a message to a NATS server", tag="nats.io, nats", recommended=NatsConnection.class, since="3.9.3") public class NatsProducer extends RequestReplyProducerImpProduce the current message to a NATS server with the configured subject.This effectively uses the
Since the payload for NATS.io is always an opaque set of bytes; if you wish to includeConnection#publish(String, byte[])orConnection#request(String, byte[], java.time.Duration)to send the message to NATS. The subject will be derived form the configured destination.AdaptrisMessage.getMetadata()in the message, then you will have to configure aAdaptrisMessageEncoderinstance; otherwise all metadata is lost.In the adapter configuration file this class is aliased as nats-standard-producer 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 NatsProducer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected longdefaultTimeout()The default timeout if not specified is 60 seconds.protected voiddoProduce(AdaptrisMessage msg, java.lang.String endpoint)protected AdaptrisMessagedoRequest(AdaptrisMessage msg, java.lang.String endpoint, long timeout)java.lang.Stringendpoint(AdaptrisMessage msg)java.lang.StringgetSubject()The NATS Subjectvoidprepare()voidsetSubject(java.lang.String subject)The NATS Subjectprotected byte[]toByteArray(AdaptrisMessage msg, long maxSize)NatsProducerwithSubject(java.lang.String s)-
Methods inherited from class com.adaptris.core.RequestReplyProducerImp
produce, request, request
-
Methods inherited from class com.adaptris.core.RequestReplyProducerBase
copyReplyContents, getIgnoreReplyMetadata, mergeReply, setIgnoreReplyMetadata
-
Methods inherited from class com.adaptris.core.AdaptrisMessageProducerImp
createName
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
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, start, stop
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createQualifier, isTrackingEndpoint
-
-
-
-
Method Detail
-
prepare
public void prepare() throws CoreException- Throws:
CoreException
-
doProduce
protected void doProduce(AdaptrisMessage msg, java.lang.String endpoint) throws ProduceException
- Specified by:
doProducein classRequestReplyProducerImp- Throws:
ProduceException
-
defaultTimeout
protected long defaultTimeout()
The default timeout if not specified is 60 seconds.- Specified by:
defaultTimeoutin classRequestReplyProducerBase
-
doRequest
protected AdaptrisMessage doRequest(AdaptrisMessage msg, java.lang.String endpoint, long timeout) throws ProduceException
- Specified by:
doRequestin classRequestReplyProducerImp- Throws:
ProduceException
-
toByteArray
protected byte[] toByteArray(AdaptrisMessage msg, long maxSize) throws java.lang.Exception
- Throws:
java.lang.Exception
-
endpoint
public java.lang.String endpoint(AdaptrisMessage msg) throws ProduceException
- Specified by:
endpointin classAdaptrisMessageProducerImp- Throws:
ProduceException
-
withSubject
public NatsProducer withSubject(java.lang.String s)
-
getSubject
public java.lang.String getSubject()
The NATS Subject
-
setSubject
public void setSubject(java.lang.String subject)
The NATS Subject
-
-