开发者

How to create physical queue in JMS at run time

Want to know how to create physical queue in JMS at run time. when I search for this I got Creating JMS Queues at runtime

But wh开发者_如何学JAVAen I read http://activemq.apache.org/how-do-i-create-new-destinations.html I come to know queue which mention in Creating JMS Queues at runtime is not creating any physical queue at server side.

Please correct me if I m wrong. If any one know to create physical queue at run time please replay.

Thanks in advance.


The creation of "normal" queues is not adressed by the JMS standard. Depending on what you want to do there are two approaches:

  • use temporary queues -> however they have many restrictions, most commonly they are used forrequest-reply scenarios
  • use the API of the JMS provider - however your solution will be depending on this specific provider then


The JMS standard only addresses sending and receiving data from objects like queues and topics. Creation of JMS artefacts is vendor specific and most often requires using:

1)specific vendor APIs (not JMS)

2)command/admin messages aimed at the JMS server (command agents on activemq)

3)JMX API

I have used JMX method, which is the most powerful, but also the most work.

JMX Method for activemq (version 5.0+)

a) JMS Server Setup

1) Enable JMX in activemq startup scripts and activemq.xml files

2) If you are authenticating to to the server, make sure your user has admin privileges setup in activemq.xml (see http://activemq.apache.org/security.html)

3)restart activemq server

b) Your Client Code

1) create an instance of org.apache.activemq.broker.jmx.BrokerViewMBean (you will need to connect with some JMX connectivity code which is a bit messy)

2) use its addQueue method. This will create a queue on the server

(The process is similar for hornetq but since you mentioned Activemq I have omitted hornetq details here.)

I have used this method myself and it works.

An alternative is to use Command Agents in Activemq, but I have no personal experience with these. These are special messages contain admin commands and may do what you want as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