I’m connecting to an IBM MQSeries server using the Perl MQClient::MQSeries module on a MQSeries 9 client and server installation on a CentOS 7 system.
I connect to the queue manager from two threads using
sub connectToQueuemanager
{
my ($host, $queuemanager, $channel) = @_;
my $coption = {
'ChannelName' => $channel,
'TransportType' => 'TCP',
'ConnectionName' => $host
};
my $compcode = 0;
my $compres = 0;
my $hconn = MQCONNX ($queuemanager, {'ClientConn' => $coption}, $compcode, $compres);
}
This works fine in the first thread, but not in the second – there I get code 2002 (“Application already connected.”) as result. This problem did not appear with MQSeries version 6.
As of https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.5.0/com.ibm.mq.dev.doc/q025940_.htm this could be solved by setting MQCNO_HANDLE_SHARE_NO_BLOCK in the connection options. The Perl module MQSeries.pm lists this as one of the known constants, but I found no way to set this in the MQCONNX connection call.
How can I set this option in the MQCONNX call?
2
Answers
Based on the other language bindings it would be
I don’t know Perl and I haven’t used the Perl MQSeries interface, but reading the help here, it says the following:-
This is unfortunately not very helpful, since there is no such thing as an MQCO structure. I think it might mean MQCNO. Then later where it says ClientConn provides access to the MQCNO structure, I think it might mean the MQCD structure which is hung off the MQCNO structure (since that is certainly what the contents of ClientConn looks like).
Your question distils down to "where do I put MQCNO_* option flags?" and I don’t think the answer is to put them into the MQCD ClientConn structure as that is not where they are found in the native MQ API.
Given that I don’t know how to program in Perl, and just using my MQ expertise on this, here is what I think the code should look like. I apologise in advance if it doesn’t compile, but I hope this will lead you to a solution. Please feel free to edit my answer if it’s close, but not quite right due to my Perl inadequacies.