How do I verify that a JMS queue exists using Java? -
How can I check if there is a queue on the JMS server using the Java API? I still do not want to send or receive any data in the queue, just verify that the queue exists. Also, the queue may be empty.
Here is my code sample. I have removed the error handling for simplicity.
Connection connection = zero; Session session = null; Connection = Factory. Secure connection (); Session = connection.create session (false, session. AUTO_ACKNOWLEDGE); // I was hoping that this next line would throw an exception if the queue is not in line Queue line = session .createQueue (queueName); My JMS server is Tibo EMS. I am hoping for a solution that works on version 5-7.
Solution I followed the recommendation in the accepted answer but instead created a browser. The following line threw an exception as desired:
QueueBrowser browser = session.createBrowser (queue);
A queue object that you just created to a consumer or creator:
Previous> session.createConsumer (queue); If this queue (or subject) does not exist, then it should throw an invalid DestinationException.
Comments
Post a Comment