Send Messages

Use a Message Producer client to send messages to a destination. You can either send a message to the destination specified by the Message Producer or, if the Message Producer specifies NULL as the destination, you can send a message to a specific destination.

In either case, you can optionally set the JMSDeliveryMode, JMSExpiration, and JMSPriority message header fields described in JMS Message Header Fields when sending each message.

The following examples show different ways to send a text message in each language:

See EMS Extensions to JMS Messages for more information about creating messages.

  • Java
    Use the MessageProducer object’s send() method to send a message to the destination specified by the MessageProducer object:
       QueueSender.send(message); 

    Use the following form of the send() method to send a message to a specific destination:

       MessageProducer NULLsender = session.createProducer(null);
       ....
       NULLsender.send(topic, message);

    Use the form of the send() method with a completion listener argument to send a message asynchronously:

      QueueSender.send(message, completionListener);

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

  • C

    Use the tibemsMsgProducer_Send function to send a message to the destination specified by the tibemsMsgProducer:

       status = tibemsMsgProducer_Send(QueueSender, message);

    Use the tibemsMsgProducer_SendToDestination function to send the message to a specific destination:

       status = tibemsMsgProducer_SendToDestination(NULLsender,
                                                topic, message);

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

    Note: Unlike the Java and C# APIs, in the C API, you can use the tibemsMsgProducer_SendToDestination function to specify the destination regardless of whether a destination is in the tibemsMsgProducer.
  • C#

    Use the MessageProducer.Send method to send a message to the destination specified by the MessageProducer:

       QueueSender.Send(message);

    Use the following form of the MessageProducer.Send method to send a message to a specific destination:

       MessageProducer NULLsender = session.CreateProducer(NULL);
       NULLsender.Send(topic, message);

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