qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Conway <acon...@redhat.com>
Subject Re: c++ messaging api: a map message example
Date Tue, 04 Aug 2009 20:23:06 GMT
On 07/31/2009 01:10 PM, Gordon Sim wrote:
> Attached is a patch for a higher level, protocol independent messaging
> api from c++ as last discussed some months ago. I have not had much time
> to spend on this since then and so there is not a huge amount of change
> (mainly moving to a better namespace and adjusting for the revised
> include directory layout).
>Looks good, overall I like the flow of the examples.

We shoudl ensure that Variant::Map and Variant::List provide the full 
std::map/sequence API.

	Message message;
         message.getContent()["id"] = 987654321;

Why does a message default to having a map content?  How about:

   Map map;
   map["id"] = ...

A map is a valuable data structure that deserves to exist independently of 
Message, and a Message
shouldn't be predjudiced towards one particular type of content. In particular 
there's no way to
implement getContent()[] if the message contains binary data.

         Variant::List colours;

We should make it simple & efficient to interop with std:: collections here, e.g.:

   std::vector<string> colours;
   map["colours"] = Variant::rangeList(colours);

Where rangeList returns a templated wrapper for a pair of iterators that can be 
into a map.


print functions: I think all our types including Variant and Map should have 
std::ostream op<<, I'd push
the print code into that and use << in the example. Also the type returned by 
getContent() should have
an ostream op so you can say:

         cout << message.getContent();


This looks messy:
         listener.subscribed(session.subscribe("message_queue", listener));

Informing the listener can be done as part of the implementation of 
session.subscribe(), it doesn't
need to be left to the user.

We need to sort out our threading model in this new API. The critical
thing is to allow many sessions to be served by the same thread or
thread pool pool. E.g. in TSX case it looks like it helps to have a
session per queue for large numbers of messages, but for small numbers
the excessive threading (with 4000 queues) makes performance much
worse. What you really want is 4000 sessions and a thread pool of
<number of cpus> threads that dispatch them all.

We also want to integrate that with our own client side poller, and of
course keep the current model for backwards compatibility.

How about providing two alternatives:
Session {
   void dispatch(); // Calling thread dispatches session.
   // OR
   void activate(); // Session is dispatched by qpid's own thread pool. Does not 
   void deactivate(); // Stop dispatching in qpid thread pool, blocks till 
current operation completes.
   void wait(); // Wait for activated session to be closed, or the last 
subscription to be cancelled.

I think that covers the majority of cases. The other case that has
been mentioned is providing a selectable fd to dispatch to qpid from
someone elses select/poll/epoll loop. I'd say that's an addition for
the 1.1 release of the new API, not necessarily for 1.0.

Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org

View raw message