How does a client create a topic (or a queue)?

Jerry Smith

In the section "Topic Management" the JMS specification states: "JMS does not define facilities for creating, administering, or deleting topics." In the JMS API, however, the QueueSession and TopicSession interfaces include createQueue() and createTopic(), respectively.

For now, it's likely that JMS implementations will vary with respect to static versus dynamic topic creation, as well as external topic administration and manipulation. It's possible that some implementations will require static topic creation in advance using external functionality, for example, a utility. Some JMS implementations include a complete system administration tool for topic and queue management. Some implementations will provide administrative APIs for programmatic control of resource management. Other implementations may provide basic facilities for, say, topic or queue creation on the fly, plus an administrative console for creation, deletion, and other management tasks, plus security management.

For example, some environments support dynamic look-up using JNDI, plus dynamic destination creation, if necessary:

  try {
    queue = (Queue) c.lookup(QUEUE);
  catch (NamingException ne) {
    try {
      queue = session.createQueue(QUEUE);
      c.bind(QUEUE, queue);
    catch (Exception e) {
      readyToSend = false;

In the previous code segment, c is a JNDI InitialContext object.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact