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 RequestReplyProducerImp
Produce the current message to a NATS server with the configured subject.
This effectively uses the Connection#publish(String, byte[]) or Connection#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 a AdaptrisMessageEncoder instance; 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected longThe default timeout if not specified is 60 seconds.protected voiddoProduce(AdaptrisMessage msg, String endpoint) protected AdaptrisMessagedoRequest(AdaptrisMessage msg, String endpoint, long timeout) endpoint(AdaptrisMessage msg) The NATS Subjectvoidprepare()voidsetSubject(String subject) The NATS Subjectprotected byte[]toByteArray(AdaptrisMessage msg, long maxSize) Methods inherited from class com.adaptris.core.RequestReplyProducerImp
produce, request, requestMethods inherited from class com.adaptris.core.RequestReplyProducerBase
copyReplyContents, getIgnoreReplyMetadata, mergeReply, setIgnoreReplyMetadataMethods inherited from class com.adaptris.core.AdaptrisMessageProducerImp
createNameMethods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueIDMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueIdMethods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactoryMethods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stopMethods inherited from interface com.adaptris.core.MessageEventGenerator
createQualifier, isTrackingEndpoint
-
Constructor Details
-
NatsProducer
public NatsProducer()
-
-
Method Details
-
prepare
- Throws:
CoreException
-
doProduce
- 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, String endpoint, long timeout) throws ProduceException - Specified by:
doRequestin classRequestReplyProducerImp- Throws:
ProduceException
-
toByteArray
- Throws:
Exception
-
endpoint
- Specified by:
endpointin classAdaptrisMessageProducerImp- Throws:
ProduceException
-
withSubject
-
getSubject
The NATS Subject -
setSubject
The NATS Subject
-