Class ConnectionManager

    • Constructor Detail

      • ConnectionManager

        public ConnectionManager​(jakarta.jms.XAConnectionFactory xaConnectionFactory,
                                 String user,
                                 String pass)
    • Method Detail

      • connectAndAccept

        public void connectAndAccept​(XAResourceConsumer consumer)
                              throws XAException
        Invoke XAResourceConsumer accept method before making sure that JMS connection is available. Current connection is used if one is available. If connection is not available, new connection is created before the accept call and closed after it.
        Parameters:
        consumer - XAResourceConsumer to be executed.
        Throws:
        XAException - if JMS connection cannot be created.
      • connectAndApply

        public <T> T connectAndApply​(XAResourceFunction<T> function)
                              throws XAException
        Invoke XAResourceFunction apply method before making sure that JMS connection is available. Current connection is used if one is available. If connection is not available, new connection is created before the apply call and closed after it.
        Type Parameters:
        T - Return type of the XAResourceFunction.
        Parameters:
        function - XAResourceFunction to be executed.
        Returns:
        The result of XAResourceFunction.
        Throws:
        XAException - if JMS connection cannot be created.
      • connect

        public void connect()
                     throws XAException
        Create JMS connection.
        Throws:
        XAException - if JMS connection cannot be created.
      • disconnect

        public void disconnect()
        Close current JMS connection.
      • isConnected

        public boolean isConnected()
        Check if JMS connection is active.
        Returns:
        true if JMS connection is active.