ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » MQSeries java to override the header properties

Post new topic  Reply to topic
 MQSeries java to override the header properties « View previous topic :: View next topic » 
Author Message
vishal13
PostPosted: Thu Nov 18, 2010 5:47 pm    Post subject: MQSeries java to override the header properties Reply with quote

Newbie

Joined: 18 Nov 2010
Posts: 4

Hi ,
I am new to MQSeries and I have a requirement to populate MQSeries header, but I could not find any code in the internet. Please can anyone give me any reference to it.
Thanks,
S.Vishal
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Nov 18, 2010 6:09 pm    Post subject: Re: MQSeries java to override the header properties Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

vishal13 wrote:
Please can anyone give me any reference to it.


There's an entire Java manual in the InfoCenter (link at the top of this page) and if you're using JMS you don't need to manually populate the header per se.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
vishal13
PostPosted: Thu Nov 18, 2010 6:21 pm    Post subject: hi Reply with quote

Newbie

Joined: 18 Nov 2010
Posts: 4

Hi,
My requirement is..... I have to populate a message property in the JMSHeader so that on the receiver side he can use that property.
Please can you help me to provide any code snippet to populate that.
Thanks,
S.Vishal
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Nov 18, 2010 8:53 pm    Post subject: Re: hi Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

vishal13 wrote:
Hi,
My requirement is..... I have to populate a message property in the JMSHeader so that on the receiver side he can use that property.
Please can you help me to provide any code snippet to populate that.
Thanks,
S.Vishal


Your requirement is way to vague and you have not supplied an example.
The response, of course, will be vastly different whether you are JMS all the way or you have applications that will not accept the RFH header, and whether you are on V6 or V7....
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
vishal13
PostPosted: Fri Nov 19, 2010 4:46 am    Post subject: hi Reply with quote

Newbie

Joined: 18 Nov 2010
Posts: 4

Hi,
Version is 7. I want to populate JMSCorrelationId. Here is the code......

package mqseriesjava;

import com.oracle.bpel.client.IBPELDomainHandle;

import javax.jms.JMSException;
import javax.jms.Session;

import com.ibm.jms.JMSMessage;
import com.ibm.jms.JMSTextMessage;
import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQConnectionMetaData;
import com.ibm.mq.jms.MQQueue;
import com.ibm.mq.jms.MQQueueConnection;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import com.ibm.mq.jms.MQQueueReceiver;
import com.ibm.mq.jms.MQQueueSender;
import com.ibm.mq.jms.MQQueueSession;

import com.collaxa.cube.engine.types.bpel.CXMessageVariable;

import com.ibm.mq.MQGetMessageOptions;
import com.ibm.mq.MQMessage;

import com.ibm.mq.MQPropertyDescriptor;

import com.ibm.mq.MQPutMessageOptions;

import com.ibm.mq.headers.MQCIH;
import com.ibm.mq.headers.MQHeader;

import com.oracle.bpel.client.Locator;

import javax.jms.Message;


