alanxz / SimpleAmqpClient

Simple C++ Interface to rabbitmq-c
MIT License
404 stars 213 forks source link

Asynchronous API support #83

Open asanand opened 10 years ago

asanand commented 10 years ago

I was wondering if there is plan to have asynchronous calls for different simpleamqpclient APIs.

alanxz commented 10 years ago

A while ago I put some thought into what it would take to add async support for messages delivered via consumer, (and other various other events). When I first wrote SimpleAmqpClient I did so to provide an easy-to-use interface when making synchronous RPC-style calls. I wasn't looking to get the best performance out of the protocol. With that constraint the internal bits of SimpleAmqpClient were architected in such a way to hide the async portions of the AMQP protocol.

To add the async bits back to SimpleAmqpClient would require rethinking the core of SimpleAmqpClient to run a thread internally to manage the rabbitmq-c structures, then all of the API calls would need to talk to this thread.

At the time I didn't see a whole lot of demand from users for this sort of feature, that said, if there is new demand maybe its time to re-think adding this feature to SimpleAmqpClient.

asanand commented 10 years ago

I see. we are looking for high performance, and use our cores to do some other operations instead of waiting for these synchronous calls. thread is an option, but if we get async support, that would be really great.

alanxz commented 10 years ago

Noted.

luca3m commented 10 years ago

Hi,

I would like an async API too. How do you think is better to implement it? Boost provides Boost::asio with asynchronous sockets. Is it a good option or rabbitmq-c has yet something to manage asynchrony?

alanxz commented 10 years ago

SimpleAmqpClient wraps rabbitmq-c and rabbitmq-c currently does nothing to provide a good interface to the asynchronous parts of the AMQP protocol.

Since SimpleAmqpClient doesn't use sockets directly, boost::asio would not be a good option to use with SimpleAmqpClient. Currently I believe the best way forward to get useable support for the asynchronous parts of AMQP is to do a bit of re-architecting of the rabbitmq-c library to support both the various methods available to do network-based async-IO, and provide a useable async API .

luca3m commented 10 years ago

I've read some more details about code of rabbitmq-c and SimpleAmqpClient, for me probably it's easier to use asio sockets and use rabbitmq-c only for protocol parsing.

I'm doing some other experiments and eventually I'll get back on this issue if somebody it's interested.

Vermillionaire commented 8 years ago

Did you come up with a solution for this? I'd like to have a consumer in a seperate thread, but it doesnt sound like it supports it.

luca3m commented 8 years ago

I used this library https://github.com/CopernicaMarketingSoftware/AMQP-CPP, no good luck but probably now it's better than two years ago.

alosya commented 8 years ago

Is there any progress on providing async support. We are trying to use simpleamqpclient for RPC purposes. Performance is not great. I really really like the simplicity nature of this client but, we need performance as well. Yes, async support would be wonderful.

alanxz commented 8 years ago

@alosya - are you concerned about performance in publishing messages or receiving messages?

grasevski commented 6 years ago

You can already consume asynchronously by setting timeout to 0 in BasicConsumeMessage. Async publish could be achieved by adding an async flag to BasicPublish and some pollable methods to Channel, eg IsPublished, GetNextConfirmation, etc.