Dynamically Create Topics and Queues
EMS provides a JNDI implementation that can be used to store topics and queues. Java, C, and C# clients can use the EMS JNDI implementation to lookup topics and queues.
You can also store topics and queues in any JNDI-compliant naming service or in an LDAP server. Java clients can lookup topics and queues in any JNDI-compliant naming service. C# clients can use LDAP servers but C clients cannot.
Look up Administered Objects Stored in EMS describes how to lookup topics and queues from an EMS server.
Clients can also create destinations as needed. If a client requests the creation of a destination that already exists, the existing destination is used. If the destination does not exist, and the specification of the topics.conf, queues.conf, or acl.conf files allow the destination, the server dynamically creates the new destination. The new destination inherits properties and permissions from its ancestors as described in Wildcards and Dynamically Created Destinations. The destination is managed by the server as long as clients that use the destination are running.
The following examples show how to create destinations dynamically:
- Java
Use the
Sessionobject’screateTopic()method to create a topic as aDestinationobject:Destination topic = session.createTopic(topicName);Use the
Sessionobject’screateQueue()method to create a queue as aDestinationobject:Destination queue = session.createQueue(queueName);See the
tibjmsMsgProducer.javasample client for a working example. - C
Use the
tibemsTopic_Createfunction to create a topic of typetibemsDestination:tibemsDestination topic = NULL;status = tibemsTopic_Create(&topic,topicName);Use the
tibemsQueue_Createfunction to create a queue of typetibemsDestination:tibemsDestination queue = NULL;status = tibemsQueue_Create(&queue,queueName);See the
tibemsMsgProducer.csample client for a working example. - C#
Use the
Session.CreateTopicmethod to create aTopicobject:Destination topic = session.CreateTopic(topicName);Use the
Session.CreateQueuemethod to create aQueueobject:Destination queue = session.CreateQueue(queueName);See the
csMsgProducer.cssample client for a working example.