Class DefaultDispatchFn
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionDefaultDispatchFn(jakarta.jms.ConnectionFactory connectionFactory, ToJson toJson, List<DispatchListener> dispatchListeners) Creates a DefaultDispatchFn with the given ConnectionFactory.DefaultDispatchFn(jakarta.jms.JMSContext jmsContex, ToJson toJson) DefaultDispatchFn(jakarta.jms.JMSContext jmsContex, ToJson toJson, List<DispatchListener> dispatchListeners) Creates a DefaultDispatchFn with the given JMSContext. -
Method Summary
-
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
-
-
Method Details
-
send
- Specified by:
sendin interfaceJmsDispatchFn- Returns:
- The message that has been sent successfully
-