You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Alan Conway (JIRA)" <qp...@incubator.apache.org> on 2010/03/17 22:07:27 UTC
[jira] Created: (QPID-2451) Add support for MessageListener
callback objects in new messaging API
Add support for MessageListener callback objects in new messaging API
---------------------------------------------------------------------
Key: QPID-2451
URL: https://issues.apache.org/jira/browse/QPID-2451
Project: Qpid
Issue Type: New Feature
Components: C++ Client
Reporter: Alan Conway
Assignee: Alan Conway
The old C++ client API allows the use to register an object derived from MessageListener as a callback to receive messages from the subscriptions associated with a session. The user can start a thread for each session to dispatch callbacks.
We need a callback API for the new messaging API. The new API should allow the user to create a thread pool to dispatch to any number of sessions rather than requiring a thread per session. Note the pool model does also support thread-per-session by creating a pool of size 1 for each session.
--
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:dev-subscribe@qpid.apache.org
[jira] Commented: (QPID-2451) Add support for MessageListener
callback objects in new messaging API
Posted by "Alan Conway (JIRA)" <qp...@incubator.apache.org>.
[ https://issues.apache.org/jira/browse/QPID-2451?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12847066#action_12847066 ]
Alan Conway commented on QPID-2451:
-----------------------------------
An alternative API proposal. This is slightly more low level but still should be easy to use, and it provides greater flexibility. This doesn't directly support MessageListeners, but does support a thread pool polling a set of sessions and dispatching messages. A MessageListener solution like the one above can be implemented in terms of a SessionPoller.
Currently there is only one event type to poll for - session has messages. The interface reserves a set of flags to allow us to add support for multiple event types in a binary compatible way.
namespace qpid {
namespace messaging {
class Session;
struct PollerStopped : public Exception {
QPID_CLIENT_EXTERN PollerStopped(const std::string&);
};
/**
* Poll a group of sessions waiting for messages.
*
* Thread safe: can be used to implement a thread group dispatching a
* set of sessions by starting multiple threads each calling wait() in
* a loop.
*/
class SessionPoller {
public:
/**
* Add a session for polling. A session may only be in one poller
* at a time.
*
*@param session Session to be added.
*@param flags Ignored, reserved for future use.
*@exception PollerStopped The poller is stopped.
*/
QPID_CLIENT_EXTERN void add(const Session& session, int flags=0);
/** Remove a session from the poller. */
QPID_CLIENT_EXTERN void remove(const Session&);
/**
* Wait up to timeout for a session with messages. The returned
* session is automatically removed from the poller, call add() to
* put it back.
*
*@param session Out paramemter, set to the session.
*@param timeout Maximum time to wait for a session before returning.
*@return True if session has been set, false if the call timed out.
*@exception PollerStopped The poller was stopped.
*/
QPID_CLIENT_EXTERN bool wait(Session& session, Duration timeout=INFINITE_DURATION);
/**
* Stop the poller. Threads blocked in wait() will be thrown PollerStopped.
* Once stopped a poller cannot be re-started.
*/
QPID_CLIENT_EXTERN void stop();
};
}} // qpid::messaging
#endif /*!QPID_MESSAGING_SESSIONPOLLER_H*/
> Add support for MessageListener callback objects in new messaging API
> ---------------------------------------------------------------------
>
> Key: QPID-2451
> URL: https://issues.apache.org/jira/browse/QPID-2451
> Project: Qpid
> Issue Type: New Feature
> Components: C++ Client
> Reporter: Alan Conway
> Assignee: Alan Conway
>
> The old C++ client API allows the use to register an object derived from MessageListener as a callback to receive messages from the subscriptions associated with a session. The user can start a thread for each session to dispatch callbacks.
> We need a callback API for the new messaging API. The new API should allow the user to create a thread pool to dispatch to any number of sessions rather than requiring a thread per session. Note the pool model does also support thread-per-session by creating a pool of size 1 for each session.
--
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:dev-subscribe@qpid.apache.org
[jira] Updated: (QPID-2451) Multi-threaded dispatch support for the
new API.
Posted by "Alan Conway (JIRA)" <qp...@incubator.apache.org>.
[ https://issues.apache.org/jira/browse/QPID-2451?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alan Conway updated QPID-2451:
------------------------------
Summary: Multi-threaded dispatch support for the new API. (was: Add support for MessageListener callback objects in new messaging API)
> Multi-threaded dispatch support for the new API.
> ------------------------------------------------
>
> Key: QPID-2451
> URL: https://issues.apache.org/jira/browse/QPID-2451
> Project: Qpid
> Issue Type: New Feature
> Components: C++ Client
> Reporter: Alan Conway
> Assignee: Alan Conway
>
> The old C++ client API allows the use to register an object derived from MessageListener as a callback to receive messages from the subscriptions associated with a session. The user can start a thread for each session to dispatch callbacks.
> We need a callback API for the new messaging API. The new API should allow the user to create a thread pool to dispatch to any number of sessions rather than requiring a thread per session. Note the pool model does also support thread-per-session by creating a pool of size 1 for each session.
--
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:dev-subscribe@qpid.apache.org
[jira] Commented: (QPID-2451) Add support for MessageListener
callback objects in new messaging API
Posted by "Alan Conway (JIRA)" <qp...@incubator.apache.org>.
[ https://issues.apache.org/jira/browse/QPID-2451?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12846587#action_12846587 ]
Alan Conway commented on QPID-2451:
-----------------------------------
This is the proposed API, in the messaging namespace:
The message::MessageListener interface is the same as client::MessageListener
/**
* A group of threads that dispatch messages to MessageListener
* objects provided by the user.
*
* Messages from the same session will be dispatched sequentially.
* Messages from different sessions may be dispatched concurrently in
* separate threads.
*/
ListenerThreads {
struct BadReceiver : qpid::Exception {
QPID_CLIENT_EXTERN BadReceiver(const std::string&);
};
struct BadSession : qpid::Exception {
QPID_CLIENT_EXTERN BadSession(const std::string&);
};
/** Create ListenerThreads instance with n dispatch threads started. */
QPID_CLIENT_EXTERN ListenerThreads(unsigned n=0);
/** Stop all dispatch threads. */
QPID_CLIENT_EXTERN ~ListenerThreads();
/**
* Register a listener. The listener's receive() function will be
* called with messages received by the Receiver. The
* listener must not be destroyed while it is in use, @see
* forget()
*
*@param listener User implementation object to receive messages.
*@param receiver Messages received by this Receiver are passed to the listener.
*@exception BadReceiver The Receiver is already associated with a listener.
*@exception BadSession The Receiver's session is already associated
* with a different ListenerThreads instance
*/
void QPID_CLIENT_EXTERN listen(MessageListener& listener, Receiver& receiver);
/**
* Forget about the listener. No more messages will be delivered to it
* it can safely be destroyed.
*/
void QPID_CLIENT_EXTERN forget(listener);
/** Start n dispatch threads. */
void QPID_CLIENT_EXTERN start(unsigned n);
/** Stop n dispatch threads or all threads if n >= size() */
void QPID_CLIENT_EXTERN stop(unsigned n);
/**@return The number of dispatch threads currently running. */
unsigned QPID_CLIENT_EXTERN size();
};
> Add support for MessageListener callback objects in new messaging API
> ---------------------------------------------------------------------
>
> Key: QPID-2451
> URL: https://issues.apache.org/jira/browse/QPID-2451
> Project: Qpid
> Issue Type: New Feature
> Components: C++ Client
> Reporter: Alan Conway
> Assignee: Alan Conway
>
> The old C++ client API allows the use to register an object derived from MessageListener as a callback to receive messages from the subscriptions associated with a session. The user can start a thread for each session to dispatch callbacks.
> We need a callback API for the new messaging API. The new API should allow the user to create a thread pool to dispatch to any number of sessions rather than requiring a thread per session. Note the pool model does also support thread-per-session by creating a pool of size 1 for each session.
--
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:dev-subscribe@qpid.apache.org