Class PushingJmsListener

All Implemented Interfaces:
FrankElement, HasApplicationContext, HasName, HasPhysicalDestination, HasSender, IConfigurable, IKnowsDeliveryCount<jakarta.jms.Message>, IListener<jakarta.jms.Message>, IPortConnectedListener<jakarta.jms.Message>, IPushingListener<jakarta.jms.Message>, IRedeliveringListener<jakarta.jms.Message>, IScopeProvider, IThreadCountControllable, IWithParameters, IXAEnabled, NameAware, ReceiverAware<jakarta.jms.Message>, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle
Direct Known Subclasses:
JmsListener

public class PushingJmsListener extends AbstractJmsListener implements IPortConnectedListener<jakarta.jms.Message>, IThreadCountControllable, IKnowsDeliveryCount<jakarta.jms.Message>
JMSListener re-implemented as a pushing listener rather than a pulling listener. The JMS messages have to come in from an external source: an MDB or a Spring message container. This version of the JmsListener supports distributed transactions using the XA-protocol. No special action is required to have the listener join the transaction.

Setting listener.acknowledgeMode to "auto" means that messages are allways acknowledged (removed from the queue, regardless of what the status of the Adapter is. "client" means that the message will only be removed from the queue when the state of the Adapter equals the success state. The "dups" mode instructs the session to lazily acknowledge the delivery of the messages. This is likely to result in the delivery of duplicate messages if JMS fails. It should be used by consumers who are tolerant in processing duplicate messages. In cases where the client is tolerant of duplicate messages, some enhancement in performance can be achieved using this mode, since a session has lower overhead in trying to prevent duplicate messages.

The setting for listener.acknowledgeMode will only be processed if the setting for listener.transacted.

If useReplyTo is set and a replyTo-destination is specified in the message, the JmsListener sends the result of the processing in the pipeline to this destination. Otherwise the result is sent using the (optionally) specified Sender, that in turn sends the message to whatever it is configured to.

Notice: the JmsListener is ONLY capable of processing TextMessages and BytesMessage

Since:
4.8
Author:
Tim van der Leeuw
  • Constructor Details

    • PushingJmsListener

      public PushingJmsListener()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      Description copied from interface: IConfigurable
      Configure this component.

      configure() is called once at startup of the framework in the configure method of the owner of this IConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in the configure(), to improve performance.

      In the case of a container, this will propagate the configure signal to all components that apply.

      Specified by:
      configure in interface IConfigurable
      Overrides:
      configure in class AbstractJmsListener
      Throws:
      ConfigurationException - in case it was not able to configure the component.
    • start

      public void start()
      Description copied from class: JMSFacade
      Obtains a connection and a serviceQueue.
      Specified by:
      start in interface IListener<jakarta.jms.Message>
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Overrides:
      start in class AbstractJmsListener
    • stop

      public void stop()
      Description copied from class: JMSFacade
      Releases references to serviceQueue and connection.
      Specified by:
      stop in interface IListener<jakarta.jms.Message>
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Overrides:
      stop in class AbstractJmsListener
    • wrapRawMessage

      public RawMessageWrapper<jakarta.jms.Message> wrapRawMessage(jakarta.jms.Message rawMessage, PipeLineSession session) throws ListenerException
      Description copied from interface: IPushingListener
      Wrap a raw message in a MessageWrapper. Populate PipeLineSession with properties from the message.
      Specified by:
      wrapRawMessage in interface IPushingListener<jakarta.jms.Message>
      Parameters:
      rawMessage - The raw message data, unwrapped
      session - PipeLineSession to populate with properties from the message.
      Returns:
      Wrapped raw message
      Throws:
      ListenerException - If any exception occurs during wrapping, a ListenerException is thrown.
    • isThreadCountReadable

      public boolean isThreadCountReadable()
      Specified by:
      isThreadCountReadable in interface IThreadCountControllable
    • isThreadCountControllable

      public boolean isThreadCountControllable()
      Specified by:
      isThreadCountControllable in interface IThreadCountControllable
    • getCurrentThreadCount

      public int getCurrentThreadCount()
      Specified by:
      getCurrentThreadCount in interface IThreadCountControllable
    • getMaxThreadCount

      public int getMaxThreadCount()
      Specified by:
      getMaxThreadCount in interface IThreadCountControllable
    • increaseThreadCount

      public void increaseThreadCount()
      Specified by:
      increaseThreadCount in interface IThreadCountControllable
    • decreaseThreadCount

      public void decreaseThreadCount()
      Specified by:
      decreaseThreadCount in interface IThreadCountControllable
    • getDeliveryCount

      public int getDeliveryCount(RawMessageWrapper<jakarta.jms.Message> rawMessage)
      Specified by:
      getDeliveryCount in interface IKnowsDeliveryCount<jakarta.jms.Message>
    • setDestinationName

      @Mandatory public void setDestinationName(String destinationName)
      Description copied from class: JMSFacade
      Name of the JMS destination (queue or topic) to use
      Overrides:
      setDestinationName in class JMSFacade
    • setCacheMode

      public void setCacheMode(IListenerConnector.CacheMode cacheMode)
    • setPollGuardInterval

      public void setPollGuardInterval(long pollGuardInterval)
      Interval in milliseconds for the poll guard to check whether a successful poll was done by the receive (https://docs.oracle.com/javaee/7/api/javax/jms/messageconsumer.html#receive-long-) since last check. If polling has stopped this will be logged and the listener will be stopped and started in an attempt to workaround problems with polling. Polling might stop due to bugs in the JMS driver/implementation which should be fixed by the supplier. As the poll time includes reading and processing of the message no successful poll might be registered since the last check when message processing takes a long time, hence while messages are being processed the check on last successful poll will be skipped. Set to -1 to disable.
      Default value
      ten times the specified timeout
    • getCacheMode

      public IListenerConnector.CacheMode getCacheMode()
    • getPollGuardInterval

      public long getPollGuardInterval()
    • getJmsConnector

      public IListenerConnector<jakarta.jms.Message> getJmsConnector()
    • setJmsConnector

      public void setJmsConnector(IListenerConnector<jakarta.jms.Message> jmsConnector)
    • getHandler

      public IMessageHandler<jakarta.jms.Message> getHandler()
      Specified by:
      getHandler in interface IPortConnectedListener<jakarta.jms.Message>
    • setHandler

      public void setHandler(IMessageHandler<jakarta.jms.Message> handler)
      Description copied from interface: IPushingListener
      Set the handler that will do the processing of the message. Each of the received messages must be pushed through handler.processMessage()
      Specified by:
      setHandler in interface IPushingListener<jakarta.jms.Message>
    • getReceiver

      public Receiver<jakarta.jms.Message> getReceiver()
      Specified by:
      getReceiver in interface ReceiverAware<jakarta.jms.Message>
    • setReceiver

      public void setReceiver(Receiver<jakarta.jms.Message> receiver)
      Specified by:
      setReceiver in interface ReceiverAware<jakarta.jms.Message>
    • getExceptionListener

      public IbisExceptionListener getExceptionListener()
      Specified by:
      getExceptionListener in interface IPortConnectedListener<jakarta.jms.Message>
    • setExceptionListener

      public void setExceptionListener(IbisExceptionListener exceptionListener)
      Description copied from interface: IPushingListener
      Set a (single) listener that will be notified of any exceptions. The listener should use this listener to notify the receiver of any exception that occurs outside the processing of a message.
      Specified by:
      setExceptionListener in interface IPushingListener<jakarta.jms.Message>