Class PasProducer
- java.lang.Object
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageProducer
,AdaptrisMessageSender
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,JmsActorConfig
,MessageEventGenerator
@ComponentProfile(summary="Place message on a JMS Topic", tag="producer,jms", recommended=JmsConnection.class) public class PasProducer extends DefinedJmsProducer
AdaptrisMessageProducer
implementation for Topic based JMS.This implementation baselines to JMS 1.1 for minimum API support and its behaviour and support for standard JMS Headers can be controlled in a number of ways.
When converting from an
AdaptrisMessage
into a standardMessage
; you should choose an implementation ofMessageTypeTranslator
. The more common types areBytesMessageTranslator
,TextMessageTranslator
,ObjectMessageTranslator
andMapMessageTranslator
which correspond toBytesMessage
,TextMessage
,ObjectMessage
andMapMessage
respectively. EachMessageTypeTranslator
will allow you to move some or all metadata from the AdaptrisMessage to the JMS Message. Of course, there are other vendor specific JMS message types can be used.The
Message.getJMSCorrelationID()
field is generally used for linking one message to with another. It typically links a reply message with the originating request message. If you need to handle the correlation id in some fashion then typically you would choose an implementation ofCorrelationIdSource
that explicitly handles the correlation ID; for instanceMetadataCorrelationIdSource
.Synchronous request/reply messaging behaviour is available for this producer and relies heavily on the
Message.getJMSReplyTo()
field. Normally if the adapter is initiating the request then a temporary destination is created and this is used as the JMSReplyTo field. Sometimes you may wish to specify your own JMSReplyTo field (where the JMS Vendor doesn't play nice with temporary topics). To do this, then you need to ensure that the metadata key "JMSAsyncStaticReplyTo" is set with the appropriate queue name; this will cause that message to be produced to the topic with a JMSReplyTo set to that topic name. You may also use "JMSAsyncStaticReplyTo" in an asynchronous workflow; if the metadata key exists in the message then it will be used to populate the JMSReplyTo Field.By convention, the
Message.getJMSPriority()
,Message.getJMSDeliveryMode()
, andMessage.getJMSExpiration()
are configured directly (expiration here is semantically equivalent to the elementJmsProducerImpl.setTtl(Long)
on the producer. It is possible to control it dynamically on a per message basis using the elementJmsProducerImpl.setPerMessageProperties(Boolean)
. If you opt to control these fields on a per message basis then the following metadata keys are used :- "JMSPriority" - This overrides the priority of the message and should be an integer value.
- "JMSDeliveryMode" - This overrides the delivery
mode of the message, and can either be an integer or a string value understood by
DeliveryMode
- "JMSExpiration" - This overrides the expiration of the message, and can either be an long value specifying when the message expires, or a string value in the form "yyyy-MM-dd'T'HH:mm:ssZ". It will be used to calculate the correct TTL.
In the adapter configuration file this class is aliased as jms-topic-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 PasProducer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.jms.Topic
createDestination(java.lang.String name)
protected javax.jms.Destination
createTemporaryDestination()
java.lang.String
endpoint(AdaptrisMessage msg)
Return the endpoint that will be derived from the message.java.lang.String
getTopic()
The JMS Topicvoid
prepare()
Prepare for initialisation.void
produce(AdaptrisMessage msg)
Produces theAdaptrisMessage
to the default destination.AdaptrisMessage
request(AdaptrisMessage msg, long timeout)
Produces theAdaptrisMessage
and blocks for the specified timeout for a reply.void
setTopic(java.lang.String topic)
The JMS TopicPasProducer
withTopic(java.lang.String t)
-
Methods inherited from class com.adaptris.core.jms.DefinedJmsProducer
doProduce, doProduce, produce, request
-
Methods inherited from class com.adaptris.core.jms.JmsProducerImpl
acknowledge, calculateDeliveryMode, calculatePriority, calculateTimeToLive, captureOutgoingMessageDetails, captureOutgoingMessageDetails, close, commit, configuredAcknowledgeMode, configuredCorrelationIdSource, configuredMessageListener, configuredMessageTranslator, currentLogger, currentSession, defaultTimeout, getAcknowledgeMode, getCaptureOutgoingMessageDetails, getCorrelationIdSource, getDeliveryMode, getMessageTranslator, getPerMessageProperties, getPriority, getSessionFactory, getTtl, init, isManagedTransaction, logLinkedException, messagePriority, perMessageProperties, producerSession, request, retrieveObjectDestination, rollback, rollbackTimeout, setAcknowledgeMode, setCaptureOutgoingMessageDetails, setCorrelationIdSource, setDeliveryMode, setMessageTranslator, setPerMessageProperties, setPriority, setSessionFactory, setTtl, setupSession, start, stop, timeToLive, transactedSession, translate
-
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.MessageEventGenerator
createQualifier, isTrackingEndpoint
-
-
-
-
Method Detail
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Overrides:
prepare
in classJmsProducerImpl
- Throws:
CoreException
-
createDestination
protected javax.jms.Topic createDestination(java.lang.String name) throws javax.jms.JMSException
- Specified by:
createDestination
in classDefinedJmsProducer
- Throws:
javax.jms.JMSException
-
createTemporaryDestination
protected javax.jms.Destination createTemporaryDestination() throws javax.jms.JMSException
- Specified by:
createTemporaryDestination
in classDefinedJmsProducer
- Throws:
javax.jms.JMSException
-
request
public AdaptrisMessage request(AdaptrisMessage msg, long timeout) throws ProduceException
Description copied from interface:AdaptrisMessageProducer
Produces theAdaptrisMessage
and blocks for the specified timeout for a reply.- Parameters:
msg
- theAdaptrisMessage
to producetimeout
- the time to wait for a reply in milliseconds- Returns:
- a reply
AdaptrisMessage
which is generally the same as supplied parameter - Throws:
ProduceException
- wrapping any underlying Exceptions
-
produce
public void produce(AdaptrisMessage msg) throws ProduceException
Description copied from interface:AdaptrisMessageSender
Produces theAdaptrisMessage
to the default destination.- Parameters:
msg
- the @link AdaptrisMessage} to produce- Throws:
ProduceException
- wrapping any underlying Exceptions
-
endpoint
public java.lang.String endpoint(AdaptrisMessage msg) throws ProduceException
Description copied from class:AdaptrisMessageProducerImp
Return the endpoint that will be derived from the message.The purpose of this method is to mitigate the number of changes that need to happen because
ProduceDestination
is being deprecated; boilerplate code can still be present in the parent super-classes w/o impacting concrete sub-classes "too much".- Specified by:
endpoint
in classAdaptrisMessageProducerImp
- Throws:
ProduceException
- See Also:
AdaptrisMessageSender.produce(AdaptrisMessage)
-
withTopic
public PasProducer withTopic(java.lang.String t)
-
getTopic
public java.lang.String getTopic()
The JMS Topic
-
setTopic
public void setTopic(java.lang.String topic)
The JMS Topic
-
-