1

I configured the IBM MQ resource adapter 9.2.5.0 in Wildfly 20.0.0 as follows:

                <resource-adapter id="wmq.jmsra.rar">
                    <archive>
                        wmq.jmsra.rar
                    </archive>
                    <transaction-support>XATransaction</transaction-support>
                    <connection-definitions>
                        <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="jms/IBMMQ_CONNECTIONFACTORY" pool-name="ibmmq-connection-definition">
                            <config-property name="hostName">${env.HOSTNAME}</config-property>
                            <config-property name="port">${env.PORT}</config-property>
                            <config-property name="channel">${env.CHANNEL}</config-property>
                            <config-property name="transportType">CLIENT</config-property>
                            <config-property name="queueManager">${env.QUEUE_MANAGER}</config-property>
                        </connection-definition>
                    </connection-definitions>
                </resource-adapter>

When using this connection factory to create an MQ connection, I get the following error:

MQJCA1011: Failed to allocate a JMS connection
...
Caused by: javax.resource.ResourceException: IJ000455: Wrong ManagedConnectionFactory sent to allocateConnection (Pool=com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl@f85b573c, MCF=com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl@f85b573c)
    at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:784) ~[?:?]
    at com.ibm.mq.connector.outbound.ConnectionFactoryImpl.createManagedJMSConnection(ConnectionFactoryImpl.java:309)
Felix Siegrist
  • 275
  • 3
  • 8

2 Answers2

2

APAR IT37469 was the starting point here. It addressed some inconsistencies with data types returned by getters for Resource Adapter properties - forcing them to return object types (as required by the Java EE specification) rather than primitives (which many, but not all Application Servers tolerated).

Unfortunately, the fix was incompletely applied to the CD release - so 9.2.5 has the issue reported and as explained very well by Felix Siegrist.

The fix has been corrected for MQ 9.3.0 - see APAR IT40764

Mark Bluemel
  • 146
  • 1
1

In AbstractConnectionManager.allocateConnection() two ManagedConnectionFactoryImpl instances (Pool and MCF) are compared using equals(). Even though both instances are in fact the same (hash code f85b573c, so a == comparison would return true), equals() returns false i.e. the equals() implementation of com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl violates the contract for java.lang.Object.equals(). It does so, because it compares Integer values using == instead of Objects.equals(..., ...). The according properties are of type int but the used getters return Integer. When auto-boxing the int values, Integer.valueOf() is used internally. This returns new instances with each call for values out of the range [-128...127].

To work around the problem, I had to fall back to version 9.2.4.0 of the IBM MQ resource adapter.

Felix Siegrist
  • 275
  • 3
  • 8
  • Are you saying that this is a defect in V9.2.5 of the IBM MQ resource adapter? Have you reported it to IBM? – Morag Hughson Jun 16 '22 at 08:59
  • Yes, it is a bug in V9.2.5 of the IBM MQ resource adapter. I tried to report it to IBM but did not find a place, where I can do this without having a support contract for IBM MQ. So I posted it here to at least help other developers having the same issue. – Felix Siegrist Jun 16 '22 at 12:52
  • See my answer below. – Mark Bluemel Jun 17 '22 at 13:49