• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to set the userId in the MQ header

Anup Bansal
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am using the base MQ java to send a message vi MQ. I want a specific user id to be sent in the MQ header of the message. However the message arriving on the MQ contains the my WAS user id with which I start my application.
Following is a snippet of my code.
Can anyone please tell me what might be the problem:
public void sendResponse(String strOutputMessage){

MQMessage outputMessage = null;
try {

//MQEnvironment.userID = "u@gzsj1";

// Create a connection to the queue manager
qMgr = new MQQueueManager(qManager);

// Set up the options on the queue we wish to open...
// Note. All WebSphere MQ Options are prefixed with MQC in Java.
int openOptions = MQC.MQOO_OUTPUT ;

// Now specify the queue that we wish to open,
// and the open options...
MQQueue outputQueue = qMgr.accessQueue("GZ250I01", openOptions);
short LL = (short)(strOutputMessage.length() + 4 + 9);
short ZZ = 0;
outputMessage.writeString(" "); // 1 byte reserved

// specify the message options...
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_NONE;

// put the message on the queue
outputQueue.put(outputMessage, pmo);

// Disconnect from the queue manager

// If an error has occurred in the above, try to identify what went wrong
// Was it a WebSphere MQ error?
catch (MQException ex)
System.out.println("A WebSphere MQ error occurred : Completion code " +
ex.completionCode + " Reason code " + ex.reasonCode);
} catch (IOException e) {
// TODO Auto-generated catch block

Thanks in advance,
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic