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 JmsProducerImpl
JMS Producer implementation that can target queues or topics via an RFC6167 style destination.This differs from the standard
PtpProducer
andPasProducer
in that it supports a destination that is specified in RFC6167 style. For instancejms:queue:myQueueName
will produce to a queue calledmyQueueName
andjms:topic:myTopicName
to a topic calledmyTopicName
While 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 class
JmsProducer.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 JmsDestination
buildDestination(java.lang.String dest, AdaptrisMessage msg, boolean createReplyTo)
Build a JMSDestination.protected javax.jms.Destination
createReplyTo(AdaptrisMessage msg, JmsDestination target, boolean createTmpDest)
Create a Destination for JMSReplyTo if one doesn't already exist or ifJMS_ASYNC_STATIC_REPLY_TO
exists as metadata.java.lang.String
endpoint(AdaptrisMessage msg)
Return the endpoint that will be derived from the message.java.lang.String
getEndpoint()
The JMS Endpoint defined in an RFC6167 manner.boolean
perMessageProperties()
void
prepare()
Prepare for initialisation.void
produce(AdaptrisMessage msg)
Produces theAdaptrisMessage
to the default destination.protected void
produce(AdaptrisMessage msg, JmsDestination jmsDest)
void
produce(AdaptrisMessage msg, java.lang.String dest)
AdaptrisMessage
request(AdaptrisMessage msg, long timeout)
Produces theAdaptrisMessage
and blocks for the specified timeout for a reply.AdaptrisMessage
request(AdaptrisMessage msg, java.lang.String dest, long timeout)
void
setEndpoint(java.lang.String endpoint)
The JMS Endpoint defined in an RFC6167 manner.protected <T extends VendorImplementationBase>
TvendorImplementation()
protected AdaptrisMessage
waitForReply(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 CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Overrides:
prepare
in 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.JMSException
CoreException
-
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
- theMessageConsumer
timeout
- 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.JMSException
CoreException
-
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_TO
exists as metadata.- Parameters:
msg
- the message (which will be checked forJMS_ASYNC_STATIC_REPLY_TO
.createTmpDest
- - create a temporary destination ifJMS_ASYNC_STATIC_REPLY_TO
isn'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: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)
-
perMessageProperties
public boolean perMessageProperties()
- Overrides:
perMessageProperties
in 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.
-
-