Ive just spent a day resolving a problem with specifying a port value trying to connect to MQ.
I had
public long port = 1414;
String channel = “MYCHANNEL”;
String hostname = “127.0.0.1”;
Hashtable<String, Object> h = new Hashtable<String, Object>();
h.put(MQConstants.PORT_PROPERTY, dd.port);h.put(MQConstants.CHANNEL_PROPERTY, channel);
h.put(MQConstants.TRANSPORT_PROPERTY, MQConstants.TRANSPORT_MQSERIES_CLIENT);
h.put(MQConstants.HOST_NAME_PROPERTY, hostname);
queueManager = new MQQueueManager(“QMA”,h);
(did you spot the problem?)
This failed with
MQConnection to QMA com.ibm.mq.MQException: MQJE001: Completion Code ‘2’, Reason ‘2538’.
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9204: Connection to host ‘127.0.0.1(0)’ rejected.
This is saying it tried to connect with port 0!
I tried
String port = “1414”;, that failed the same way.
If I used
MQEnvironment.port=”1414″; it worked.
This was tough to resolve, as there is no documentation to help me.
Someone suggested public int port = 1414; and it worked! What a way to spend a nice autumn day.
As for documentation, it says here (https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.1.0/com.ibm.mq.javadoc.doc/WMQJavaClasses/com/ibm/mq/constants/CMQC.html#PORT_PROPERTY) that it must be an integer.
LikeLike
I could not find information based on MQConstants.PORT_PROPERTY, or MQEnvironment.port=port.
In the document you linked to, it says “static final java.lang.String PORT_PROPERTY IBM MQ Java environment key for defining the port number. The corresponding value must be an Integer” So an integer interpretation of a string. So the type is String!
LikeLike
Interesting post. I believe what is happening there is the IBM MQ Java code is getting an int variable (signed 4 byte integer) mapped onto the 4 highest bytes of the long port variable (signed 8 byte integer), due to how Hashtables put/get the inputs with reference types. It would be interesting if you went back to the long port and set the port to 6,073,083,756,544. 6,073,083,756,544 = 0x58600000000. The 4 high order bytes would be 0x00000586 = 1414. You should see the port then be 1414.
LikeLike
Interesting post. I believe what is happening there is the IBM MQ Java code is getting an int variable (signed 4 byte integer) mapped onto the 4 highest bytes of the long port variable (signed 8 byte integer), due to how Hashtables put/get the inputs with reference types. It would be interesting if you went back to the long port and set the port to 6,073,083,756,544. 6,073,083,756,544 = 0x58600000000. The 4 high order bytes would be 0x00000586 = 1414. You should see the port then be 1414.
LikeLike