Friday, March 1, 2013

RabbitMQ

Broker
Publisher --> Exchanges binding to Queues --> Consumers

Default
Direct Exchange
Fanout
Topic
Headers

Direct exchange is often used to distribute tasks between workers but messages are load balanced between consumers and not between queues.

Messages can be persistent but this is per message and not related to whether the queue is durable or not.

Message attributes, content type, encoding, routing key, delivery mode, message priority, message publishing timestamp, expiration period, …

When does the Broker remove messages from the queue?
After broker sends a message to an application (using either basic.deliver or basic.get-ok AMQP methods)
After the application sends back an acknowledgement (using basic.ack AMQP method)
In the above statement if the message fails to deliver aka an acknowledgement was not received the message can be requeued and delivered to another consumer.


Remember with Queues you cannot redeclare a queue with different attributes other you will get a channel level exception code 406 (PRECONDITION_FAILED)

Channels in AMQP are "lightweight connections that share a single TCP connection", nice way to share between threads.

hcp125:~ randy$ rabbitmqctl list_exchanges
Listing exchanges ...
direct
acmeExchange direct
amq.direct direct
amq.fanout fanout
amq.headers headers
amq.match headers
amq.rabbitmq.log topic
amq.rabbitmq.trace topic
amq.topic topic
...done.
dhcp125:~ randy$ rabbitmqadmin delete exchange name=acmeExchange
exchange deleted
dhcp125:~ randy$ rabbitmqadmin delete queue name=mathQueue

AMQP is extensible

Declaration of exchanges and queues can include additional attributes that the broker can use. For example, per-queue message TTL in RabbitMQ is implemented this way.


Two interesting reads on Rabbit Performance
http://www.rabbitmq.com/blog/2012/04/17/rabbitmq-performance-measurements-part-1/
http://www.rabbitmq.com/blog/2012/04/25/rabbitmq-performance-measurements-part-2/

No comments:

Post a Comment