m***@brz.gv.at
2006-01-11 10:07:10 UTC
I just started with JMS messaging using the Spring framework as shown in "The Spring series, Part 4: 1-2-3 messaging with Spring JMS", see
http://www-128.ibm.com/developerworks/web/library/wa-spring4/?ca=drs-tp4005
The "problem" is, that MQ formats all TextMessages from JMS into its MQHRF2 format instead of the simple MQSTR format. One wants to put simple TextMessages in MQSTR if rthe receiving end are non-JMS consumers, eg. good old CICS programs ;-)
The solution is to coerce the Destination into an MQQueue and set the TargetClient to JMSC.MQJMS_CLIENT_NONJMS_MQ.
The method of JMSSender.sendMessage() of the accompanied sources to "The Spring series, Part 4: 1-2-3 messaging with Spring JMS" must be changed therefore to
public void sendMessage() {
jmsTemplate102.send(queueName, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
// Destination should be NON-JMS, so TextMessageFormat should be MQSTR insteasd of MQHRF2
boolean isPubSubDomain = jmsTemplate102.isPubSubDomain();
Destination destination = jmsTemplate102.getDestinationResolver().resolveDestinationName(session, queueName, isPubSubDomain);
((MQQueue)destination).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
DateFormat df = DateFormat.getDateTimeInstance();
String text = "Time is: " + df.format(new Date()) + "***";
System.out.println(" Now sending -->" + text);
return session.createTextMessage(text);
}
});
}
Hope this helps!
greetings
mike
http://www-128.ibm.com/developerworks/web/library/wa-spring4/?ca=drs-tp4005
The "problem" is, that MQ formats all TextMessages from JMS into its MQHRF2 format instead of the simple MQSTR format. One wants to put simple TextMessages in MQSTR if rthe receiving end are non-JMS consumers, eg. good old CICS programs ;-)
The solution is to coerce the Destination into an MQQueue and set the TargetClient to JMSC.MQJMS_CLIENT_NONJMS_MQ.
The method of JMSSender.sendMessage() of the accompanied sources to "The Spring series, Part 4: 1-2-3 messaging with Spring JMS" must be changed therefore to
public void sendMessage() {
jmsTemplate102.send(queueName, new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
// Destination should be NON-JMS, so TextMessageFormat should be MQSTR insteasd of MQHRF2
boolean isPubSubDomain = jmsTemplate102.isPubSubDomain();
Destination destination = jmsTemplate102.getDestinationResolver().resolveDestinationName(session, queueName, isPubSubDomain);
((MQQueue)destination).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
DateFormat df = DateFormat.getDateTimeInstance();
String text = "Time is: " + df.format(new Date()) + "***";
System.out.println(" Now sending -->" + text);
return session.createTextMessage(text);
}
});
}
Hope this helps!
greetings
mike