Author |
Message
|
Biju |
Posted: Wed Oct 19, 2005 4:52 am Post subject: Can we set the put time in a message header? |
|
|
 Acolyte
Joined: 03 Oct 2005 Posts: 71
|
Hello Gurus,
Please excuse me if this is a duplicated question. I have tried to search for an answer but couldnt find it yet. The problem is " can we assign the put time to a message, in a java application". Any help will be apreciated and I would like to know more about the put time . How is the put time specified. If an application sets a put time to a message is it over written by the QM when it is actually arrived in the target queue with the current system time. Hope to get an answer soon. Thank you for all your time.
Regards
Bijish |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Oct 19, 2005 5:14 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Start with the MQMD.
Notice that the PutTime and PutDate are a) separate fields, b) part of the message context.
Next, look at the Java definition.
Unless you're using JMS. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Biju |
Posted: Wed Oct 19, 2005 6:15 am Post subject: |
|
|
 Acolyte
Joined: 03 Oct 2005 Posts: 71
|
Thank you Jeff for a quick reply. Let me try on it. I couldnt figure out yet how can I set a time for a message yet. Hope to find it out soon. Thank you once again.
Regards
Bijish |
|
Back to top |
|
 |
Biju |
Posted: Thu Oct 20, 2005 1:14 am Post subject: |
|
|
 Acolyte
Joined: 03 Oct 2005 Posts: 71
|
Hi Guys,
Still I am on the other side. No solutions yet. Jeff I did go through the MQMD fileslds. I could give the putdatetime field a value also. But I searched a lot but failed to assign a puttime value to the message. Let me tell u what I am doing.
1. Set the environment variables(host,port and channel)
2. Open Q after initialising QM,Q and other things like PMO and open options.
3. Create a message.(new MQMessage).
4. Write a string to it using (msg.writeString())
Now the questions are....
1. The message descriptor is a part of the message so how do we assign values to it?
2. If we assign values to it and send it to the Q will the QM overwrite the values of those parameters?
Now let me tell you I am using v5.3 and CSD05 on WInXP.
I know these questions must be simple to you. But its not the same for a newbie like me(Atleast for me). If you could (or any one) kindly answer these question. Its not an urgent one. I am just trying to be as equipped as I can with the Java programming with WMQ. I am also trying to get a solution by myself and surely let you know if I succeed.Thank you all for your time.
Regards
Bijish. |
|
Back to top |
|
 |
wschutz |
Posted: Thu Oct 20, 2005 1:31 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/csqzaw1381.htm
:
Quote: |
For the MQPUT and MQPUT1 calls, this is an input/output field if MQPMO_SET_ALL_CONTEXT is specified in the PutMsgOpts parameter. The queue manager does not check the contents of the field, except that any information following a null character within the field is discarded. The queue manger converts the null character and any following characters to blanks. If MQPMO_SET_ALL_CONTEXT is not specified, this field is ignored on input and is an output-only field.
|
So you need to use "set_all_context" when you OPEN the queue and PUT the message. _________________ -wayne |
|
Back to top |
|
 |
Biju |
Posted: Thu Oct 20, 2005 1:31 am Post subject: |
|
|
 Acolyte
Joined: 03 Oct 2005 Posts: 71
|
I got the answer for the 2nd Question...
"To control context information, use the Options field in the MQPMO structure.If you do not, the queue manager overwrites context information that might already be in the message descriptor with the identity and context information that it has generated for your message. This is the same as specifying the MQPMO_DEFAULT_CONTEXT option."
Hope to find the other one soon |
|
Back to top |
|
 |
Biju |
Posted: Thu Oct 20, 2005 5:02 am Post subject: |
|
|
 Acolyte
Joined: 03 Oct 2005 Posts: 71
|
Hello Guys,
Sorry to come here with simple questions. But would you mind telling me what are the open options and PMOs we have to specify so that the QMGR will not over write the context params we specifya in the application for a particular message. I tried a combination of various options but none worked out. Hope to get an answer. Thanks in advance.
Regards,
Bijish |
|
Back to top |
|
 |
wschutz |
Posted: Thu Oct 20, 2005 6:10 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
I gave you this answer in my last post...
MQOO_SET_ALL_CONTEXT
MQPMO_SET_ALL_CONTEXT _________________ -wayne |
|
Back to top |
|
 |
Biju |
Posted: Thu Oct 20, 2005 6:17 am Post subject: |
|
|
 Acolyte
Joined: 03 Oct 2005 Posts: 71
|
Hi,
I tried it but still it is over written........Here is the piece of code which I am using. Please tell me if something is wrong in there
public boolean putMsg()
{
boolean flag = true;
MQQueueManager qmgr = null;
MQQueue q = null;
MQMessage msg = null;
try
{
MQEnvironment.hostname = host2;
MQEnvironment.port = Integer.parseInt(port2);
MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
qmgr = new MQQueueManager(qManagerD);
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_SET_ALL_CONTEXT ;
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_SET_ALL_CONTEXT ;
msg = new MQMessage();
msg.messageId = "Message:Id123".getBytes();
msg.putDateTime = new GregorianCalendar(2004,11,11,11,11,11);
msg.writeString("Hello there");
q = qmgr.accessQueue(lQueueD,openOptions,qm,null,null);
q.put(msg, pmo);
q.close();
System.out.println("Message Put Successfully...");
qmgr.commit();
qmgr.disconnect();
}
catch (MQException e)
{
flag = false;
System.out.println("MQException Exception PUT...");
showUsage();
}
catch (Exception e)
{
flag = false;
System.out.println("MQ Connection Exception PUT msg...");
showUsage();
}
finally
{
try
{
if (q != null)
{
q.close();
}
if (qmgr != null)
{
qmgr.disconnect();
}
}
catch (Exception e)
{
}
return flag;
}
}
Thank you
Bijish |
|
Back to top |
|
 |
wschutz |
Posted: Thu Oct 20, 2005 6:45 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Well, I took your fragment and compiled it (what do you set "qm" to?) and it works as I expected...the date is '2004-12-11'.
What are you using to look at the message on the queue? (and, are you sure you're looking at the right queue??) _________________ -wayne |
|
Back to top |
|
 |
Biju |
Posted: Thu Oct 20, 2005 6:54 am Post subject: |
|
|
 Acolyte
Joined: 03 Oct 2005 Posts: 71
|
Hi Wayne,
Thanks a lot for your co operation. qm is my Qmanager name and I am using explorer to check the message and other parameters. Yea now after restarting my QM its working fine. Thanks a lot once again
Best Regards,
Bijish |
|
Back to top |
|
 |
wschutz |
Posted: Thu Oct 20, 2005 6:57 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
Quote: |
Yea now after restarting my QM its working fine. |
I really don't think this had anything to do with your problem. _________________ -wayne |
|
Back to top |
|
 |
Biju |
Posted: Thu Oct 20, 2005 7:02 am Post subject: |
|
|
 Acolyte
Joined: 03 Oct 2005 Posts: 71
|
No idea about it. But I didnt change anything in the code. Just recompiled the code and restarted the QM. Just was desperate to get a solution. Any way I got it and am happy. Can go home and have a tight sleep.
Regards,
Bijish |
|
Back to top |
|
 |
|