aspose file tools*
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
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
Author

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.enableTracing(4);
//MQEnvironment.userID = "u@gzsj1";

System.out.println(MQEnvironment.properties.get(MQC.USER_ID_PROPERTY).toString());
// 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.writeShort(LL);
outputMessage.writeShort(ZZ);
outputMessage.writeString("GZ250T01");
outputMessage.writeString(" "); // 1 byte reserved
outputMessage.writeString(strOutputMessage);

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

System.out.println(outputMessage.toString());
// put the message on the queue
outputQueue.put(outputMessage, pmo);

outputQueue.close();
// Disconnect from the queue manager

qMgr.disconnect();
}
// 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
e.printStackTrace();
}

Thanks in advance,
Anup
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to set the userId in the MQ header