Bug 730977

Summary: java client fails to resolve target when assert is used in the address string
Product: Red Hat Enterprise MRG Reporter: Petr Matousek <pematous>
Component: qpid-javaAssignee: messaging-bugs <messaging-bugs>
Status: NEW --- QA Contact: MRG Quality Engineering <mrgqe-bugs>
Severity: high Docs Contact:
Priority: medium    
Version: 2.0CC: jross, mtoth, zkraus
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Petr Matousek 2011-08-16 12:57:44 UTC
Description of problem:

# java -cp $CLASSPATH org.apache.qpid.example.Spout "amq.direct; { assert: always, node: { type: topic }}"
{}
Exception in thread "main" javax.jms.JMSException: Error creating producer
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:681)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:82)
	at org.apache.qpid.client.AMQSession$6.execute(AMQSession.java:2599)
	at org.apache.qpid.client.AMQSession$6.execute(AMQSession.java:2594)
	at org.apache.qpid.client.AMQConnectionDelegate_0_10.executeRetrySupport(AMQConnectionDelegate_0_10.java:314)
	at org.apache.qpid.client.AMQConnection.executeRetrySupport(AMQConnection.java:622)
	at org.apache.qpid.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102)
	at org.apache.qpid.client.AMQSession.createProducerImpl(AMQSession.java:2592)
	at org.apache.qpid.client.AMQSession.createProducerImpl(AMQSession.java:2586)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:1199)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:120)
	at org.apache.qpid.example.Spout.<init>(Spout.java:91)
	at org.apache.qpid.example.Spout.main(Spout.java:146)
Caused by: org.apache.qpid.AMQException: Exception occured while verifying destination
	at org.apache.qpid.client.BasicMessageProducer_0_10.declareDestination(BasicMessageProducer_0_10.java:90)
	at org.apache.qpid.client.BasicMessageProducer.<init>(BasicMessageProducer.java:141)
	at org.apache.qpid.client.BasicMessageProducer_0_10.<init>(BasicMessageProducer_0_10.java:65)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:676)
	... 12 more
Caused by: org.apache.qpid.AMQException: The name 'amq.direct' supplied in the address doesn't resolve to an exchange or a queue
	at org.apache.qpid.client.AMQSession_0_10.handleAddressBasedDestination(AMQSession_0_10.java:1237)
	at org.apache.qpid.client.BasicMessageProducer_0_10.declareDestination(BasicMessageProducer_0_10.java:86)
	... 15 more

Note: Python, C++ clients do not suffer from that

Version-Release number of selected component (if applicable):
qpid-java-0.10-6

How reproducible:
100%

Steps to Reproduce:
1. java -cp $CLASSPATH org.apache.qpid.example.Spout "amq.direct; { assert: always, node: { type: topic }}"
2. got exception: The name 'amq.direct' supplied in the address doesn't resolve to an exchange or a queue
  
Actual results:
The target is not resolved when assert is used.

Expected results:
The target is successfully resolved when assert is used.

Additional info:

Comment 1 Michal Toth 2015-01-28 15:30:21 UTC
Hi Rajith, 
 we have found another wrong behavior in asserts and update to original bugzilla.

Update:
1) ./run_example.sh org.apache.qpid.example.Spout "amq.direct; { assert: always, node: { type: topic }}"
{}
Exception in thread "main" javax.jms.JMSException: Error creating producer
	at org.apache.qpid.client.AMQSession.toJMSException(AMQSession.java:3468)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:694)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:88)
	at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2593)
	at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2584)
	at org.apache.qpid.client.AMQConnectionDelegate_0_10.executeRetrySupport(AMQConnectionDelegate_0_10.java:371)
	at org.apache.qpid.client.AMQConnection.executeRetrySupport(AMQConnection.java:624)
	at org.apache.qpid.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102)
	at org.apache.qpid.client.AMQSession.createProducerImpl(AMQSession.java:2582)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:1164)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:98)
	at org.apache.qpid.example.Spout.<init>(Spout.java:91)
	at org.apache.qpid.example.Spout.main(Spout.java:147)
Caused by: org.apache.qpid.AMQException: Exception occured while verifying destination
	at org.apache.qpid.client.BasicMessageProducer_0_10.declareDestination(BasicMessageProducer_0_10.java:95)
	at org.apache.qpid.client.BasicMessageProducer.<init>(BasicMessageProducer.java:136)
	at org.apache.qpid.client.BasicMessageProducer_0_10.<init>(BasicMessageProducer_0_10.java:64)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:689)
	... 11 more
Caused by: org.apache.qpid.AMQException: Assert failed for address : 'amq.direct'/None; {
  'assert': 'always',
  'node': {
    'type': 'topic'
  }
}, Result was : ExchangeQueryResult(type=direct, durable=true, arguments={qpid.replicate=none})
	at org.apache.qpid.client.AMQSession_0_10.isExchangeExist(AMQSession_0_10.java:1122)
	at org.apache.qpid.client.AMQSession_0_10.resolveAddress(AMQSession_0_10.java:1252)
	at org.apache.qpid.client.BasicMessageProducer_0_10.declareDestination(BasicMessageProducer_0_10.java:89)
	... 14 more




