Create a Message Producer

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 Send 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 Create 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.