Python client is not sending arguments from messaging address correctly
-----------------------------------------------------------------------
Key: QPID-2964
URL: https://issues.apache.org/jira/browse/QPID-2964
Project: Qpid
Issue Type: Bug
Components: Python Client
Reporter: Jonathan Robie
The Python and C++ client libraries are sending arguments from messaging
addresses in different ways.
This is easily seen by comparing the C++ and Python implementations of drain,
using the same command line:
$ ./drain -f "xml; {link:{x-bindings:[{key:'weather',
arguments:{xquery:\"$(cat rdu.xquery )\"}}]}}"
Here are the steps needed to reconstruct:
1. Create XML exchange:
====================
$ ./qpid-config add exchange xml xml
2. Python client (the XML Exchange receives an empty query
====================================================
$ ./drain -f "xml; {link:{x-bindings:[{key:'weather', arguments:{xquery:\"$(cat
rdu.xquery )\"}}]}}"
Traceback (most recent call last):
File "./drain", line 81, in <module>
rcv = ssn.receiver(addr)
File "<string>", line 6, in receiver
File
"/home/jrobie/projects/qpid/pure/qpid/python/qpid/messaging/endpoints.py", line
603, in receiver
receiver._ewait(lambda: receiver.linked)
File
"/home/jrobie/projects/qpid/pure/qpid/python/qpid/messaging/endpoints.py", line
960, in _ewait
result = self.session._ewait(lambda: self.error or predicate(), timeout)
File
"/home/jrobie/projects/qpid/pure/qpid/python/qpid/messaging/endpoints.py", line
554, in _ewait
self.check_error()
File
"/home/jrobie/projects/qpid/pure/qpid/python/qpid/messaging/endpoints.py", line
543, in check_error
raise self.error
qpid.messaging.exceptions.ServerError: internal-error: Could not parse xquery:
(qpid/xml/XmlExchange.cpp:96)(541)
Broker output:
2010-11-26 10:31:23 trace qpid/amqp_0_10/Connection.cpp:57: RECV
[127.0.0.1:59898]: Frame[BEbe; channel=0; {ExchangeBindBody:
queue=36361426-3df6-49e2-b70e-7cb22ec24ec3:0.0; exchange=xml; }]
2010-11-26 10:31:23 trace qpid/SessionState.cpp:200:
anonymous.36361426-3df6-49e2-b70e-7cb22ec24ec3:0: recv cmd 3:
{ExchangeBindBody: queue=36361426-3df6-49e2-b70e-7cb22ec24ec3:0.0;
exchange=xml; } ##### note empty arguments - confirmed in debugger
2010-11-26 10:31:23 trace qpid/xml/XmlExchange.cpp:72: Creating binding with
query: ##### note that query is empty
2010-11-26 10:31:23 debug qpid/Exception.cpp:31: Exception constructed: Could
not parse xquery: (qpid/xml/XmlExchange.cpp:96)
2010-11-26 10:31:23 error qpid/amqp_0_10/SessionHandler.cpp:97: Execution
exception: internal-error: Could not parse xquery: (qpid/xml/XmlExchange.cpp:96)
2010-11-26 10:31:23 trace qpid/amqp_0_10/Connection.cpp:57: RECV
[127.0.0.1:59898]: Frame[BEbe; channel=0; {ExchangeBindBody:
queue=36361426-3df6-49e2-b70e-7cb22ec24ec3:0.0; exchange=xml;
binding-key=weather; arguments={xquery:V2:204:str16(let $w := ./weather return
$w/station = 'Raleigh-Durham International Airport (KRDU)' and $w/temperature_f
> 50 and $w/temperature_f - $w/dewpoint > 5 and $w/wind_speed_mph > 7 and
$w/wind_speed_mph < 20 )}; }] ##### Note that the query actually was sent to
the broker
2010-11-26 10:31:23 trace qpid/amqp_0_10/Connection.cpp:57: RECV
[127.0.0.1:59898]: Frame[BEbe; channel=0; {MessageSubscribeBody:
queue=36361426-3df6-49e2-b70e-7cb22ec24ec3:0.0; destination=0; accept-mode=0;
acquire-mode=0; }]
2010-11-26 10:31:23 trace qpid/amqp_0_10/Connection.cpp:57: RECV
[127.0.0.1:59898]: Frame[BEbe; channel=0; {MessageSetFlowModeBody:
destination=0; flow-mode=0; }]
2010-11-26 10:31:23 trace qpid/amqp_0_10/Connection.cpp:95: SENT
[127.0.0.1:59898]: Frame[BEbe; channel=0; {ExecutionExceptionBody:
error-code=541; command-id=3; class-code=7; command-code=4; field-index=0;
description=internal-error: Could not parse xquery:
(qpid/xml/XmlExchange.cpp:96); error-info={}; }]
2010-11-26 10:31:23 trace qpid/amqp_0_10/Connection.cpp:95: SENT
[127.0.0.1:59898]: Frame[BEbe; channel=0; {SessionDetachBody:
name=36361426-3df6-49e2-b70e-7cb22ec24ec3:0; }]
2010-11-26 10:31:23 trace qpid/amqp_0_10/Connection.cpp:57: RECV
[127.0.0.1:59898]: Frame[BEbe; channel=0; {SessionDetachedBody:
name=36361426-3df6-49e2-b70e-7cb22ec24ec3:0; }]
2010-11-26 10:31:23 debug qpid/broker/SessionState.cpp:120:
anonymous.36361426-3df6-49e2-b70e-7cb22ec24ec3:0: detached on broker.
Looking at the arguments in the broker:
Breakpoint 4, 0x00436e7c in
qpid::broker::SessionAdapter::ExchangeHandlerImpl::bind (this=0xb604238c,
queueName="reply-localhost.localdomain.20520.1", exchangeName="amq.direct",
routingKey="reply-localhost.localdomain.20520.1", arguments=...) at
../../cpp/src/qpid/broker/SessionAdapter.cpp:189
((gdb) p arguments
$2 = (const qpid::framing::FieldTable &) @0xb6044918: {values = std::map with 0
elements}
Compare to C++ client: (works as expected)
====================================
$ ./drain -f "xml; {link:{x-bindings:[{key:'weather',
arguments:{xquery:\"$(cat rdu.xquery )\"}}]}}"
Broker shows query is received and correctly parsed:
2010-11-25 13:19:53 trace ../../cpp/src/qpid/amqp_0_10/Connection.cpp:57: RECV
[127.0.0.1:47869]: Frame[BEbe; channel=1; {ExchangeBindBody:
queue=xml_26cb6be2-13dd-470d-a580-49398755c0f8; exchange=xml;
binding-key=weather; arguments={xquery:V2:204:vbin16(let $w := ./weather return
$w/station = 'Raleigh-Durham International Airport (KRDU)' and $w/temperature_f
> 50 and $w/temperature_f - $w/dewpoint > 5 and $w/wind_speed_mph > 7 and
$w/wind_speed_mph < 20 )}; }]
2010-11-25 13:19:53 trace ../../cpp/src/qpid/SessionState.cpp:200:
anonymous.63665982-bcce-496c-b33f-79c474b29a04: recv cmd 5: {ExchangeBindBody:
queue=xml_26cb6be2-13dd-470d-a580-49398755c0f8; exchange=xml;
binding-key=weather; arguments={xquery:V2:204:vbin16(let $w := ./weather return
$w/station = 'Raleigh-Durham International Airport (KRDU)' and $w/temperature_f
> 50 and $w/temperature_f - $w/dewpoint > 5 and $w/wind_speed_mph > 7 and
$w/wind_speed_mph < 20 )}; }
2010-11-25 13:19:53 trace ../../cpp/src/qpid/xml/XmlExchange.cpp:72: Creating
binding with query: let $w := ./weather return $w/station = 'Raleigh-Durham
International Airport (KRDU)' and $w/temperature_f > 50 and $w/temperature_f -
$w/dewpoint > 5 and $w/wind_speed_mph > 7 and $w/wind_speed_mph < 20
2010-11-25 13:19:53 trace ../../cpp/src/qpid/xml/XmlExchange.cpp:78: Bound
successfully with query: let $w := ./weather return $w/station =
'Raleigh-Durham International Airport (KRDU)' and $w/temperature_f > 50 and
$w/temperature_f - $w/dewpoint > 5 and $w/wind_speed_mph > 7 and
$w/wind_speed_mph < 20
2010-11-25 13:19:53 trace
../../cpp/src/qpid/management/ManagementAgent.cpp:373: SEND raiseEvent (v1)
class=org.apache.qpid.broker.bind
2010-11-25 13:19:53 debug ../../cpp/src/qpid/SessionState.cpp:214:
anonymous.63665982-bcce-496c-b33f-79c474b29a04: receiver marked completed: 5
incomplete: { } unknown-completed: { [0,5] }
Looking at the arguments in the debugger:
#2 0x00436e7c in qpid::broker::SessionAdapter::ExchangeHandlerImpl::bind
(this=0x8168bd4, queueName="xml-exchange_5cc7fe9f-8feb-41b1-9b56-6a7816e4498c",
exchangeName="xml-exchange", routingKey="weather", arguments=...) at
../../cpp/src/qpid/broker/SessionAdapter.cpp:189
(gdb) p arguments
$1 = (const qpid::framing::FieldTable &) @0x8145e88: {values = std::map with 1
elements = {["xquery"] = {px = 0x8115c30, pn = {pi_ = 0x8145f10}}}}
(gdb)
rdu.xquery:
===========
let $w := ./weather return $w/station = 'Raleigh-Durham International Airport
(KRDU)' and $w/temperature_f > 50 and $w/temperature_f - $w/dewpoint > 5 and
$w/wind_speed_mph > 7 and $w/wind_speed_mph < 20
rdu.xml:
===========
<weather>
<station>Raleigh-Durham International Airport (KRDU)</station>
<wind_speed_mph>16</wind_speed_mph>
<temperature_f>70</temperature_f>
<dewpoint>35</dewpoint>
</weather>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]