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
Jakarta Messaging 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 Jakarta Messaging Messages for more information about creating messages.
- Java
Use the
MessageProducerobject’ssend()method to send a message to the destination specified by theMessageProducerobject: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.javasample client for a working example. - C
Use the
tibemsMsgProducer_Sendfunction to send a message to the destination specified by thetibemsMsgProducer:status = tibemsMsgProducer_Send(QueueSender, message);Use the
tibemsMsgProducer_SendToDestinationfunction to send the message to a specific destination:status = tibemsMsgProducer_SendToDestination(NULLsender,topic, message);See the
tibemsMsgProducer.csample client for a working example.Note: Unlike the Java and C# APIs, in the C API, you can use thetibemsMsgProducer_SendToDestinationfunction to specify the destination regardless of whether a destination is in thetibemsMsgProducer. - C#
Use the
MessageProducer.Sendmethod to send a message to the destination specified by theMessageProducer:QueueSender.Send(message);Use the following form of the
MessageProducer.Sendmethod to send a message to a specific destination:MessageProducer NULLsender = session.CreateProducer(NULL);NULLsender.Send(topic, message);See the
csMsgProducer.cssample client for a working example.