Class JmsProducer
- java.lang.Object
-
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisMessageProducer,AdaptrisMessageSender,AdaptrisMessageWorker,ComponentLifecycle,ComponentLifecycleExtension,JmsActorConfig,MessageEventGenerator
- Direct Known Subclasses:
JmsAsyncProducer
@ComponentProfile(summary="Place message on a JMS queue or topic", tag="producer,jms", recommended=JmsConnection.class) public class JmsProducer extends JmsProducerImplJMS Producer implementation that can target queues or topics via an RFC6167 style destination.This differs from the standard
PtpProducerandPasProducerin that it supports a destination that is specified in RFC6167 style. For instancejms:queue:myQueueNamewill produce to a queue calledmyQueueNameandjms:topic:myTopicNameto a topic calledmyTopicNameWhile RFC6167 defines the ability to use jndi to lookup the (as part of the 'jndi' variant section); this is not supported. The standard deliveryMode, timeToLive, priority, replyToName properties are supported. If not specified, then they will be inherited from the producers configuration. For instance you could have the following destinations:
- jms:queue:MyQueueName
- jms:topic:MyTopicName
- jms:queue:MyQueueName?replyToName=StaticReplyTo&priority=1&timeToLive=1234
- jms:topic:MyTopicName?replyToName=StaticReplyTo
As the RFC6167 string can specify priority, timeToLive and deliveryMode; this producer defaults
JmsProducerImpl.getPerMessageProperties()to be true.In the adapter configuration file this class is aliased as jms-producer which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classJmsProducer.MyJmsDestination
-
Field Summary
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description JmsProducer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected JmsDestinationbuildDestination(java.lang.String dest, AdaptrisMessage msg, boolean createReplyTo)Build a JMSDestination.protected javax.jms.DestinationcreateReplyTo(AdaptrisMessage msg, JmsDestination target, boolean createTmpDest)Create a Destination for JMSReplyTo if one doesn't already exist or ifJMS_ASYNC_STATIC_REPLY_TOexists as metadata.java.lang.Stringendpoint(AdaptrisMessage msg)Return the endpoint that will be derived from the message.java.lang.StringgetEndpoint()The JMS Endpoint defined in an RFC6167 manner.booleanperMessageProperties()voidprepare()Prepare for initialisation.voidproduce(AdaptrisMessage msg)Produces theAdaptrisMessageto the default destination.protected voidproduce(AdaptrisMessage msg, JmsDestination jmsDest)voidproduce(AdaptrisMessage msg, java.lang.String dest)AdaptrisMessagerequest(AdaptrisMessage msg, long timeout)Produces theAdaptrisMessageand blocks for the specified timeout for a reply.AdaptrisMessagerequest(AdaptrisMessage msg, java.lang.String dest, long timeout)voidsetEndpoint(java.lang.String endpoint)The JMS Endpoint defined in an RFC6167 manner.protected <T extends VendorImplementationBase>
TvendorImplementation()protected AdaptrisMessagewaitForReply(javax.jms.MessageConsumer receiver, long timeout)Wait for a reply.<T extends JmsProducer>
TwithEndpoint(java.lang.String s)-
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, 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 CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Specified by:
preparein interfaceComponentLifecycleExtension- Overrides:
preparein classJmsProducerImpl- Throws:
CoreException
-
produce
public void produce(AdaptrisMessage msg, java.lang.String dest) throws ProduceException
- Throws:
ProduceException
-
produce
protected void produce(AdaptrisMessage msg, JmsDestination jmsDest) throws javax.jms.JMSException, CoreException
- Throws:
javax.jms.JMSExceptionCoreException
-
request
public AdaptrisMessage request(AdaptrisMessage msg, java.lang.String dest, long timeout) throws ProduceException
- Throws:
ProduceException
-
waitForReply
protected AdaptrisMessage waitForReply(javax.jms.MessageConsumer receiver, long timeout) throws javax.jms.JMSException
Wait for a reply.- Parameters:
receiver- theMessageConsumertimeout- the timeout (ms)- Returns:
- an AdaptrisMessage translated by the configured MessageTranslator
- Throws:
javax.jms.JMSException- on Exception (including a timeout exception).
-
buildDestination
protected JmsDestination buildDestination(java.lang.String dest, AdaptrisMessage msg, boolean createReplyTo) throws javax.jms.JMSException, CoreException
Build a JMSDestination.- Parameters:
dest- the ProduceDestinationmsg- the messagecreateReplyTo- - passed through tocreateReplyTo(AdaptrisMessage, JmsDestination, boolean)- Returns:
- a JMSDestination instanced.
- Throws:
javax.jms.JMSExceptionCoreException
-
createReplyTo
protected javax.jms.Destination createReplyTo(AdaptrisMessage msg, JmsDestination target, boolean createTmpDest) throws javax.jms.JMSException
Create a Destination for JMSReplyTo if one doesn't already exist or ifJMS_ASYNC_STATIC_REPLY_TOexists as metadata.- Parameters:
msg- the message (which will be checked forJMS_ASYNC_STATIC_REPLY_TO.createTmpDest- - create a temporary destination ifJMS_ASYNC_STATIC_REPLY_TOisn't available.- Returns:
- a javax.jms.Destination
- Throws:
javax.jms.JMSException
-
vendorImplementation
protected <T extends VendorImplementationBase> T vendorImplementation()
-
request
public AdaptrisMessage request(AdaptrisMessage msg, long timeout) throws ProduceException
Description copied from interface:AdaptrisMessageProducerProduces theAdaptrisMessageand blocks for the specified timeout for a reply.- Parameters:
msg- theAdaptrisMessageto producetimeout- the time to wait for a reply in milliseconds- Returns:
- a reply
AdaptrisMessagewhich 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:AdaptrisMessageSenderProduces theAdaptrisMessageto 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:AdaptrisMessageProducerImpReturn 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
ProduceDestinationis being deprecated; boilerplate code can still be present in the parent super-classes w/o impacting concrete sub-classes "too much".- Specified by:
endpointin classAdaptrisMessageProducerImp- Throws:
ProduceException- See Also:
AdaptrisMessageSender.produce(AdaptrisMessage)
-
perMessageProperties
public boolean perMessageProperties()
- Overrides:
perMessagePropertiesin classJmsProducerImpl
-
withEndpoint
public <T extends JmsProducer> T withEndpoint(java.lang.String s)
-
getEndpoint
public java.lang.String getEndpoint()
The JMS Endpoint defined in an RFC6167 manner.
-
setEndpoint
public void setEndpoint(java.lang.String endpoint)
The JMS Endpoint defined in an RFC6167 manner.
-
-