Class JmsOutboundGateway
- All Implemented Interfaces:
MessageListener
,org.reactivestreams.Subscriber<Message<?>>
,Aware
,BeanClassLoaderAware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Lifecycle
,Ordered
,ComponentSourceAware
,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 classes/interfaces inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
AbstractReplyProducingMessageHandler.RequestHandler
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
A default receive timeout in milliseconds.Fields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
messagingTemplate
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Connection
Create a new JMS Connection for this JMS gateway.protected Session
createSession
(Connection connection) Create a new JMS Session using the provided Connection.protected void
doInit()
Subclasses may implement this method to provide component type information.protected Object
handleRequestMessage
(Message<?> requestMessage) Subclasses must implement this method to handle the request Message.boolean
void
void
setConnectionFactory
(ConnectionFactory connectionFactory) Set the JMS ConnectionFactory that this gateway should use.void
setCorrelationKey
(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.void
setDefaultPriority
(int priority) Specify the default JMS priority to use when sending request Messages with noIntegrationMessageHeaderAccessor.PRIORITY
header.void
setDeliveryPersistent
(boolean deliveryPersistent) Set whether message delivery should be persistent or non-persistent, specified as a boolean value ("true" or "false").void
setDestinationResolver
(DestinationResolver destinationResolver) Provide theDestinationResolver
to use when resolving either a 'requestDestinationName' or 'replyDestinationName' value.void
setExplicitQosEnabled
(boolean explicitQosEnabled) Specify whether explicit QoS settings are enabled (deliveryMode, priority, and timeToLive).void
setExtractReplyPayload
(boolean extractReplyPayload) This property describes what to do with a JMS reply Message.void
setExtractRequestPayload
(boolean extractRequestPayload) This property describes how a JMS Message should be generated from the Spring Integration Message.void
setHeaderMapper
(JmsHeaderMapper headerMapper) Provide aJmsHeaderMapper
implementation for mapping the Spring Integration Message Headers to/from JMS Message properties.void
setIdleReplyContainerTimeout
(long idleReplyContainerTimeout) Set the target timeout for idle containers, in seconds.void
setIdleReplyContainerTimeout
(long idleReplyContainerTimeout, TimeUnit unit) Set the target timeout for idle containers.void
setMessageConverter
(MessageConverter messageConverter) Provide aMessageConverter
strategy 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.void
setReceiveTimeout
(long receiveTimeout) Set the max timeout value for the MessageConsumer's receive call when waiting for a reply.void
setReplyChannel
(MessageChannel replyChannel) Specify the Spring Integration reply channel.void
setReplyContainerProperties
(JmsOutboundGateway.ReplyContainerProperties replyContainerProperties) void
setReplyDestination
(Destination replyDestination) Set the JMS Destination from which reply Messages should be received.void
setReplyDestinationExpression
(Expression replyDestinationExpression) Set the SpEL Expression to be used for determining the reply Destination instance or reply destination name.void
setReplyDestinationName
(String replyDestinationName) Set the name of the JMS Destination from which reply Messages should be received.void
setReplyPubSubDomain
(boolean replyPubSubDomain) Specify whether the reply destination is a Topic.void
setRequestDestination
(Destination requestDestination) Set the JMS Destination to which request Messages should be sent.void
setRequestDestinationExpression
(Expression requestDestinationExpression) Set the SpEL Expression to be used for determining the request Destination instance or request destination name.void
setRequestDestinationName
(String requestDestinationName) Set the name of the JMS Destination to which request Messages should be sent.void
setRequestPubSubDomain
(boolean requestPubSubDomain) Specify whether the request destination is a Topic.void
setRequiresReply
(boolean requiresReply) Flag whether a reply is required.void
setTimeToLive
(long timeToLive) Specify the timeToLive for each sent Message.void
setUseReplyContainer
(boolean useReplyContainer) void
start()
void
stop()
Methods inherited from class org.springframework.integration.handler.AbstractReplyProducingMessageHandler
doInvokeAdvisedRequestHandler, getBeanClassLoader, getIntegrationPatternType, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader
Methods 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, updateNotPropagatedHeaders
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConvention
Methods 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, shouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface reactor.core.CoreSubscriber
currentContext
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods 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 aTemporaryQueue
per 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 aTemporaryQueue
per 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 theDestinationResolver
to 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.PRIORITY
header. 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 aMessageConverter
strategy 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 aJmsHeaderMapper
implementation 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:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classMessageHandlerSupport
-
setUseReplyContainer
public void setUseReplyContainer(boolean useReplyContainer) - Parameters:
useReplyContainer
- the useReplyContainer to set
-
setRequiresReply
public void setRequiresReply(boolean requiresReply) Description copied from class:AbstractReplyProducingMessageHandler
Flag 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:
setRequiresReply
in 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:
doInit
in classAbstractReplyProducingMessageHandler
-
start
public void start()- Specified by:
start
in interfaceLifecycle
- Specified by:
start
in interfaceManageableLifecycle
-
stop
public void stop()- Specified by:
stop
in interfaceLifecycle
- Specified by:
stop
in interfaceManageableLifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunning
in interfaceLifecycle
- Specified by:
isRunning
in interfaceManageableLifecycle
-
handleRequestMessage
Description copied from class:AbstractReplyProducingMessageHandler
Subclasses 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:
handleRequestMessage
in 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:
onMessage
in interfaceMessageListener
-