Reputation: 29266
I am sending message from Java Code to Websphere MQ Server
and when I am reading the same message on MQ server, it's displaying as:
message<RFH >
Below is the code sending the message to MQ server:
private void sendMessage() throws Exception {
ConnectionFactory cf1 = (ConnectionFactory) new InitialContext().lookup("java:comp/env/jms/wmqCF");
// Lookup Queue resource from JNDI
Queue queue = (Queue) new InitialContext().lookup("java:comp/env/jms/wmqQ1");
Connection con = cf1.createConnection();
// start the connection to receive message
con.start();
// create a queue session to send a message
Session sessionSender = con.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
MessageProducer send = sessionSender.createProducer(queue);
TextMessage msg = sessionSender.createTextMessage("Liberty Sample Message");
// send a sample message
send.send(msg);
if (con != null)
con.close();
System.out.println("Send Message Completed");
}
Expected to be displayed as: Liberty Sample Message
.
Any idea, what I am missing here?
Thanks.
Upvotes: 0
Views: 1137
Reputation: 29266
Setting the targetClient="MQ"
as a property of jmsQueue
works.
Below is the configuration change in server.xml
of WLP:
<jmsQueue id="jms/queue1" jndiName="jms/wmqQ1">
<properties.wmqJms baseQueueManagerName="QMA" baseQueueName="QUEUE1" targetClient="MQ"/>
</jmsQueue>
Upvotes: 0
Reputation: 7456
And if you retrieve the message with another JMS program then the message data will be "Liberty Sample Message".
You are mixing JMS and non-JMS program types.
.lookup("java:comp/env/jms/wmqQ1");
Set the 'TARGCLIENT' attribute to MQ. i.e. TARGCLIENT(MQ)
Then the message data will not have the RFH2 header.
Upvotes: 1