> Creating a Message Producer
> As described in JMS Message Models, a Message Producer is an EMS client that either publishes messages to a topic or sends messages to a queue. When working with topics, a Message Producer is commonly referred to as a Publisher. Optionally, when creating a Message Producer, you can set the destination to NULL and specify the destination when you send or publish a message, as described in Sending Messages.
> You must have send permission on a queue to create a message producer that sends messages to that queue. You must have durable permission on the topic to create a new durable subscriber for that topic, and have at least use_durable permission on the topic to attach to an existing durable subscriber for the topic. See User Permissions for details.
> The following examples create a message producer that sends messages to the queue that was dynamically created in Dynamically Creating Topics and Queues.
> Java
> Use the Session object’s createProducer() method to create a MessageProducer object:
> MessageProducer QueueSender = session.createProducer(queue);
> See the tibjmsMsgProducer.java sample client for a working example.
> C
> Use the tibemsSession_CreateProducer function to create a message producer of type tibemsMsgProducer:
> tibemsMsgProducer QueueSender = NULL;
> status = tibemsSession_CreateProducer(session,
> &QueueSender,queue);
> See the tibemsMsgProducer.c sample client for a working example.
> C#
> Use the Session.CreateProducer method to create a MessageProducer object:
> MessageProducer QueueSender = session.CreateProducer(queue);
> See the csMsgProducer.cs sample client for a working example.
> Configuring a Message Producer
> A message producer can be configured to generate messages with default headers and properties that define how those messages are to be routed and delivered. Specifically, you can:

> ● | Set the producer's default delivery mode.

> ● | Set whether message IDs are disabled.

> ● | Set whether message timestamps are disabled.

> ● | Set the producer's default priority.

> ● | Set the default length of time that a produced message should be retained by the message system.

> For example, as described in the Message Delivery Modes, you can set the message deliver mode to either PERSISTENT, NON_PERSISTENT, or RELIABLE_DELIVERY.
> Java
> Use the MessageProducer object’s setDeliveryMode() method to configure your Message Producer with a default delivery mode of RELIABLE_DELIVERY:
> QueueSender.setDeliveryMode(
> com.tibco.tibjms.Tibjms.RELIABLE_DELIVERY);
> To configure the Message Producer with a default delivery mode of NON_PERSISTENT:
> QueueSender.setDeliveryMode(
> javax.jms.DeliveryMode.NON_PERSISTENT);
> See the tibjmsMsgProducerPerf.java sample client for a working example.

> | Delivery mode cannot be set by using the Message.setJMSDeliveryMode() method. According to the JMS specification, the publisher ignores the value of the JMSDeliveryMode header field when a message is being published.

> C
> Use the tibemsMsgProducer_SetDeliveryMode function to configure your Message Producer to set a default delivery mode for each message it produces to RELIABLE_DELIVERY:
> tibems_int deliveryMode = TIBEMS_RELIABLE;
> status tibemsMsgProducer_SetDeliveryMode(QueueSender,
> deliveryMode);
> C#
> Set the DeliveryMode on the MessageProducer object to RELIABLE_DELIVERY:
> QueueSender.DeliveryMode = DeliveryMode.RELIABLE_DELIVERY;
> See the csMsgProducerPerf.cs sample client for a working example.

Copyright © TIBCO Software Inc. All Rights Reserved.