Any port in a storm? No.

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.

5 thoughts on “Any port in a storm? No.

  1. 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!

    Like

  2. 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.

    Like

  3. 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.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s