• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Unable to set the userId in the MQ header

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic