Evandro Pomatti
Evandro Pomatti

Reputation: 15144

IBM MQ fail with reason '2058' with amqsgetc

When running the GET sample amqsget I can connect normally in the queue...

C:\Program Files\IBM\MQ\bin>amqsget QUEUE1
Sample AMQSGET0 start
no more messages
Sample AMQSGET0 end

However when using amqsgetc I get an error "MQCONNX ended with reason code 2058":

C:\Program Files\IBM\MQ\bin>amqsgetc QUEUE1
Sample AMQSGET0 start
MQCONNX ended with reason code 2058

Explicitly adding the queue manager at the end does not work as well.

This article from IBM summarizes the problem causes but it still not clear why one is working and not the other. This other article explains the sample programs.

Upvotes: 2

Views: 3147

Answers (2)

Rob Parker
Rob Parker

Reputation: 774

amqsget will connect to a queue manager on your local machine using shared memory pipes. This means as long as it is on the same machine as your queue manager it can find the queue manager and connect to it.

amqsgetc will connect to a queue manager over the network. Because, by default, it doesn't know where the queue manager is you will need to tell it how to connect to the queue manager. You can tell amqsgetc (or any client application) how to connect ot a queue manager in one of 3 ways:

  1. Programmatically. If you have a custom application you can program in the connection details to hard code them. This is not an option for amqsgetc.
  2. MQSERVER environment variable. If you set this environment variable then you amqsgetc will pick up the details it needs. The variable should be in the format: <Channel>/<Network Protocol, most likely TCP>/<address>(<port>) for example Channel1/TCP/localhost(1414). This page has more details about MQSERVER.
  3. A CCDT file. If you create a CCDT file then you amqsgetc can pick this up in order to find the connection details you need. More on CCDT files here

Upvotes: 3

ChrisL
ChrisL

Reputation: 129

The sample programs ending with 'c' are linked with the MQ client libraries, rather than the server libraries. As such they connect with a network connection (typically TCP) rather than shared memory.

The article you link to provides further information on the order of precedence used by the when working out how to reach a remote queue manager, but to summarise, it's likely that the client doesn't know how to contact the queue manager.

You will need to advise the client of the connection details to use to contact the queue manager, either with a CCDT, or using the MQSERVER environment variable.

Upvotes: 2

Related Questions