Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • 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.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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic