This page last changed on Mar 09, 2009 by jonathan.robie@redhat.com.
This page compares C++ and Python code samples from our examples, looking for arbitrary discrepancies in the API. I suggest that we add proposals to fix these discrepancies inline for each example.
Opening and closing connections and sessions
C++
Python
Discrepancies
- Python uses a socket object, not needed in the C++ API. I suggest that Python follow C++ here.
- Python requires the user to provide a UUID instead of creating one for him. I suggest that Python provide the UUID automagically, as does C++.
- Our Python examples end by closing the session, our C++ examples end by closing the connection. If both APIs allow both approaches, we should fix the examples; if not, we should make the APIs consistent.
Subscribing to a Queue
C++
Python
Discrepancies
- C++ local queues are created as standalone objects, then subscribed. Python retrieves a local queue from the server using the session.incoming() method.
- Python starts delivery using the local queue's start() method. C++ begins delivery using the SubscriptionManger.run() or Session.run() method.
- Naming: Python calls the method "message_subscribe", which corresponds to the AMQP name, but it's odd naming: it does not subscribe to a message, nor does it subscribe a message to anything else.
Setting Delivery Properties, Message Properties
C++
Python
Discrepancies
- Python requires the programmer to create the delivery property object for a new message using a session object. That seems strange - it would be better to create it using the message, since it pertains to a message's delivery properties.
- This same discrepancy affects message properties
SubscriptionManager
Discrepancies
- Python does not have a SubscriptionManager. This would be very useful once Python supports async mode.
Message Listeners
C++
Python
Discrepancies
- In Python, a message handler is registered with a local queue, and the local queue is subscribed to the remote queue. In C+, a message listener is subscribed to using a Session or a Subscription Manager. I prefer the C+ approach here.
Synchronous / Asynchronous Modes
Discrepancies
- C++ supports both synchronous and asynchronous modes. Python supports only synchronous mode. Python should support both.
Getting and Setting Message Contents
C++
Python
Discrepancies
- C++ calls this "message data" and accesses it via methods, Python calls it the message body and provides direct access. They are completely different
Other issues
- Both languages should support streaming data into and out of messages
- The C++ interface has consistently confused people who work with binary data
Getting and Setting Application Headers
C++
Python
Discrepancies
- Different data model. C++ has a message, which has headers. Python has a message, which has message properties, including application headers.
- Python supports via a dictionary, which is very nice. Can I do this in C++?
|