Author |
Message
|
k_usa |
Posted: Thu Oct 12, 2006 11:12 am Post subject: Connecting to a local Queue from Java |
|
|
Apprentice
Joined: 14 Aug 2006 Posts: 42 Location: NewJersey
|
Hi,
I am trying to set the 'User Identifier' and the 'Put Application Name' for a mq message from my Java code.
But somehow it is overriding these values with mqm (for UserId).
MQEnvironment.hostname = hostName ;
MQEnvironment.channel = channel ;
MQEnvironment.port = Integer.valueOf(port).intValue();
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES);
MQQueueManager qMgr = new MQQueueManager(qManager) ;
int openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING ;
MQQueue myQueue =qMgr.accessQueue(queue, openOptions, null, null, null);
MQMessage myMessage = new MQMessage();
myMessage.messageId = null;
myMessage.correlationId = null;
myMessage.userId = "cwadmin";
myMessage.putApplicationName = "WICS";
myMessage.writeString("hello");
myQueue.put(myMessage);
But the userId and ApplicationName set by me getting overwritten by mqm and 'mq series client for Java'.
Can anybody help me please.
Thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Oct 12, 2006 11:15 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
k_usa |
Posted: Thu Oct 12, 2006 11:27 am Post subject: |
|
|
Apprentice
Joined: 14 Aug 2006 Posts: 42 Location: NewJersey
|
Thanks for the reply,
I have changed the openOptions like following
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_SET_IDENTITY_CONTEXT ;
But still my problem is not resolved. Can you please tell me what else can i try? |
|
Back to top |
|
 |
k_usa |
Posted: Thu Oct 12, 2006 12:15 pm Post subject: wORKING NOW |
|
|
Apprentice
Joined: 14 Aug 2006 Posts: 42 Location: NewJersey
|
Now i am able to put the message with the user-defined context.
Here is my final program.
//Set up the MQEnvironment properties for Client Connections
MQEnvironment.hostname = hostName ;
MQEnvironment.channel = channel ;
MQEnvironment.port = Integer.valueOf(port).intValue();
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY,MQC.TRANSPORT_MQSERIES);
//Connection To the Queue Manager
MQQueueManager qMgr = new MQQueueManager(qManager) ;
int openOptions=MQC.MQOO_OUTPUT + MQC.MQOO_SET_ALL_CONTEXT ;
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQOO_SET_ALL_CONTEXT ;
MQQueue myQueue =qMgr.accessQueue(queue, openOptions, null, null, null);
MQMessage myMessage = new MQMessage();
myMessage.userId = "cwadmin";
myMessage.putApplicationName = "WICS";
myMessage.putApplicationType = MQC.MQAT_JAVA;
myMessage.putDateTime = new GregorianCalendar();
myMessage.writeString("hhhh");
myMessage.format = MQC.MQFMT_STRING;
myQueue.put(myMessage,pmo);
myQueue.close();
qMgr.commit();
qMgr.disconnect();
Thanks a lot for the help. |
|
Back to top |
|
 |
tleichen |
Posted: Thu Oct 12, 2006 12:16 pm Post subject: |
|
|
Yatiri
Joined: 11 Apr 2005 Posts: 663 Location: Center of the USA
|
Assuming you read the text that Jeff pointed out, is your userid authorized to use the MQOO_SET_IDENTITY_CONTEXT option? _________________ IBM Certified MQSeries Specialist
IBM Certified MQSeries Developer |
|
Back to top |
|
 |
wschutz |
Posted: Thu Oct 12, 2006 12:53 pm Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
tleichen wrote: |
Assuming you read the text that Jeff pointed out, is your userid authorized to use the MQOO_SET_IDENTITY_CONTEXT option? |
if he weren't authorized, he'd get a 2035 on the open.... but he does need to use MQPMO_SET_ALL_CONTEXT _________________ -wayne |
|
Back to top |
|
 |
|