When we assert a queue with provided queue arguments, java client ends with error code.
Steps to reproduce
1) qpid-config add queue my_q --argument qpid.auto_delete_timeout=30
2) java -cp $CLASSPATH  -Dlog4j.configuration=log4j.properties  org.apache.qpid.example.qc2_connector --broker localhost:5672 --connection-options "{  sasl_mechanisms : 'ANONYMOUS', protocol : 'amqp0-10' }"   -a "my_q;{'assert': 'always'}" --obj-ctrl CER

javax.jms.JMSException: Error registering consumer: org.apache.qpid.AMQException: Assert failed for address : 'my_q'/None; {
  'assert': 'always'
}, Result was : QueueQueryResult(queue=my_q, alternateExchange=, autoDelete=true, arguments={qpid.auto_delete_timeout=30}, messageCount=0, subscriberCount=0)
	at org.apache.qpid.client.AMQSession.toJMSException(AMQSession.java:3468)
	at org.apache.qpid.client.AMQSession$4.execute(AMQSession.java:2021)
	at org.apache.qpid.client.AMQSession$4.execute(AMQSession.java:1973)
	at org.apache.qpid.client.AMQConnectionDelegate_0_10.executeRetrySupport(AMQConnectionDelegate_0_10.java:371)
	at org.apache.qpid.client.AMQConnection.executeRetrySupport(AMQConnection.java:624)
	at org.apache.qpid.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102)
	at org.apache.qpid.client.AMQSession.createConsumerImpl(AMQSession.java:1971)
	at org.apache.qpid.client.AMQSession.createConsumer(AMQSession.java:939)
	at org.apache.qpid.example.qc2_connector.<init>(qc2_connector.java:223)
	at org.apache.qpid.example.qc2_connector.main(qc2_connector.java:283)
Caused by: org.apache.qpid.AMQException: Assert failed for address : 'my_q'/None; {
  'assert': 'always'
}, Result was : QueueQueryResult(queue=my_q, alternateExchange=, autoDelete=true, arguments={qpid.auto_delete_timeout=30}, messageCount=0, subscriberCount=0)
	at org.apache.qpid.client.AMQSession_0_10.isQueueExist(AMQSession_0_10.java:1150)
	at org.apache.qpid.client.AMQSession_0_10.resolveAddress(AMQSession_0_10.java:1236)
	at org.apache.qpid.client.AMQSession.registerConsumer(AMQSession.java:2842)
	at org.apache.qpid.client.AMQSession.access$400(AMQSession.java:98)
	at org.apache.qpid.client.AMQSession$4.execute(AMQSession.java:1998)
	... 8 more
javax.jms.JMSException: Error registering consumer: org.apache.qpid.AMQException: Assert failed for address : 'my_q'/None; {
  'assert': 'always'
}, Result was : QueueQueryResult(queue=my_q, alternateExchange=, autoDelete=true, arguments={qpid.auto_delete_timeout=30}, messageCount=0, subscriberCount=0)




or 2) using example clients
./run_example.sh org.apache.qpid.example.Spout "my_q; { assert: always}"
{}
Exception in thread "main" javax.jms.JMSException: Error creating producer
	at org.apache.qpid.client.AMQSession.toJMSException(AMQSession.java:3468)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:694)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:88)
	at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2593)
	at org.apache.qpid.client.AMQSession$7.execute(AMQSession.java:2584)
	at org.apache.qpid.client.AMQConnectionDelegate_0_10.executeRetrySupport(AMQConnectionDelegate_0_10.java:371)
	at org.apache.qpid.client.AMQConnection.executeRetrySupport(AMQConnection.java:624)
	at org.apache.qpid.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102)
	at org.apache.qpid.client.AMQSession.createProducerImpl(AMQSession.java:2582)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:1164)
	at org.apache.qpid.client.AMQSession.createProducer(AMQSession.java:98)
	at org.apache.qpid.example.Spout.<init>(Spout.java:91)
	at org.apache.qpid.example.Spout.main(Spout.java:147)
Caused by: org.apache.qpid.AMQException: Exception occured while verifying destination
	at org.apache.qpid.client.BasicMessageProducer_0_10.declareDestination(BasicMessageProducer_0_10.java:95)
	at org.apache.qpid.client.BasicMessageProducer.<init>(BasicMessageProducer.java:136)
	at org.apache.qpid.client.BasicMessageProducer_0_10.<init>(BasicMessageProducer_0_10.java:64)
	at org.apache.qpid.client.AMQSession_0_10.createMessageProducer(AMQSession_0_10.java:689)
	... 11 more
Caused by: org.apache.qpid.AMQException: Assert failed for address : 'my_q'/None; {
  'assert': 'always'
}, Result was : QueueQueryResult()
	at org.apache.qpid.client.AMQSession_0_10.isQueueExist(AMQSession_0_10.java:1150)
	at org.apache.qpid.client.AMQSession_0_10.resolveAddress(AMQSession_0_10.java:1236)
	at org.apache.qpid.client.BasicMessageProducer_0_10.declareDestination(BasicMessageProducer_0_10.java:89)
	... 14 more

Actual result:
Error is thrown

Expected result
Assert passes.











Tested with
qpid-java-example-0.22-8.el6.noarch
qpid-java-client-0.22-8.el6.noarch
qpid-java-common-0.22-8.el6.noarch