Bug 845999 - second invocation of createConsumer fails for queue in JNDI properties file
Summary: second invocation of createConsumer fails for queue in JNDI properties file
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: qpid-java
Version: 2.1
Hardware: All
OS: All
medium
medium
Target Milestone: 3.0
: ---
Assignee: Rajith Attapattu
QA Contact: Irina Boverman
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-06 12:54 UTC by Pavel Moravec
Modified: 2018-12-06 14:48 UTC (History)
5 users (show)

Fixed In Version: qpid-java-0.22
Doc Type: Bug Fix
Doc Text:
If the address had a delete directive, the queue or exchange would be deleted when the consumer or producer closed (as specified in the delete directive). Because the destination was marked as resolved, no validation (or creation) of the queue or exchange was performed when it was used again. A not-found-exception occurred if the same destination was reused to create another producer or consumer after the queue or exchange was deleted. The fix now resets the address resolution flag when the queue or exchange is deleted. If the same exchange is re-used, it will go through address resolution again. If there is a directive to create the queue or exchange, it will be created. An error is thrown otherwise.
Clone Of:
Environment:
Last Closed: 2014-09-24 15:04:36 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
reproducer Java program (2.74 KB, application/octet-stream)
2012-08-06 12:54 UTC, Pavel Moravec
no flags Details
Simplified reproducer (2.24 KB, application/octet-stream)
2012-08-31 08:00 UTC, Pavel Moravec
no flags Details
patch proposal (756 bytes, patch)
2012-08-31 11:23 UTC, Pavel Moravec
no flags Details | Diff
Extended reproducer (5.01 KB, text/x-java)
2013-07-25 14:54 UTC, Ernie
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Apache JIRA QPID-4274 0 None None None 2012-08-31 11:29:05 UTC
Red Hat Product Errata RHEA-2014:1296 0 normal SHIPPED_LIVE Red Hat Enterprise MRG Messaging 3.0 Release 2014-09-24 19:00:06 UTC

Description Pavel Moravec 2012-08-06 12:54:20 UTC
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.

Comment 1 Pavel Moravec 2012-08-09 12:48:14 UTC
When moving:

Context ctx = new InitialContext(properties);

into the loop, no exception is raised.

Comment 2 Pavel Moravec 2012-08-31 07:39:58 UTC
When properties not loaded from JNDI file but set from code like:

Properties properties = new Properties();
properties.setProperty( .. )

then no exception is raised.

Comment 3 Pavel Moravec 2012-08-31 08:00:08 UTC
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)

Comment 4 Pavel Moravec 2012-08-31 11:23:11 UTC
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.

Comment 5 Rajith Attapattu 2013-03-07 22:40:15 UTC
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

Comment 6 Ernie 2013-07-25 14:54:09 UTC
Created attachment 778290 [details]
Extended reproducer

Reproducer now tests for 2nd creation of:
- queue consumer
- queue producer
- exchange consumer
- exchange producer

Comment 7 Ernie 2013-07-25 15:05:40 UTC
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

Comment 12 errata-xmlrpc 2014-09-24 15:04:36 UTC
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


Note You need to log in before you can comment on or make changes to this bug.