Using ActiveMQ via JNDI

前端 未结 2 1226
情话喂你
情话喂你 2021-01-02 19:49

I\'m trying to create simply connect with ActiveMQ using JNDI.


I have

  1. Queue named \'example.A\'.

  2. According ActiveMQ documentation touc

2条回答
  •  [愿得一人]
    2021-01-02 20:13

    The problem is that you are explicitly creating the properties and passing them into the InitialContext constructor. This means the jndi.properties on the class path won't be read.

    Your code should be something like:

    Context context = new InitialContext();
    ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("ConnectionFactory");
    Queue queue = (Queue) context.lookup("MyQueue");
    

提交回复
热议问题