Java – IBM WebSphere MQ 2042 error

ibm-mqjava

I have the following code:

int openOptions = MQC.MQOO_INQUIRE 
    + MQC.MQOO_FAIL_IF_QUIESCING
    + MQC.MQOO_INPUT_SHARED;

Which when executed, I am getting an error:

com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2042
MQJE001: Completion Code 2, Reason 2042

This happens while connecting my Java program with WebSphere MQ. Please note that the queue property is set as input shared. All help appreciated.

Best Answer

Although the queue may be set to DEFSOPT(SHARED), this is only a default. It does not prevent a program from opening it with exclusive use. In particular, transmission queues for non-cluster channels, the command queue and other queues used by MQ system components are opened with exclusive use, regardless of the queue's default setting. Similarly, monitoring programs often open the event queues for exclusive use to ensure that other programs do not compete for messages and result in missed critical events.

Is it one of the event or XMit queues? If so, you may not be able to remove the error without stopping the channel or monitoring agent. If it is a user-defined queue, use the DISPLAY QSTATUS command to see which process has it open for exclusive input, then disconnect that process.

Here is an example:

C:\Users\T.Rob>runmqsc QM75
5724-H72 (C) Copyright IBM Corp. 1994, 2011.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager QM75.


dis qs(system.admin.command.queue) all
     1 : dis qs(system.admin.command.queue) type(handle) all
AMQ8450: Display queue status details.
   QUEUE(SYSTEM.ADMIN.COMMAND.QUEUE)       TYPE(HANDLE)
   APPLDESC(WebSphere MQ Command Server)
   APPLTAG(here MQ 7.5\bin\amqpcsea.exe)
   APPLTYPE(SYSTEM)                        BROWSE(NO)
   CHANNEL( )                              CONNAME( )
   ASTATE(NONE)                            HSTATE(ACTIVE)
   INPUT(EXCL)                             INQUIRE(YES)
   OUTPUT(NO)                              PID(5220)
   QMURID(0.0)                             SET(NO)
   TID(1)
   URID(XA_FORMATID[] XA_GTRID[] XA_BQUAL[])
   URTYPE(QMGR)

The output of the command will repeat for each process attached to the queue. It shows the executable name (in this case amqpcsea which is the command server), the type of open, the process ID and the thread ID. Note that here it shows INPUT(EXCL) indicating that nothing else can open the command queue for browsing or getting of messages.

Related Topic