Author |
Message
|
ucbus1 |
Posted: Tue Apr 29, 2003 6:43 am Post subject: MQPUT question |
|
|
Knight
Joined: 30 Jan 2002 Posts: 560
|
I am using Java to put a message in a queue.
I am setting MqEnvironment variables to populate the needed fields.
for example
MQEnvironment.hostname
MQEnvironment.channel
MQEnvironment.port
MQEnvironment.userID
Th is is working fine. I would like to customize the application name . Right now it is defaulting to "MQSeriesClient for java". Is thee any way I can customize and change it to say "xyz". Please let me know |
|
Back to top |
|
 |
vennela |
Posted: Tue Apr 29, 2003 1:32 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
You can use the MQMessage's fields to achieve what you are trying to. There are fields like putApplicationName or applicationIdData that you can use to set to whatever value you want to. From your post it seems that you want to set putApplicationName. But in the open options (while you open the queue) do not forget to include MQC.MQOO_SET_ALL_CONTEXT. and while doing the put you PutMessageOptions should have MQC.MQPMO_SET_ALL_CONTEXT.
-------
Venny |
|
Back to top |
|
 |
ucbus1 |
Posted: Wed Apr 30, 2003 6:06 am Post subject: |
|
|
Knight
Joined: 30 Jan 2002 Posts: 560
|
Thanks venny.
Thanks for showing the direction. I have the following questions
In "Mq series using java". I find under MQMessage options applicationIdData and putApplicationName are having default values " ". then why I am getting "MQSeriesClient for java" . Ideally it should be the default " ". right?
Quote: |
But in the open options (while you open the queue) do not forget to include MQC.MQOO_SET_ALL_CONTEXT. and while doing the put you PutMessageOptions should have MQC.MQPMO_SET_ALL_CONTEXT. |
Could you explain significance of the above option?
Thanks |
|
Back to top |
|
 |
vennela |
Posted: Wed Apr 30, 2003 8:29 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
Yes, the doc is right.
If your code looks something like this:
Code: |
DemoQueue.put(inMessage); |
then the putApplicationName will have the value "MQSeriesClient for java".
But if your code looks something like this
Code: |
MQPutMessageOptions pmo = new MQPutMessageOptions();
DemoQueue.put(inMessage, pmo);
//MQMessage's values are defaults.
|
then you will have spaces in the putApplicationName filed
MQC.MQOO_SET_ALL_CONTEXT
If you don't use this option, you will not be able to set some fileds like the above ones.
-------
Venny |
|
Back to top |
|
 |
ucbus1 |
Posted: Wed Apr 30, 2003 9:23 am Post subject: |
|
|
Knight
Joined: 30 Jan 2002 Posts: 560
|
Thanks venny...
It is very informative. I have the following code
My open queue looks like this
QueueManager = new MQQueueManager(qMgrName);
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_SET_IDENTITY_CONTEXT;
InputQ = QueueManager.accessQueue( qName, openOptions,qMgrName,null,null);
*******************
My put looks like this
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_SET_IDENTITY_CONTEXT;
InputQ.put(Msg,pmo);
Quote: |
But if your code looks something like this
Code:
MQPutMessageOptions pmo = new MQPutMessageOptions();
DemoQueue.put(inMessage, pmo); |
Could you please explain why I am still getting "MQSeriesClient for java". evan after I am having pmo parameter in PUT function
Thanks |
|
Back to top |
|
 |
vennela |
Posted: Wed Apr 30, 2003 9:44 am Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
The options that you have specified will allow you to set the Identity Context of the Message Descriptor.
You should make the following changes to your code:
int openOptions = MQC.MQOO_OUTPUT | QC.MQOO_SET_ALL_CONTEXT;
pmo.options = MQC.MQPMO_SET_ALL_CONTEXT;
(If you haven't noticed, the options that you specified are different from the above. MQC.MQPMO_SET_ALL_CONTEXT
MQC.MQOO_SET_IDENTITY_CONTEXT )
With this you should be OK.
-------
Venny |
|
Back to top |
|
 |
ucbus1 |
Posted: Wed Apr 30, 2003 1:18 pm Post subject: |
|
|
Knight
Joined: 30 Jan 2002 Posts: 560
|
Thanks it did work. But I got some other problem.
When I have changed to "all context" from "ID context".. I am getting invalid date time format on MQ explorer ( when you look under putdatetimestamp column). I guess it is expecting in mm:dd:yy hh:mm:ss format and the default is GMT format. Do you know how to get over the problem??
Thanks |
|
Back to top |
|
 |
ucbus1 |
Posted: Thu May 01, 2003 6:34 am Post subject: |
|
|
Knight
Joined: 30 Jan 2002 Posts: 560
|
I think I have fixed the problem
To populate the application name, changed put message options from MQC.MQPMO_SET_IDENTITY_CONTEXT to
MQC.MQPMO_SET_ALL_CONTEXT.Since this makes the putDatetime as i/o field, I had to populate putDateTime by coding
Code: |
import java.util.*;
private GregorianCalendar putDateTime=new GregorianCalendar();
Msg.putDateTime=putDateTime;
Venny,
Could you please let me know if my soultion is right?
Thanks |
|
|
Back to top |
|
 |
|