Announcement Announcement Module
Collapse
No announcement yet.
JMS Messages onto MQSeries Messages Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JMS Messages onto MQSeries Messages

    Hi,

    How i can set following properties on the JMS Messages

    characterSet
    encoding
    format
    persistence
    replyToQueueManagerName
    replyToQueueName

    if i cast JMS Messages to MQ message and set these properties it complied but i am getting class cast exception at run time.

    I am usin JMSTemplate to send message.

    thank you,
    muhwas

  • #2
    Websphere MQ MQMD properties via JMS API

    Hello muhwas,

    Here is a sample of code to set Websphere MQ MQMD properties via JMS API. and few details about where you can get detailed information about MQMD <-> JMS fields mapping.

    Sample

    I had an exception with JMSC.FORMAT_PROPERTY because I don't know how to use it but this property is definitively used by Websphere MQ JMS to define the MQMD format attribute

    Code:
    // initialize ConnectionFactory manually
    ConnectionFactory connectionFactory = new MQConnectionFactory();
    ((MQConnectionFactory) connectionFactory).setHostName("localhost");
    ((MQConnectionFactory) connectionFactory).setPort(1414);
    
    Connection connection = connectionFactory.createConnection();
    connection.start();
    
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue requestQueue = session.createQueue("MyRequestQueue");
    MessageProducer messageProducer = session.createProducer(requestQueue);
    Queue replyQueue = session.createQueue("MyReplyQueue");
    
    TextMessage textMessage = session.createTextMessage("this is a mesage " + new Date());
    
    textMessage.setIntProperty(JMSC.CHARSET_PROPERTY, 819);
    
    textMessage.setIntProperty(JMSC.ENCODING_PROPERTY, JMSC.MQJMS_ENCODING_NATIVE);
    
    // JMSC.FORMAT_PROPERTY should work but raises "MQJE001: ... Reason 2334"
    // textMessage.setStringProperty(JMSC.FORMAT_PROPERTY, "MQHRF2 ");
    
    textMessage.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
    
    textMessage.setJMSReplyTo(replyQueue);
    
    messageProducer.send(textMessage);
    Websphere MQ Infocenter : Mapping JMS fields onto WebSphere MQ fields (outgoing messages)

    Outgoing message field mapping
    Code:
    | JMS header field | MQMD field used       | Header | Set by         |
    | name             | used for transmission |        |                |
    |                  |                       |        |                |
    | JMSDestination   |                       | MQRFH2 | Send Method    |
    | JMSDeliveryMode  | Persistence           | MQRFH2 | Send Method    |
    | JMSExpiration    | Expiry                | MQRFH2 | Send Method    |
    | JMSPriority      | Priority              | MQRFH2 | Send Method    |
    | JMSMessageID     | MessageID             |        | Send Method    |
    | JMSTimestamp     | PutDate/PutTime       |        | Send Method    |
    | JMSCorrelationID | CorrelId              | MQRFH2 | Message Object |
    | JMSReplyTo       | ReplyToQ/ReplyToQMgr  | MQRFH2 | Message Object |
    | JMSType          |                       | MQRFH2 | Message Object |
    
    | JMSRedelivered   |                       |        | Receive-only   |

    Outgoing message JMS property mapping

    Code:
    | JMS property name | MQMD field used  | Header | Set by         |
    |                   | for transmission |        |                |
    |                   |                  |        |                |
    | JMSXUserID        | UserIdentifier   |        | Send Method    |
    | JMSXAppID         | PutApplName      |        | Send Method    |
    | JMSXDeliveryCount |                  |        | Receive-only   |
    | JMSXGroupID       | GroupId          | MQRFH2 | Message Object |
    | JMSXGroupSeq      | MsgSeqNumber     | MQRFH2 | Message Object |
    Hope this helps,

    Cyrille

    Comment


    • #3
      JMS Messages onto MQSeries Messages

      Do you know if the Provider allows you to set those header properties. I would suggest you to look at it first before setting the properties. Because some of the providers dont allow to set these properties as they use them while receiving and processing the messages. Check it out.

      Comment


      • #4
        for format you should use "JMS_IBM_Format" and its a MQCHAR8 please see

        http://www-306.ibm.com/software/inte...htm#TBLMESPCFT

        Comment

        Working...
        X