Class JmsListenerBase

All Implemented Interfaces:
HasPhysicalDestination, HasSender, IConfigurable, IConfigurationAware, IListener<jakarta.jms.Message>, INamedObject, IRedeliveringListener<jakarta.jms.Message>, IScopeProvider, IWithParameters, IXAEnabled, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
PullingJmsListener, PushingJmsListener

public abstract class JmsListenerBase extends JMSFacade implements HasSender, IWithParameters, IRedeliveringListener<jakarta.jms.Message>
Common baseclass for Pulling and Pushing JMS Listeners.
Since:
4.9
Author:
Gerrit van Brakel
  • Constructor Details

    • JmsListenerBase

      public JmsListenerBase()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      Description copied from interface: IListener
      configure() is called once at startup of the framework in the configure() method of the owner of this listener. Purpose of this method is to reduce creating connections to databases etc. in the IPullingListener.getRawMessage(Map) method. As much as possible class-instantiating should take place in the configure() or open() method, to improve performance.
      Specified by:
      configure in interface IConfigurable
      Specified by:
      configure in interface IListener<jakarta.jms.Message>
      Overrides:
      configure in class JMSFacade
      Throws:
      ConfigurationException
    • open

      public void open() throws ListenerException
      Description copied from class: JMSFacade
      Obtains a connection and a serviceQueue.
      Specified by:
      open in interface IListener<jakarta.jms.Message>
      Overrides:
      open in class JMSFacade
      Throws:
      ListenerException
    • close

      public void close()
      Description copied from class: JMSFacade
      Releases references to serviceQueue and connection.
      Specified by:
      close in interface IListener<jakarta.jms.Message>
      Overrides:
      close in class JMSFacade
    • extractMessageProperties

      public Map<String,Object> extractMessageProperties(jakarta.jms.Message rawMessage)
      Fill in thread-context with things needed by the JMSListener code. This includes a Session. The Session object can be passed in externally.
      Parameters:
      rawMessage - - Original message received, can not be null
      Returns:
      A Map with the properties of the JMS Message.
    • extractMessage

      public Message extractMessage(@Nonnull RawMessageWrapper<jakarta.jms.Message> rawMessage, @Nonnull Map<String,Object> context) throws ListenerException
      Extracts data from message obtained from IPullingListener.getRawMessage(Map). May also extract other parameters from the message and put those in the context.
      Specified by:
      extractMessage in interface IListener<jakarta.jms.Message>
      Parameters:
      rawMessage - The RawMessageWrapper from which to extract the Message.
      context - Context to populate. Either a PipeLineSession or a Map<String,Object> threadContext depending on caller.
      Returns:
      String input Message for adapter.
      Throws:
      ListenerException
    • prepareReply

      public Message prepareReply(Message rawReply, Map<String,Object> threadContext) throws ListenerException
      Throws:
      ListenerException
    • prepareReply

      public Message prepareReply(Message rawReply, Map<String,Object> threadContext, String soapHeader) throws ListenerException
      Throws:
      ListenerException
    • afterMessageProcessed

      public void afterMessageProcessed(PipeLineResult plr, RawMessageWrapper<jakarta.jms.Message> rawMessageWrapper, PipeLineSession session) throws ListenerException
      Description copied from interface: IListener
      Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.
      Specified by:
      afterMessageProcessed in interface IListener<jakarta.jms.Message>
      Throws:
      ListenerException
    • messageWillBeRedeliveredOnExitStateError

      public boolean messageWillBeRedeliveredOnExitStateError(PipeLineSession pipeLineSession)
      Specified by:
      messageWillBeRedeliveredOnExitStateError in interface IRedeliveringListener<jakarta.jms.Message>
    • sendReply

      protected void sendReply(PipeLineResult plr, jakarta.jms.Destination replyTo, String replyCid, long timeToLive, boolean ignoreInvalidDestinationException, PipeLineSession pipeLineSession, Map<String,Object> properties) throws ListenerException, jakarta.jms.JMSException, IOException, SenderException
      Throws:
      ListenerException
      jakarta.jms.JMSException
      IOException
      SenderException
    • setSender

      @Deprecated(forRemoval=true, since="7.9.0") public void setSender(ISender newSender)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getMessageProperties

      protected Map<String,Object> getMessageProperties(PipeLineSession session)
      Set additional message headers/properties on the JMS response, read after message has been processed!
      Parameters:
      session - which has been built during the pipeline
      Returns:
      a map with headers to set to the JMS response, or null if there was no session or no parameters.
    • addParameter

      public void addParameter(IParameter p)
      Specified by:
      addParameter in interface IWithParameters
    • getParameterList

      public ParameterList getParameterList()
      return the Parameters
      Specified by:
      getParameterList in interface IWithParameters
    • setForceMessageIdAsCorrelationId

      public void setForceMessageIdAsCorrelationId(Boolean force)
      By default, the JmsListener takes the Correlation-ID (if present) as the ID that has to be used as Correlation-ID of the reply. When set to true, the messageID is used as Correlation-ID of the reply.
      Default value
      false
    • setTimeout

      public void setTimeout(long newTimeout)
      Receive timeout in milliseconds as specified by the JMS API, see https://docs.oracle.com/javaee/7/api/javax/jms/MessageConsumer.html#receive-long-
      Default value
      1000
    • setUseReplyTo

      public void setUseReplyTo(boolean newUseReplyTo)
      Flag if reply-to queue from the request message should be used or not.
      Default value
      true
    • setReplyDestinationName

      public void setReplyDestinationName(String destinationName)
      Name of the JMS destination (queue or topic) to use for sending replies. If useReplyTo=true, the sender specified reply destination takes precedence over this one.
    • setReplyMessageType

      public void setReplyMessageType(String string)
      Value of the JMSType field of the reply message
      Default value
      not set by application
    • setReplyDeliveryMode

      public void setReplyDeliveryMode(JMSFacade.DeliveryMode replyDeliveryMode)
      Controls mode that reply messages are sent with
      Default value
      NON_PERSISTENT
    • setReplyPriority

      public void setReplyPriority(int i)
      Sets the priority that is used to deliver the reply message. Ranges from 0 to 9. Effectively the default priority is set by JMS to 4, -1 means not set and thus uses the JMS default
      Default value
      -1
    • setReplyMessageTimeToLive

      public void setReplyMessageTimeToLive(long l)
      Time in milliseconds after which the reply-message will expire
      Default value
      0
    • setSoap

      public void setSoap(boolean b)
      If true, messages sent are put in a SOAP envelope
      Default value
      false
    • setReplyEncodingStyleURI

      public void setReplyEncodingStyleURI(String string)
    • setReplyNamespaceURI

      public void setReplyNamespaceURI(String string)
    • setReplySoapAction

      public void setReplySoapAction(String string)
    • setSoapHeaderSessionKey

      public void setSoapHeaderSessionKey(String string)
      sessionKey to store the SOAP header of the incoming message
      Default value
      soapHeader
    • getTimeout

      public long getTimeout()
    • isUseReplyTo

      public boolean isUseReplyTo()
    • getReplyDestinationName

      public String getReplyDestinationName()
    • getReplyMessageType

      public String getReplyMessageType()
    • getReplyMessageTimeToLive

      public long getReplyMessageTimeToLive()
    • getReplyPriority

      public int getReplyPriority()
    • getReplyDeliveryMode

      public JMSFacade.DeliveryMode getReplyDeliveryMode()
    • getSender

      public ISender getSender()
      Specified by:
      getSender in interface HasSender
    • getForceMessageIdAsCorrelationId

      public Boolean getForceMessageIdAsCorrelationId()
    • isSoap

      public boolean isSoap()
    • getReplyEncodingStyleURI

      public String getReplyEncodingStyleURI()
    • getReplyNamespaceURI

      public String getReplyNamespaceURI()
    • getReplySoapAction

      public String getReplySoapAction()
    • getSoapHeaderSessionKey

      public String getSoapHeaderSessionKey()