Home » Java » java – MQ reconnect does not work with Wildfly. How to configure it correctly?-Exceptionshub

java – MQ reconnect does not work with Wildfly. How to configure it correctly?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

MQ reconnect does not work. Can you suggest ways to fix it?

I use Wildfly 12.0.0.Final

Driver is wmq.jmsra-9.1.2.0.rar

Tried to use this ways to configure reconnect

First

<subsystem xmlns="urn:jboss:domain:resource-adapters:5.0">
            <resource-adapters>
                <resource-adapter id="wmq.jmsra.rar" statistics-enabled="false">
                    <archive>
                        wmq.jmsra-9.1.2.0.rar
                    </archive>
                    <transaction-support>NoTransaction</transaction-support>
                    <config-property name="startupRetryInterval">
                        300
                    </config-property>
                    <config-property name="reconnectionRetryCount">
                        9000
                    </config-property>
                    <config-property name="startupRetryCount">
                        9000
                    </config-property>
                    <config-property name="reconnectionRetryInterval">
                        300
                    </config-property>
                </resource-adapter>
            </resource-adapters>
        </subsystem>

Second (two last properties)

    private JMSContext createJmsContext() throws JMSException {
        JmsConnectionFactory cf;
        JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
        cf = ff.createConnectionFactory();
        cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, props.getProperty(Q_HOST));
        cf.setIntProperty(WMQConstants.WMQ_PORT, Integer.valueOf(props.getProperty(Q_PORT)));
        cf.setStringProperty(WMQConstants.WMQ_CHANNEL, props.getProperty(Q_CHANNEL));
        cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
        cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, props.getProperty(Q_MANAGER));
        cf.setStringProperty(WMQConstants.WMQ_APPLICATIONNAME, "JmsPutGet (JMS)");
        cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
        cf.setIntProperty(WMQConstants.WMQ_CLIENT_RECONNECT_OPTIONS, WMQConstants.WMQ_CLIENT_RECONNECT_Q_MGR);
        cf.setIntProperty(WMQConstants.WMQ_CLIENT_RECONNECT_TIMEOUT, 60000);
        return cf.createContext();
    }
How to&Answers:

The IBM MQ classes for JMS resource adapter does not support support Automatic JMS client reconnection.


See IBM MQ v9.1 Knowledge Center page Developing applications>Developing JMS and Java applications>Using IBM MQ classes for JMS>Writing IBM MQ classes for JMS applications>Accessing IBM MQ features from an IBM MQ classes for JMS application:

The use of this implementation of automatic client reconnection is not supported within Java™ Platform, Enterprise Edition application servers. See Using automatic client reconnection in Java EE environments for an alternative implementation.


As stated above see IBM MQ v9.1 Knowledge Center page Developing applications>Developing JMS and Java applications>Using IBM MQ classes for JMS>Writing IBM MQ classes for JMS applications>Accessing IBM MQ features from an IBM MQ classes for JMS application>Automatic JMS client reconnection>Using automatic client reconnection in Java SE and Java EE environments:

Note


Automatic client reconnection with activation specifications using the functionality provided by IBM MQ classes for JMS is not supported. The IBM MQ resource adapter provides its own mechanism for reconnecting activation specifications if the queue manager that the activation specification was connecting to becomes unavailable.