Created attachment 602509 [details] reproducer Java program Description of problem: Creating in a loop a connection, session and consumer defined in JNDI property file, 2nd instance of the loop raises "Queue not found" exception. Version-Release number of selected component (if applicable): qpid-java-*-0.14-3 How reproducible: 100% Steps to Reproduce: See reproducer. Actual results: ERROR [IoReceiver - localhost/127.0.0.1:5672] (AMQConnection.java:1267) - Throwable Received but no listener set: org.apache.qpid.AMQException: ch=0 id=0 ExecutionException(errorCode=NOT_FOUND, commandId=0, classCode=4, commandCode=7, fieldIndex=0, description=not-found: Queue not found: response-queue (qpid/broker/SessionAdapter.cpp:686), errorInfo={}) [error code 404: not found] ERROR [main] (AMQConnection.java:1267) - Throwable Received but no listener set: org.apache.qpid.AMQException: ch=0 id=0 ExecutionException(errorCode=NOT_FOUND, commandId=0, classCode=4, commandCode=7, fieldIndex=0, description=not-found: Queue not found: response-queue (qpid/broker/SessionAdapter.cpp:686), errorInfo={}) [error code 404: not found] javax.jms.JMSException: Error registering consumer: org.apache.qpid.AMQException: ch=0 id=0 ExecutionException(errorCode=NOT_FOUND, commandId=0, classCode=4, commandCode=7, fieldIndex=0, description=not-found: Queue not found: response-queue (qpid/broker/SessionAdapter.cpp:686), errorInfo={}) [error code 404: not found] at org.apache.qpid.client.AMQSession$4.execute(AMQSession.java:2105) at org.apache.qpid.client.AMQSession$4.execute(AMQSession.java:2040) at org.apache.qpid.client.AMQConnectionDelegate_0_10.executeRetrySupport(AMQConnectionDelegate_0_10.java:369) at org.apache.qpid.client.AMQConnection.executeRetrySupport(AMQConnection.java:586) at org.apache.qpid.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102) at org.apache.qpid.client.AMQSession.createConsumerImpl(AMQSession.java:2038) at org.apache.qpid.client.AMQSession.createConsumer(AMQSession.java:996) at Test_00689136.<init>(Test_00689136.java:71) at Test_00689136.main(Test_00689136.java:46) Caused by: org.apache.qpid.AMQException: ch=0 id=0 ExecutionException(errorCode=NOT_FOUND, commandId=0, classCode=4, commandCode=7, fieldIndex=0, description=not-found: Queue not found: response-queue (qpid/broker/SessionAdapter.cpp:686), errorInfo={}) [error code 404: not found] at org.apache.qpid.client.AMQSession_0_10.setCurrentException(AMQSession_0_10.java:1102) at org.apache.qpid.client.AMQSession_0_10.sync(AMQSession_0_10.java:1082) at org.apache.qpid.client.AMQSession_0_10.sendConsume(AMQSession_0_10.java:686) at org.apache.qpid.client.AMQSession_0_10.sendConsume(AMQSession_0_10.java:87) at org.apache.qpid.client.AMQSession.consumeFromQueue(AMQSession.java:2626) at org.apache.qpid.client.AMQSession.registerConsumer(AMQSession.java:2962) at org.apache.qpid.client.AMQSession.access$500(AMQSession.java:120) at org.apache.qpid.client.AMQSession$4.execute(AMQSession.java:2082) ... 8 more Expected results: No exception raised. Additional info: When the Queue object is replaced by: final Queue dest = new AMQAnyDestination(address_string_of_the_same_queue) then no exception is raised.
When moving: Context ctx = new InitialContext(properties); into the loop, no exception is raised.
When properties not loaded from JNDI file but set from code like: Properties properties = new Properties(); properties.setProperty( .. ) then no exception is raised.
Created attachment 608412 [details] Simplified reproducer Simplified reproducer not relying on external JNDI file. (please ignore comment 2, the bug is present irrespective of properties loaded from JNDI or in code)
Created attachment 608487 [details] patch proposal Simple patch proposal. calling Context ctx = new InitialContext(properties); just once causes Destination object to be created just once. First invocation of: MessageConsumer clientConsumer = session.createConsumer(destination/queue) then sets address resolution to current timestamp to prevent resolving the address later on (see handleAddressBasedDestination in AMQSession_0_10 class for details). Next invocation of createConsumer sees the destination has address already resolved, what is wrong. To correct it, once the queue is deleted (when closing the consumer), address resolution of the destination has to be re-set to 0.
Applied Pavel's patch but in a different location (where node deletion is handled) as the Queue can be deleted by Producer not just a Consumer and will cause the same issue. http://svn.apache.org/r1454134 Also applied the same fix for exchanges as a deletion triggered by a consumer/producer close can cause the same issue if the same destination is re-used to create another producer or consumer. http://svn.apache.org/r1454135
Created attachment 778290 [details] Extended reproducer Reproducer now tests for 2nd creation of: - queue consumer - queue producer - exchange consumer - exchange producer
Verified rhel 6.4 32/64 qpid-java-client-0.22-4.el6.noarch qpid-java-common-0.22-4.el6.noarch qpid-java-example-0.22-4.el6.noarch [root@mrg30 examples]# ./run_example.sh test_00689136 Test with properties from code. {destination.ResponseQueue=response-queue;{create:always,delete:always}, connectionfactory.QpidConnectionFactory=amqp://guest:guest@localhost:5672/test?brokerlist='tcp://localhost:5672', java.naming.factory.initial=org.apache.qpid.jndi.PropertiesFileInitialContextFactory, destination.topicExchange=test-topic;{create:always,delete:always, node:{type:topic}}} testing queue consumer...0.1.succeeded testing queue producer...0.1.succeeded testing exchange consumer...0.1.succeeded testing exchange producer...0.1.succeeded reproduced on rhel 6.4 64
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHEA-2014-1296.html