Class JmsCommons

java.lang.Object
org.mule.jms.commons.internal.common.JmsCommons

public final class JmsCommons extends Object
Utility class to reuse logic for JMS Extension
Since:
1.0
  • Field Details

  • Constructor Details

    • JmsCommons

      public JmsCommons()
  • Method Details

    • resolveMessageContentType

      public static String resolveMessageContentType(jakarta.jms.Message message, String defaultType)
    • resolveMessageEncoding

      public static String resolveMessageEncoding(jakarta.jms.Message message, String defaultType)
    • resolveOverride

      public static <T> T resolveOverride(T configValue, T operationValue)
    • evaluateMessageAck

      public static void evaluateMessageAck(InternalAckMode ackMode, JmsSession session, jakarta.jms.Message receivedMessage, JmsSessionManager messageSessionManager, JmsListenerLock jmsLock, JmsMessageAckedMonitor jmsMessageAckedMonitor) throws JmsAckException
      Throws:
      JmsAckException
    • createJmsSession

      public static JmsSession createJmsSession(JmsConnection jmsConnection, InternalAckMode ackMode, boolean isTopic, JmsSessionManager jmsSessionManager, org.mule.runtime.extension.api.tx.OperationTransactionalAction transactionalAction) throws jakarta.jms.JMSException
      Utility method to create new JmsSession from a given JmsConnection
      Parameters:
      jmsConnection - the connection from where create a new JmsSession
      ackMode - the InternalAckMode to use
      isTopic - Indicates if the destination is whether a topic or a queue
      jmsSessionManager - JmsSessionManager to retrieve information about the current transaction status
      Returns:
      a new JmsSession from the given JmsConnection
      Throws:
      jakarta.jms.JMSException - If an error happens creating a new JmsSession
    • toInternalAckMode

      public static InternalAckMode toInternalAckMode(JmsAckMode jmsAckMode)
    • releaseResources

      public static void releaseResources(JmsSession session, boolean isPartOfCurrentTx, AutoCloseable... closeables)
      Releases all the resources that are required to close. The session only will be closed if this one doesn't belong to the current transaction or it doesn't have an a Client ACK.
      Parameters:
      session - Session to close
      closeables - All the things that can be closed
    • isManualAck

      public static boolean isManualAck(JmsSession session)
      Verifies if the given session ACK Mode is AckMode.MANUAL
    • isPartOfCurrentTx

      public static boolean isPartOfCurrentTx(JmsSession session, JmsConnection jmsConnection, JmsSessionManager sessionManager)
      Verifies if the given session is part of the current TX.
    • closeQuietly

      public static void closeQuietly(AutoCloseable closable)
      Closes this Connection resource without throwing an exception (an error message is logged instead)
      Parameters:
      closable - the resource to close
    • stopQuietly

      public static void stopQuietly(Object stoppable)
      Stops this Stoppable resource without throwing an exception (an error message is logged instead)
      Parameters:
      stoppable - the resource to stop
    • getDestinationType

      public static String getDestinationType(ConsumerType consumerType)
    • getDestinationType

      public static String getDestinationType(DestinationTypeDescriptor consumerType)
    • getDestinationType

      public static String getDestinationType(jakarta.jms.Destination consumerType)