Class JmsOutboundGateway
- All Implemented Interfaces:
MessageListener,org.reactivestreams.Subscriber<Message<?>>,Aware,BeanClassLoaderAware,BeanFactoryAware,BeanNameAware,DisposableBean,InitializingBean,ApplicationContextAware,Lifecycle,Ordered,ExpressionCapable,Orderable,MessageProducer,HeaderPropagationAware,IntegrationPattern,NamedComponent,IntegrationManagement,ManageableLifecycle,TrackableComponent,MessageHandler,reactor.core.CoreSubscriber<Message<?>>
- Author:
- Mark Fisher, Arjen Poutsma, Juergen Hoeller, Oleg Zhurakousky, Gary Russell, Artem Bilan, Christian Tzolov
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandlerNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longA default receive timeout in milliseconds.Fields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
messagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ConnectionCreate a new JMS Connection for this JMS gateway.protected SessioncreateSession(Connection connection) Create a new JMS Session using the provided Connection.protected voiddoInit()Subclasses may implement this method to provide component type information.protected ObjecthandleRequestMessage(Message<?> requestMessage) Subclasses must implement this method to handle the request Message.booleanvoidvoidsetConnectionFactory(ConnectionFactory connectionFactory) Set the JMS ConnectionFactory that this gateway should use.voidsetCorrelationKey(String correlationKey) Provide the name of a JMS property that should hold a generated UUID that the receiver of the JMS Message would expect to represent the CorrelationID.voidsetDefaultPriority(int priority) Specify the default JMS priority to use when sending request Messages with noIntegrationMessageHeaderAccessor.PRIORITYheader.voidsetDeliveryPersistent(boolean deliveryPersistent) Set whether message delivery should be persistent or non-persistent, specified as a boolean value ("true" or "false").voidsetDestinationResolver(DestinationResolver destinationResolver) Provide theDestinationResolverto use when resolving either a 'requestDestinationName' or 'replyDestinationName' value.voidsetExplicitQosEnabled(boolean explicitQosEnabled) Specify whether explicit QoS settings are enabled (deliveryMode, priority, and timeToLive).voidsetExtractReplyPayload(boolean extractReplyPayload) This property describes what to do with a JMS reply Message.voidsetExtractRequestPayload(boolean extractRequestPayload) This property describes how a JMS Message should be generated from the Spring Integration Message.voidsetHeaderMapper(JmsHeaderMapper headerMapper) Provide aJmsHeaderMapperimplementation for mapping the Spring Integration Message Headers to/from JMS Message properties.voidsetIdleReplyContainerTimeout(long idleReplyContainerTimeout) Set the target timeout for idle containers, in seconds.voidsetIdleReplyContainerTimeout(long idleReplyContainerTimeout, TimeUnit unit) Set the target timeout for idle containers.voidsetMessageConverter(MessageConverter messageConverter) Provide aMessageConverterstrategy to use for converting the Spring Integration request Message into a JMS Message and for converting the JMS reply Messages back into Spring Integration Messages.voidsetReceiveTimeout(long receiveTimeout) Set the max timeout value for the MessageConsumer's receive call when waiting for a reply.voidsetReplyChannel(MessageChannel replyChannel) Specify the Spring Integration reply channel.voidsetReplyContainerProperties(JmsOutboundGateway.ReplyContainerProperties replyContainerProperties) voidsetReplyDestination(Destination replyDestination) Set the JMS Destination from which reply Messages should be received.voidsetReplyDestinationExpression(Expression replyDestinationExpression) Set the SpEL Expression to be used for determining the reply Destination instance or reply destination name.voidsetReplyDestinationName(String replyDestinationName) Set the name of the JMS Destination from which reply Messages should be received.voidsetReplyPubSubDomain(boolean replyPubSubDomain) Specify whether the reply destination is a Topic.voidsetRequestDestination(Destination requestDestination) Set the JMS Destination to which request Messages should be sent.voidsetRequestDestinationExpression(Expression requestDestinationExpression) Set the SpEL Expression to be used for determining the request Destination instance or request destination name.voidsetRequestDestinationName(String requestDestinationName) Set the name of the JMS Destination to which request Messages should be sent.voidsetRequestPubSubDomain(boolean requestPubSubDomain) Specify whether the request destination is a Topic.voidsetRequiresReply(boolean requiresReply) Flag whether a reply is required.voidsetTimeToLive(long timeToLive) Specify the timeToLive for each sent Message.voidsetUseReplyContainer(boolean useReplyContainer) voidstart()voidstop()Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
doInvokeAdvisedRequestHandler, getBeanClassLoader, getIntegrationPatternType, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoaderMethods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscriber
currentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Field Details
-
DEFAULT_RECEIVE_TIMEOUT
public static final long DEFAULT_RECEIVE_TIMEOUTA default receive timeout in milliseconds.- See Also:
-
-
Constructor Details
-
JmsOutboundGateway
public JmsOutboundGateway()
-
-
Method Details
-
setDeliveryPersistent
public void setDeliveryPersistent(boolean deliveryPersistent) Set whether message delivery should be persistent or non-persistent, specified as a boolean value ("true" or "false"). This will set the delivery mode accordingly to either "PERSISTENT" (1) or "NON_PERSISTENT" (2).The default is "true", i.e. delivery mode "PERSISTENT".
- Parameters:
deliveryPersistent- true for a persistent delivery.- See Also:
-
setConnectionFactory
Set the JMS ConnectionFactory that this gateway should use. This is a required property.- Parameters:
connectionFactory- The connection factory.
-
setRequestDestination
Set the JMS Destination to which request Messages should be sent. Either this or one of 'requestDestinationName' or 'requestDestinationExpression' is required.- Parameters:
requestDestination- The request destination.
-
setRequestDestinationName
Set the name of the JMS Destination to which request Messages should be sent. Either this or one of 'requestDestination' or 'requestDestinationExpression' is required.- Parameters:
requestDestinationName- The request destination name.
-
setRequestDestinationExpression
Set the SpEL Expression to be used for determining the request Destination instance or request destination name. Either this or one of 'requestDestination' or 'requestDestinationName' is required.- Parameters:
requestDestinationExpression- The request destination expression.
-
setReplyDestination
Set the JMS Destination from which reply Messages should be received. If none is provided, this gateway will create aTemporaryQueueper invocation.- Parameters:
replyDestination- The reply destination.
-
setReplyDestinationName
Set the name of the JMS Destination from which reply Messages should be received. If none is provided, this gateway will create aTemporaryQueueper invocation.- Parameters:
replyDestinationName- The reply destination name.
-
setReplyDestinationExpression
Set the SpEL Expression to be used for determining the reply Destination instance or reply destination name. Either this or one of 'replyDestination' or 'replyDestinationName' is required.- Parameters:
replyDestinationExpression- The reply destination expression.
-
setDestinationResolver
Provide theDestinationResolverto use when resolving either a 'requestDestinationName' or 'replyDestinationName' value. The default is an instance ofDynamicDestinationResolver.- Parameters:
destinationResolver- The destination resolver.
-
setRequestPubSubDomain
public void setRequestPubSubDomain(boolean requestPubSubDomain) Specify whether the request destination is a Topic. This value is necessary when providing a destination name for a Topic rather than a destination reference.- Parameters:
requestPubSubDomain- true if the request destination is a Topic.
-
setReplyPubSubDomain
public void setReplyPubSubDomain(boolean replyPubSubDomain) Specify whether the reply destination is a Topic. This value is necessary when providing a destination name for a Topic rather than a destination reference.- Parameters:
replyPubSubDomain- true if the reply destination is a Topic.
-
setReceiveTimeout
public void setReceiveTimeout(long receiveTimeout) Set the max timeout value for the MessageConsumer's receive call when waiting for a reply. The default value is 5 seconds.- Parameters:
receiveTimeout- The receive timeout.
-
setDefaultPriority
public void setDefaultPriority(int priority) Specify the default JMS priority to use when sending request Messages with noIntegrationMessageHeaderAccessor.PRIORITYheader. The value should be within the range of 0-9.- Parameters:
priority- The priority.- Since:
- 5.1.2
-
setTimeToLive
public void setTimeToLive(long timeToLive) Specify the timeToLive for each sent Message. The default value indicates no expiration.- Parameters:
timeToLive- The time to live.
-
setExplicitQosEnabled
public void setExplicitQosEnabled(boolean explicitQosEnabled) Specify whether explicit QoS settings are enabled (deliveryMode, priority, and timeToLive).- Parameters:
explicitQosEnabled- true to enable explicit QoS.
-
setCorrelationKey
Provide the name of a JMS property that should hold a generated UUID that the receiver of the JMS Message would expect to represent the CorrelationID. When waiting for the reply Message, a MessageSelector will be configured to match this property name and the UUID value that was sent in the request.If this value is NULL (the default) then the reply consumer's MessageSelector will be expecting the JMSCorrelationID to equal the Message ID of the request.
If you want to store the outbound correlation UUID value in the actual JMSCorrelationID property, then set this value to "JMSCorrelationID".
If you want to use and existing "JMSCorrelationID" from the inbound message (mapped from 'jms_correlationId'), you can set this property to "JMSCorrelationID*" with the trailing asterisk. If the message has a correlation id, it will be used, otherwise a new one will be set in the 'JMSCorrelationID' header. However, understand that the gateway has no means to ensure uniqueness and unexpected side effects can occur if the correlation id is not unique.
This setting is not allowed if a reply listener is used.
- Parameters:
correlationKey- The correlation key.
-
setMessageConverter
Provide aMessageConverterstrategy to use for converting the Spring Integration request Message into a JMS Message and for converting the JMS reply Messages back into Spring Integration Messages.The default is
SimpleMessageConverter.- Parameters:
messageConverter- The message converter.
-
setHeaderMapper
Provide aJmsHeaderMapperimplementation for mapping the Spring Integration Message Headers to/from JMS Message properties.- Parameters:
headerMapper- The header mapper.
-
setExtractRequestPayload
public void setExtractRequestPayload(boolean extractRequestPayload) This property describes how a JMS Message should be generated from the Spring Integration Message. If set to 'true', the body of the JMS Message will be created from the Spring Integration Message's payload (via the MessageConverter). If set to 'false', then the entire Spring Integration Message will serve as the base for JMS Message creation. Since the JMS Message is created by the MessageConverter, this really manages what is sent to theMessageConverter: the entire Spring Integration Message or only its payload. Default is 'true'.- Parameters:
extractRequestPayload- true to extract the request payload.
-
setExtractReplyPayload
public void setExtractReplyPayload(boolean extractReplyPayload) This property describes what to do with a JMS reply Message. If set to 'true', the payload of the Spring Integration Message will be created from the JMS Reply Message's body (via MessageConverter). Otherwise, the entire JMS Message will become the payload of the Spring Integration Message.- Parameters:
extractReplyPayload- true to extract the reply payload.
-
setReplyChannel
Specify the Spring Integration reply channel. If this property is not set the gateway will check for a 'replyChannel' header on the request.- Parameters:
replyChannel- The reply channel.
-
setReplyContainerProperties
public void setReplyContainerProperties(JmsOutboundGateway.ReplyContainerProperties replyContainerProperties) - Parameters:
replyContainerProperties- the replyContainerProperties to set
-
getComponentType
Description copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classMessageHandlerSupport
-
setUseReplyContainer
public void setUseReplyContainer(boolean useReplyContainer) - Parameters:
useReplyContainer- the useReplyContainer to set
-
setRequiresReply
public void setRequiresReply(boolean requiresReply) Description copied from class:AbstractReplyProducingMessageHandlerFlag whether a reply is required. If true an incoming message MUST result in a reply message being sent. If false an incoming message MAY result in a reply message being sent. Default is false.- Overrides:
setRequiresReplyin classAbstractReplyProducingMessageHandler- Parameters:
requiresReply- true if a reply is required.
-
setIdleReplyContainerTimeout
public void setIdleReplyContainerTimeout(long idleReplyContainerTimeout) Set the target timeout for idle containers, in seconds. Setting this greater than zero enables lazy starting of the reply listener container. The container will be started when a message is sent. It will be stopped when idle for at least this time. The actual stop time may be up to 1.5x this time.- Parameters:
idleReplyContainerTimeout- the timeout in seconds.- Since:
- 4.2
-
setIdleReplyContainerTimeout
Set the target timeout for idle containers. Setting this greater than zero enables lazy starting of the reply listener container. The container will be started when a message is sent. It will be stopped when idle for at least this time. The actual stop time may be up to 1.5x this time.- Parameters:
idleReplyContainerTimeout- the timeout in seconds.unit- the time unit.- Since:
- 4.2
-
doInit
protected void doInit()- Overrides:
doInitin classAbstractReplyProducingMessageHandler
-
start
public void start()- Specified by:
startin interfaceLifecycle- Specified by:
startin interfaceManageableLifecycle
-
stop
public void stop()- Specified by:
stopin interfaceLifecycle- Specified by:
stopin interfaceManageableLifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceLifecycle- Specified by:
isRunningin interfaceManageableLifecycle
-
handleRequestMessage
Description copied from class:AbstractReplyProducingMessageHandlerSubclasses must implement this method to handle the request Message. The return value may be a Message, a MessageBuilder, or any plain Object. The base class will handle the final creation of a reply Message from any of those starting points. If the return value is null, the Message flow will end here.- Specified by:
handleRequestMessagein classAbstractReplyProducingMessageHandler- Parameters:
requestMessage- The request message.- Returns:
- The result of handling the message, or
null.
-
createConnection
Create a new JMS Connection for this JMS gateway.- Returns:
- The connection.
- Throws:
JMSException- Any JMSException.
-
createSession
Create a new JMS Session using the provided Connection.- Parameters:
connection- The connection.- Returns:
- The session.
- Throws:
JMSException- Any JMSException.
-
onMessage
- Specified by:
onMessagein interfaceMessageListener
-