Hello, community

Currently I have 2 Mojolicious applications. I want first application 
notify second application about some messages it receives. I decided, that 
RabbitMQ will be the best way to implement it, because RabbitMQ tool is 
widespread, it has monitoring features, it's fast and allow flexibility. 
But, I have some troubles to use RabbitMQ from mojolicious. There are 
clients to RabbitMQ that allow non-blocking mode, but due to company's 
coding standards I don't want to use unsupported client like 
AnyEvent::RabbitMQ. Now I have the following Idea:
1. I found a client https://github.com/markwellis/net-amqp-rabbitmq that 
has some support and has commits in a recently few months
2. Unfortunately, it's blocking.
3. But I can call method 'get' to get messages from RabbitMQ if they exist, 
or it will return undef, if there no messages
4. I want to emit event 'receiving' in IOLoop and call Rabbit's 'get' 
method. 
5. If there is a message I will emit 'received' event in IOLoop and then 
will be handle it in callback. 
6. After this handling I will emit 'receiving' again. 
7. If there are no messages in 'receiving' call, I will start IOLoop's 
timer to fire after 0.1 sec and emit 'receiving' in timer's callback
8. So, I will have the system, that works non-blocking, using blocking 
library (?)
9. But I will have some overhead when RabbitMQ is idle, and I will be check 
it every 0.1 sec. I think it's not a problem for me, because RabbitMQ 
always should have a load in production. I did measured, that idle 
Mojolicious in this 'receiving' mode don't consume much resources. Just a 
1-2% of CPU. But again, I think it really never will be idle. 

QUESTION: Do you see some pitfalls in this schema I have described? Is it 
OK?
QUESTION 2: Maybe some advices to use another configuration or instruments 
to achieve my goals? 

Thanks,
Dmitry

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to