MQSTR instead of MQHRF2 using Spring JMS - Solution - Websphere

This is a discussion on MQSTR instead of MQHRF2 using Spring JMS - Solution - Websphere ; 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/developerwork...?ca=drs-tp4005 The "problem" is, that MQ formats all TextMessages from JMS into its MQHRF2 format instead ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: MQSTR instead of MQHRF2 using Spring JMS - Solution

  1. MQSTR instead of MQHRF2 using Spring JMS - Solution

    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/developerwork...?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().resolveDes tinationName(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


  2. Re: MQSTR instead of MQHRF2 using Spring JMS - Solution

    Hi mike,

    Thanks. Did you write to the developerworks article's author with this?

    Martin



  3. Yes, I did mail the solution to the author

    Hi Martin,
    jipp, I wrote a mail including all the sorces to Naveen Balani today.

    BTW, if you want the sources as well, contact me via mail

    greetings
    mike (michael.hauser@brz.gv.at)

+ Reply to Thread