Create Messages

As described in JMS Message Bodies, EMS works with the following types of messages:

  • Messages with no body
  • Text Messages
  • Map Messages
  • Bytes Messages
  • Stream Messages
  • Object Messages

There is a separate create method for each type of message.

The following examples show how to create a simple text message containing the string "Hello."

  • Java

    Use the Session object’s createTextMessage() method to create a TextMessage:

       TextMessage message = session.createTextMessage("Hello");

    See the tibjmsMsgProducer.java sample client for a working example.

  • C

    Use the tibemsTextMsg_Create function to create a text message of type tibemsTextMsg:

       tibemsTextMsg message = "Hello";
       status = tibemsTextMsg_Create(&message);

    See the tibemsMsgProducer.c sample client for a working example.

  • C#

    Use the Session.CreateTextMessage method to create text message of type TextMessage:

       TextMessage message = session.CreateTextMessage("Hello");

    See the csMsgProducer.cs sample client for a working example.