Class DefaultDispatchFn

java.lang.Object
me.ehp246.aufjms.api.dispatch.DefaultDispatchFn
All Implemented Interfaces:
JmsDispatchFn

public final class DefaultDispatchFn extends Object implements JmsDispatchFn
Light-weight class that implements JmsDispatchFn.

A DefaultDispatchFn can be created on either a ConnectionFactory or a JMSContext.

ConnectionFactory-backed object is thread-safe while JMSContext-based is not.

Author:
Lei Yang
  • Constructor Details

    • DefaultDispatchFn

      public DefaultDispatchFn(jakarta.jms.ConnectionFactory connectionFactory, ToJson toJson, List<DispatchListener> dispatchListeners)
      Creates a DefaultDispatchFn with the given ConnectionFactory.

      Unlike JMSContext-backed DefaultDispatchFn, the DefaultDispatchFn backed-by a ConnectionFactory creates and closes JMSContext for each invocation on JmsDispatchFn.send(JmsDispatch). I.e., it is thread-safe.

    • DefaultDispatchFn

      public DefaultDispatchFn(jakarta.jms.JMSContext jmsContex, ToJson toJson, List<DispatchListener> dispatchListeners)
      Creates a DefaultDispatchFn with the given JMSContext.

      Closing of the context is up to the caller. Once the context is closed, the DefaultDispatchFn is no longer functional and should be discarded since the reference to the context can not be changed after construction.

      JMSContext is not thread-safe. DefaultDispatchFn created on a context is not thread-safe either but it offers much better performance when sending messages in batch.

    • DefaultDispatchFn

      public DefaultDispatchFn(jakarta.jms.JMSContext jmsContex, ToJson toJson)
  • Method Details