This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Unable to set the userId in the MQ header Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Unable to set the userId in the MQ header" Watch "Unable to set the userId in the MQ header" New topic

Unable to set the userId in the MQ header

Anup Bansal
Ranch Hand

Joined: Sep 12, 2006
Posts: 69
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,
I agree. Here's the link:
subject: Unable to set the userId in the MQ header
It's not a secret anymore!