Author |
Message
|
damianharvey |
Posted: Tue May 25, 2004 7:01 pm Post subject: Passing filename into MQ to be used in Broker |
|
|
 Acolyte
Joined: 05 Aug 2003 Posts: 59 Location: Sydney, Australia
|
I have a process where a flatfile is picked up by a Java app and the contents are put to MQ. The Broker (WBI MB v5) then performs some operations on this message.
One of the requirements is to pass the filename in so that it can be used in the Broker. What is the best way of doing this?
1. Including it as part of the contents. This would require changing the contents to include the filename as part of a metadata line. Not too keen on this for various reasons.
2. Using some of the MQMessage properties eg. ApplicationOriginData. This would be ideal however I can't get the Java API to set it so that it passes through to MQ. I am using the code :
Code: |
mqmessage.applicationOriginData = "test"; |
The problem with this is retrieving it in the Broker. The only available fields in the Propeties tree are :
MessageSet
MessageType
MessageFormat
Encoding
CodedCharSetId
Transactional
Persistence
CreationTime
ExpirationTime
Priority
ReplyIdentifier
ReplyProtocol
Topic (this field contains a list) So which to use?
3. Setting the RFH2 Header. I have been able to read from the RFH2 Header thanks to the code from Eddie (http://www.mqseries.net/phpBB2/viewtopic.php?t=9911 - and cheers for that) but am having difficulty in writing to the RFH2 as MQ treats what I write as part of the content. Checking the Hex from MQExplorer they are slightly different but I don't know what else I need to set. The relevant parts of the code are :
Code: |
//Create message
MQMessage message = new message();
//Set properties
message.messageType = 8;
message.format = "MQSTR ";
message.report = 3;
message.persistence = 1;
message.expiry = -1;
message.setVersion(2);
//Create RFH2 Header
message.writeString("RFH ");
message.writeInt(2);
message.writeInt(40 + 16);
message.writeInt(546);
message.writeInt(437);
message.writeString(" ");
message.writeInt(0);
message.writeInt(1208);
message.writeInt(16);
message.writeString("<usr>test</usr> ");
//Write message contents
message.writeString("Hello World");
|
Is there something I am leaving out of this????
Anyway, sorry for the long post. If anyone can help I'd really appreciate it.
Thanks,
Damian. |
|
Back to top |
|
 |
kspranava |
Posted: Wed May 26, 2004 12:28 am Post subject: |
|
|
 Centurion
Joined: 27 Apr 2003 Posts: 124
|
Hi,
In your message flow, if you are not manipulating correl id, you can very well set the file name to it. And it will be easy to recover data from correl id in broker. However, using correl id poses certain constraints on length of file name.
Pranava. |
|
Back to top |
|
 |
JT |
Posted: Wed May 26, 2004 5:58 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Quote: |
Code: |
mqmessage.applicationOriginData = "test"; |
The problem with this is retrieving it in the Broker. The only available fields in the Propeties tree are :
|
The parameter applicationOriginData is not located in the Properties tree, it's located in the Message Descriptor, where the Broker would reference it as MQMD.ApplOriginData? |
|
Back to top |
|
 |
JT |
Posted: Wed May 26, 2004 7:05 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Quote: |
....am having difficulty in writing to the RFH2 as MQ treats what I write as part of the content |
I think the hilighted statement:
Quote: |
://Create message
MQMessage message = new message();
//Set properties
message.messageType = 8;
message.format = "MQSTR ";
message.report = 3;
message.persistence = 1;
message.expiry = -1;
message.setVersion(2);
|
...should be:
Code: |
message.format = MQC.MQFMT_RF_HEADER_2; |
MQ will now treat the MQRFH2 as a header and not part of the content. |
|
Back to top |
|
 |
damianharvey |
Posted: Wed May 26, 2004 2:35 pm Post subject: |
|
|
 Acolyte
Joined: 05 Aug 2003 Posts: 59 Location: Sydney, Australia
|
Thanks JT. The second bit worked a treat. My RFH2 is reading/writing as expected.
However the mqmessage.applicationOriginData = "test"; still can't be seen in the MQMD tree in the Broker (checked with Debug). Is there a similar setting to the format that tells MQ that this property exists? I can see everything else in the MQMD however the ApplOriginData is empty.
Cheers,
Damian. |
|
Back to top |
|
 |
JT |
Posted: Wed May 26, 2004 3:41 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Since ApplOriginData is part of the context information of the message, you have to specify the MQPMO_SET_ALL_CONTEXT setting in the PutMsgOpts parameter, otherwise the default setting of MQPMO_DEFAULT_CONTEXT is taken and the ApplOriginData is set to blanks. |
|
Back to top |
|
 |
|