Question

http://docs.oracle.com/javaee/1.4/api/javax/jms/Session.html#createTopic(java.lang.String) This API says that session.createTopic(topicname) is not for creating the physical topic. What does this mean?

If I want one group of user which has authority of "admin" is responsible for creating topics and another group of user which has authority of "write" is responsible for publishing messages to this topic, how can I implement this? It seems that the latter group must also have the authority of "admin" because they have to use this method: session.createTopic(topicname).

How can I separate the "admin" and "write" authority?

Was it helpful?

Solution

The JMS api is not for administration, only for using existing topics and queues. In ActiveMQ, default is that the physical queue/topic does is auto-created once needed (someone is sending to it/consuming from it).

How to create physical objects in a JMS implementation is vendor specific and you should checkout how this is handled in ActiveMQ.

How this is treated in AMQ

OTHER TIPS

What the JMS spec means is that createTopic(String) is used to give you a logical handle (javax.jms.Topic, a subtype of Destination) which you can subsequently use in other calls such as createProducer(Destination) or createConsumer(Destination). It just so happens in ActiveMQ that a physical destination will be created at the same time.

If you want to make sure that users can only publish to already created destinations, assign that group read and write permissions, but not admin. Obviously that assumes that those topics already exist - if they do not, then you'll get an exception thrown.

You haven't said exactly how you would like to administer topic creation, but if you are OK with doing that in the ActiveMQ config for them to be created at startup, then define those topics in a destinations block:

<broker xmlns="http://activemq.apache.org/schema/core">
  <destinations>
    <topic physicalName="topic.1" />
    <topic physicalName="topic.2" />
  </destinations>
</broker>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top