/**
* SimplePTP: A minimal and simple testcase for Point-to-point messaging (1.02 style).
*
* Assumes that the queue is empty before being run.
*
* Does not make use of JNDI for ConnectionFactory and/or Destination definitions.
*
* @author saket
*/
public class Enqueue {
/**
* Main method
*
* @param args
*/
public static void main(String[] args) {


try {
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
// com.collaxa.cube.engine.types.bpel.CXPart ss = (com.collaxa.cube.engine.types.bpel.CXPart) new com.collaxa.cube.engine.types.bpel.CXMessageVariable().getRaw().getPartDocumentIds().getParts().get(0)
//
//
// IBPELDomainHandle domain =
// Config
cf.setHostName("host");
cf.setPort(1414);
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setQueueManager("QM_HTI");
cf.setChannel("SYSTEM.DEF.SVRCONN");

MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
MQQueue queue = (MQQueue)
session.createQueue("queue:///a");
queue.setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ) ;
// MQGetMessageOptions gmo = new MQGetMessageOptions();
// MQPutMessageOptions pmo = new MQPutMessageOptions();
// MQMessage message = new MQMessage();

MQQueueSender sender = (MQQueueSender) session.createSender(queue);
MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver(queue);
a
long uniqueNumber = System.currentTimeMillis() % 1000;
// JMSTextMessage message = (JMSTextMessage) session.createTextMessage("<TestQueueProcessRequest xmlns:ns1=\"http://xmlns.oracle.com/TestQueue\" xmlns=\"http://xmlns.oracle.com/TestQueue\"><ns1:input><ns1:input1>1111</ns1:input1><ns1:input2>111122</ns1:input2></ns1:input><ns1:input3>111100</ns1:input3></TestQueueProcessRequest>\n");
// JMSTextMessage message = (JMSTextMessage) session.createTextMessage("<ns1:InitialDataSummaryProcessRequest xmlns:ns1=\"http://xmlns.oracle.com/InitialDataSummary\"><ns1:input>11</ns1:input></ns1:InitialDataSummaryProcessRequest>");
JMSTextMessage message1 = (JMSTextMessage) session.createTextMessage("<ns1:PeriodicUageProcessRequest xmlns:ns1=\"http://xmlns.oracle.com/PeriodicUage\"><ns1:input>12</ns1:input> </ns1:PeriodicUageProcessRequest> ");
MQCIH header = new MQCIH();



// Start the connection
connection.start();

// sender.send(message);
sender.send(message1);
System.out.println("Sent message:\\n" + message1);

// JMSMessage receivedMessage = (JMSMessage) receiver.receive(10000);
// System.out.println("\\nReceived message:\\n" + receivedMessage);

sender.close();
receiver.close();
session.close();
connection.close();

System.out.println("\\nSUCCESS\\n");
}
catch (JMSException jmsex) {
System.out.println(jmsex);
System.out.println("\\nFAILURE\\n");
}
catch (Exception ex) {
System.out.println(ex);
System.out.println("\\nFAILURE\\n");
}
}
}
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Nov 19, 2010 4:57 am    Post subject: Re: hi Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

vishal13 wrote:
I want to populate JMSCorrelationId. Here is the code......


If you're going to post code please use the proper tag to make it readable.

Doesn't JMS handle message and correlation automatically? I know you can't set message id in JMS.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
vishal13
PostPosted: Fri Nov 19, 2010 5:01 am    Post subject: hi Reply with quote

Newbie

Joined: 18 Nov 2010
Posts: 4

To further explain here is my scenario, my business partner will send the message and I have to read it and further based on the message I have to divert it to the different partners. So, we are planning to populate the properties so that reading those property I can understand the type of message being populated. Here I could have read the content and divert it, but its an XML and I dont want to parse it to avoid performance, there fore I am looking to populate something in the header itself so that I can know looking at those properties.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Nov 19, 2010 5:14 am    Post subject: Re: hi Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

vishal13 wrote:
I am looking to populate something in the header itself so that I can know looking at those properties.


Well the JMS User Properties would be an obvious thing to use in this context.....

You'll find these described both in the WMQ documentation and any reference on JMS (as they're JMS concepts that WMQ supports rather than WMQ concepts per se).
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 19, 2010 8:56 pm    Post subject: Re: hi Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

vishal13 wrote:
To further explain here is my scenario, my business partner will send the message and I have to read it and further based on the message I have to divert it to the different partners. So, we are planning to populate the properties so that reading those property I can understand the type of message being populated. Here I could have read the content and divert it, but its an XML and I dont want to parse it to avoid performance, there fore I am looking to populate something in the header itself so that I can know looking at those properties.


Relatively obtuse but if you really look at the JMSCorrelId you want to look at the request reply samples. They should tell you both how to recognize the messages and pick them by correlId and how to set the correlId on a messages.

My rule of thumb for JMS is: If the correlId = MQCI_NONE set the messageId as correlId, otherwise the correlId is a pass-through
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQSeries java to override the header properties
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.