Class ChannelPublishingJmsMessageListener

java.lang.Object
org.springframework.integration.jms.ChannelPublishingJmsMessageListener
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.TrackableComponent, org.springframework.jms.listener.SessionAwareMessageListener<jakarta.jms.Message>

public class ChannelPublishingJmsMessageListener extends Object implements org.springframework.jms.listener.SessionAwareMessageListener<jakarta.jms.Message>, org.springframework.beans.factory.InitializingBean, org.springframework.integration.support.management.TrackableComponent, org.springframework.beans.factory.BeanFactoryAware
JMS MessageListener that converts a JMS Message into a Spring Integration Message and sends that Message to a channel. If the 'expectReply' value is true, it will also wait for a Spring Integration reply Message and convert that into a JMS reply.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.springframework.core.log.LogAccessor
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
     
     
    void
    onMessage(jakarta.jms.Message jmsMessage, jakarta.jms.Session session)
     
    void
    setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
     
    void
    setComponentName(String componentName)
     
    void
    setCorrelationKey(String correlationKey)
    Provide the name of a JMS property that should be copied from the request Message to the reply Message.
    void
    setDefaultReplyDestination(jakarta.jms.Destination defaultReplyDestination)
    Set the default reply destination to send reply messages to.
    void
    Set the name of the default reply queue to send reply messages to.
    void
    Set the name of the default reply topic to send reply messages to.
    void
    setDestinationResolver(org.springframework.jms.support.destination.DestinationResolver destinationResolver)
    Set the DestinationResolver that should be used to resolve reply destination names for this listener.
    void
    setErrorChannel(org.springframework.messaging.MessageChannel errorChannel)
     
    void
    setErrorChannelName(String errorChannelName)
     
    void
    setErrorOnTimeout(boolean errorOnTimeout)
     
    void
    setExpectReply(boolean expectReply)
    Specify whether a JMS reply Message is expected.
    void
    setExplicitQosEnabledForReplies(boolean explicitQosEnabledForReplies)
    Specify whether explicit QoS should be enabled for replies (for timeToLive, priority, and deliveryMode settings).
    void
    setExtractReplyPayload(boolean extractReplyPayload)
    Specify whether the Spring Integration reply Message's payload should be extracted prior to converting into a JMS Message.
    void
    setExtractRequestPayload(boolean extractRequestPayload)
    Specify whether the JMS request Message's body should be extracted prior to converting into a Spring Integration Message.
    void
    Provide a JmsHeaderMapper implementation to use when converting between JMS Messages and Spring Integration Messages.
    void
    setMessageConverter(org.springframework.jms.support.converter.MessageConverter messageConverter)
    Provide a MessageConverter implementation to use when converting between JMS Messages and Spring Integration Messages.
    void
    setMetricsCaptor(org.springframework.integration.support.management.metrics.MetricsCaptor captor)
     
    void
    setObservationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry)
     
    void
    setReceiverObservationConvention(org.springframework.integration.support.management.observation.MessageReceiverObservationConvention observationConvention)
     
    void
    setRecoveryCallback(org.springframework.retry.RecoveryCallback<org.springframework.messaging.Message<?>> recoveryCallback)
    Set a RecoveryCallback when using retry within the adapter.
    void
    setReplyChannel(org.springframework.messaging.MessageChannel replyChannel)
     
    void
    setReplyChannelName(String replyChannelName)
     
    void
    setReplyDeliveryPersistent(boolean replyDeliveryPersistent)
    Specify the delivery mode for JMS reply Messages.
    void
    setReplyPriority(int replyPriority)
    Specify the priority value for JMS reply Messages.
    void
    setReplyTimeout(long replyTimeout)
     
    void
    setReplyTimeToLive(long replyTimeToLive)
    Specify the time-to-live property for JMS reply Messages.
    void
    setReplyToExpression(org.springframework.expression.Expression replyToExpression)
    Set a SpEL expression to resolve a 'replyTo' destination from a request Message as a root evaluation object if Message.getJMSReplyTo() is null.
    void
    setRequestChannel(org.springframework.messaging.MessageChannel requestChannel)
     
    void
    setRequestChannelName(String requestChannelName)
     
    void
    setRequestReplyObservationConvention(org.springframework.integration.support.management.observation.MessageRequestReplyReceiverObservationConvention observationConvention)
     
    void
    setRequestTimeout(long requestTimeout)
     
    void
    setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)
    Set a RetryTemplate to use for retrying a message delivery within the adapter.
    void
    setShouldTrack(boolean shouldTrack)
     
    protected void
     
    protected void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.integration.support.context.NamedComponent

    getBeanName
  • Field Details

    • logger

      protected final org.springframework.core.log.LogAccessor logger
  • Constructor Details

    • ChannelPublishingJmsMessageListener

      public ChannelPublishingJmsMessageListener()
  • Method Details

    • setExpectReply

      public void setExpectReply(boolean expectReply)
      Specify whether a JMS reply Message is expected.
      Parameters:
      expectReply - true if a reply is expected.
    • setComponentName

      public void setComponentName(String componentName)
    • setRequestChannel

      public void setRequestChannel(org.springframework.messaging.MessageChannel requestChannel)
    • setRequestChannelName

      public void setRequestChannelName(String requestChannelName)
    • setReplyChannel

      public void setReplyChannel(org.springframework.messaging.MessageChannel replyChannel)
    • setReplyChannelName

      public void setReplyChannelName(String replyChannelName)
    • setErrorChannel

      public void setErrorChannel(org.springframework.messaging.MessageChannel errorChannel)
    • setErrorChannelName

      public void setErrorChannelName(String errorChannelName)
    • setRequestTimeout

      public void setRequestTimeout(long requestTimeout)
    • setReplyTimeout

      public void setReplyTimeout(long replyTimeout)
    • setErrorOnTimeout

      public void setErrorOnTimeout(boolean errorOnTimeout)
    • setShouldTrack

      public void setShouldTrack(boolean shouldTrack)
      Specified by:
      setShouldTrack in interface org.springframework.integration.support.management.TrackableComponent
    • getComponentName

      public String getComponentName()
      Specified by:
      getComponentName in interface org.springframework.integration.support.context.NamedComponent
    • getComponentType

      public String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
    • setDefaultReplyDestination

      public void setDefaultReplyDestination(jakarta.jms.Destination defaultReplyDestination)
      Set the default reply destination to send reply messages to. This will be applied in case of a request message that does not carry a "JMSReplyTo" field.
      Parameters:
      defaultReplyDestination - The default reply destination.
    • setDefaultReplyQueueName

      public void setDefaultReplyQueueName(String destinationName)
      Set the name of the default reply queue to send reply messages to. This will be applied in case of a request message that does not carry a "JMSReplyTo" field.

      Alternatively, specify a JMS Destination object as "defaultReplyDestination".

      Parameters:
      destinationName - The default reply destination name.
      See Also:
    • setDefaultReplyTopicName

      public void setDefaultReplyTopicName(String destinationName)
      Set the name of the default reply topic to send reply messages to. This will be applied in case of a request message that does not carry a "JMSReplyTo" field.

      Alternatively, specify a JMS Destination object as "defaultReplyDestination".

      Parameters:
      destinationName - The default reply topic name.
      See Also:
    • setReplyTimeToLive

      public void setReplyTimeToLive(long replyTimeToLive)
      Specify the time-to-live property for JMS reply Messages.
      Parameters:
      replyTimeToLive - The reply time to live.
      See Also:
      • MessageProducer.setTimeToLive(long)
    • setReplyPriority

      public void setReplyPriority(int replyPriority)
      Specify the priority value for JMS reply Messages.
      Parameters:
      replyPriority - The reply priority.
      See Also:
      • MessageProducer.setPriority(int)
    • setReplyDeliveryPersistent

      public void setReplyDeliveryPersistent(boolean replyDeliveryPersistent)
      Specify the delivery mode for JMS reply Messages.
      Parameters:
      replyDeliveryPersistent - true for a persistent reply message.
      See Also:
      • MessageProducer.setDeliveryMode(int)
    • setCorrelationKey

      public void setCorrelationKey(String correlationKey)
      Provide the name of a JMS property that should be copied from the request Message to the reply Message. If this value is NULL (the default) then the JMSMessageID from the request will be copied into the JMSCorrelationID of the reply unless there is already a value in the JMSCorrelationID property of the newly created reply Message in which case nothing will be copied. If the JMSCorrelationID of the request Message should be copied into the JMSCorrelationID of the reply Message instead, then this value should be set to "JMSCorrelationID". Any other value will be treated as a JMS String Property to be copied as-is from the request Message into the reply Message with the same property name.
      Parameters:
      correlationKey - The correlation key.
    • setExplicitQosEnabledForReplies

      public void setExplicitQosEnabledForReplies(boolean explicitQosEnabledForReplies)
      Specify whether explicit QoS should be enabled for replies (for timeToLive, priority, and deliveryMode settings).
      Parameters:
      explicitQosEnabledForReplies - true to enable explicit QoS.
    • setDestinationResolver

      public void setDestinationResolver(org.springframework.jms.support.destination.DestinationResolver destinationResolver)
      Set the DestinationResolver that should be used to resolve reply destination names for this listener.

      The default resolver is a DynamicDestinationResolver. Specify a JndiDestinationResolver for resolving destination names as JNDI locations.

      Parameters:
      destinationResolver - The destination resolver.
      See Also:
      • DynamicDestinationResolver
      • JndiDestinationResolver
    • setReplyToExpression

      public void setReplyToExpression(org.springframework.expression.Expression replyToExpression)
      Set a SpEL expression to resolve a 'replyTo' destination from a request Message as a root evaluation object if Message.getJMSReplyTo() is null.
      Parameters:
      replyToExpression - the SpEL expression for 'replyTo' destination.
      Since:
      6.1
    • setMessageConverter

      public void setMessageConverter(org.springframework.jms.support.converter.MessageConverter messageConverter)
      Provide a MessageConverter implementation to use when converting between JMS Messages and Spring Integration Messages. If none is provided, a SimpleMessageConverter will be used.
      Parameters:
      messageConverter - The message converter.
    • setHeaderMapper

      public void setHeaderMapper(JmsHeaderMapper headerMapper)
      Provide a JmsHeaderMapper implementation to use when converting between JMS Messages and Spring Integration Messages. If none is provided, a DefaultJmsHeaderMapper will be used.
      Parameters:
      headerMapper - The header mapper.
    • setExtractRequestPayload

      public void setExtractRequestPayload(boolean extractRequestPayload)
      Specify whether the JMS request Message's body should be extracted prior to converting into a Spring Integration Message. This value is set to true by default. To send the JMS Message itself as a Spring Integration Message payload, set this to false.
      Parameters:
      extractRequestPayload - true if the request payload should be extracted.
    • setExtractReplyPayload

      public void setExtractReplyPayload(boolean extractReplyPayload)
      Specify whether the Spring Integration reply Message's payload should be extracted prior to converting into a JMS Message. This value is set to true by default. To send the Spring Integration Message itself as the JMS Message's body, set this to false.
      Parameters:
      extractReplyPayload - true if the reply payload should be extracted.
    • setMetricsCaptor

      public void setMetricsCaptor(org.springframework.integration.support.management.metrics.MetricsCaptor captor)
    • setObservationRegistry

      public void setObservationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry)
    • setRequestReplyObservationConvention

      public void setRequestReplyObservationConvention(@Nullable org.springframework.integration.support.management.observation.MessageRequestReplyReceiverObservationConvention observationConvention)
    • setReceiverObservationConvention

      public void setReceiverObservationConvention(@Nullable org.springframework.integration.support.management.observation.MessageReceiverObservationConvention observationConvention)
    • setRetryTemplate

      public void setRetryTemplate(org.springframework.retry.support.RetryTemplate retryTemplate)
      Set a RetryTemplate to use for retrying a message delivery within the adapter. Unlike adding retry at the container level, this can be used with an ErrorMessageSendingRecoverer RecoveryCallback to publish to the error channel after retries are exhausted. You generally should not configure an error channel when using retry here, use a RecoveryCallback instead.
      Parameters:
      retryTemplate - the template.
      Since:
      6.3
      See Also:
    • setRecoveryCallback

      public void setRecoveryCallback(org.springframework.retry.RecoveryCallback<org.springframework.messaging.Message<?>> recoveryCallback)
      Set a RecoveryCallback when using retry within the adapter.
      Parameters:
      recoveryCallback - the callback.
      Since:
      6.3
      See Also:
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • onMessage

      public void onMessage(jakarta.jms.Message jmsMessage, jakarta.jms.Session session) throws jakarta.jms.JMSException
      Specified by:
      onMessage in interface org.springframework.jms.listener.SessionAwareMessageListener<jakarta.jms.Message>
      Throws:
      jakarta.jms.JMSException
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • start

      protected void start()
    • stop

      protected void stop()