@ComponentProfile(summary="Place message on a JMS queue or topic asynchronously", tag="producer,jms", recommended=JmsConnection.class) public class JmsAsyncProducer extends JmsProducer implements javax.jms.CompletionListener
JmsProducer
, but allows us to send messages asynchronously.
Essentially the producer sending the message to the JMS provider will not wait for a response that would normally confirm the message
has been received and persisted. Instead the producer sends the JMS message in a "fire-and-forget" manner.
At some future point in time, the JMS provider will call us back with confirmation or inform us of an error for each sent message.
Should the message have failed to be fully received or persisted, you can configure an async-message-error-handler.
An important note about the async-message-error-handle, is that it will process the message in the state it was in just before the produce was attempted. If you have modified the message in the workflow before producing then attempting to "retry" this failed message through the same workflow may therefore be problematic.
One of the benefits to sending messages asynchronously simply comes down to processing speed. During any producer, it is generally the time waiting for the JMS provider to return control back to the client after the client submits a message that takes the most time. With asynchronous message producing, we no longer have to wait for the JMS provider, allowing us to move onto the next message.
NOTE: Once this producer has sent a message it is assumed to have succeeded, at least until a success or failure callback is received.
This means that if this producer is one of your workflow producers, the workflow itself will immediately deem this
message to have been processed and will move onto the next available message.
Generally this may not be an issue, however if processing a message triggers a form of transaction committing or JMS acknowledging,
then the commit or ack could be completed regardless if the sent JMS message eventually succeeds or fails.
In the adapter configuration file this class is aliased as jms-async-producer which is the preferred alternative to the fully qualified classname when building your configuration.
producerSession
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
JmsAsyncProducer() |
Modifier and Type | Method and Description |
---|---|
StandardProcessingExceptionHandler |
getAsyncMessageErrorHandler() |
void |
init()
Initialises the component.
|
void |
onCompletion(javax.jms.Message message) |
void |
onException(javax.jms.Message message,
java.lang.Exception exception) |
protected void |
produce(AdaptrisMessage msg,
JmsDestination jmsDest) |
void |
setAsyncMessageErrorHandler(StandardProcessingExceptionHandler asyncMessageErrorHandler) |
doRequest, perMessageProperties, produce
acknowledge, calculateDeliveryMode, calculatePriority, calculateTimeToLive, captureOutgoingMessageDetails, captureOutgoingMessageDetails, close, commit, configuredAcknowledgeMode, configuredCorrelationIdSource, configuredMessageListener, configuredMessageTranslator, createDestination, currentLogger, currentSession, defaultTimeout, getAcknowledgeMode, getCaptureOutgoingMessageDetails, getCorrelationIdSource, getDeliveryMode, getMessageTranslator, getPerMessageProperties, getPriority, getSessionFactory, getTtl, isManagedTransaction, logLinkedException, messagePriority, prepare, rollback, rollbackTimeout, setAcknowledgeMode, setCaptureOutgoingMessageDetails, setCorrelationIdSource, setDeliveryMode, setMessageTranslator, setPerMessageProperties, setPriority, setSessionFactory, setTtl, setupSession, start, stop, timeToLive, translate
getIgnoreReplyMetadata, produce, request, request, request, request, setIgnoreReplyMetadata, shouldIgnoreReplyMetadata
getDestination, setDestination
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
createName, createQualifier, isTrackingEndpoint
protected void produce(AdaptrisMessage msg, JmsDestination jmsDest) throws javax.jms.JMSException, CoreException
produce
in class JmsProducer
javax.jms.JMSException
CoreException
public void onCompletion(javax.jms.Message message)
onCompletion
in interface javax.jms.CompletionListener
public void onException(javax.jms.Message message, java.lang.Exception exception)
onException
in interface javax.jms.CompletionListener
public StandardProcessingExceptionHandler getAsyncMessageErrorHandler()
public void setAsyncMessageErrorHandler(StandardProcessingExceptionHandler asyncMessageErrorHandler)
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
init
in class JmsProducerImpl
CoreException
- wrapping any underlying Exception
s