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:
- Send the message to the Message Producer, QueueSender, created in Create a Message Producer.
- Use a Message Producer with a NULL destination that sends the message to the topic created in Dynamically Create Topics and Queues.
- Use a Completion Listener, created in Create a Message Listener for Asynchronous Message Consumption, to send the message asynchronously.
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.
- 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.