Package io.mats3.impl.jms
Class JmsMatsMessageBrokerSpecifics
java.lang.Object
io.mats3.impl.jms.JmsMatsMessageBrokerSpecifics
Some small specifics for the underlying JMS Implementation. Currently handled: ActiveMQ.
ActiveMQ
- Check for Connection liveliness:
ActiveMQConnection.is[Closed|Closing|TransportFailed]
. - Honor the
MatsEndpoint.MatsRefuseMessageException
(i.e. insta-DLQing), by setting redelivery attempts to 0 on the MessageConsumer when rolling back Session:ActiveMQSession.setRedeliveryPolicy(zeroAttemptsPolicy)
.
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
init()
static void
instaDlqWithRollbackLambda
(javax.jms.MessageConsumer jmsMessageConsumer, io.mats3.impl.jms.JmsMatsMessageBrokerSpecifics.JmsMatsJmsExceptionThrowingRunnable rollbackLambda) If the MessageConsumer is an ActiveMQMessageConsumer, then it should set it into "0 redeliveries" mode, and then run the provided lambda to rollback the current message, and then re-set the deliveries.static void
isConnectionLive
(javax.jms.Connection jmsConnection) For an ActiveMQ JMS Connection, this method throwsJmsMatsException.JmsMatsJmsException
if any of the following methods returntrue
: jmsConnection.isClosing() jmsConnection.isClosed() jmsConnection.isTransportFailed()
-
Method Details
-
init
public static void init() -
isConnectionLive
public static void isConnectionLive(javax.jms.Connection jmsConnection) throws JmsMatsException.JmsMatsJmsException For an ActiveMQ JMS Connection, this method throwsJmsMatsException.JmsMatsJmsException
if any of the following methods returntrue
:- jmsConnection.isClosing()
- jmsConnection.isClosed()
- jmsConnection.isTransportFailed()
- Parameters:
jmsConnection
- the JMS Connection to check.- Throws:
JmsMatsException.JmsMatsJmsException
- if it seems like this Connection is dead.
-
instaDlqWithRollbackLambda
public static void instaDlqWithRollbackLambda(javax.jms.MessageConsumer jmsMessageConsumer, io.mats3.impl.jms.JmsMatsMessageBrokerSpecifics.JmsMatsJmsExceptionThrowingRunnable rollbackLambda) throws JmsMatsException.JmsMatsJmsException If the MessageConsumer is an ActiveMQMessageConsumer, then it should set it into "0 redeliveries" mode, and then run the provided lambda to rollback the current message, and then re-set the deliveries. If not an ActiveMQMessageConsumer, just run the provided lambda directly to rollback the current message.- Parameters:
jmsMessageConsumer
- consumer to set to "0 redeliveries" (will be reset before return)rollbackLambda
- the lambda that should be run to perform the rollback of the current message.- Throws:
JmsMatsException.JmsMatsJmsException
-