Geeky.week3.rabbitmq

581 views

Published on

Published in: Technology, Self Improvement
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
581
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
8
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Geeky.week3.rabbitmq

  1. 1. RabbitMQ 3th WEEK SATURDAY, JULY 06, 2013 – SUNDAY, JULY 07, 2013 GEEK ACADEMY 2013
  2. 2. RABBITMQ GEEK ACADEMY 2013
  3. 3. MQ History 1985 1993 TIB IBM MQSeries RabbitMQ 2006
  4. 4. A B C D E Consumers Producers Broker Exchanges Queues F G H I J Bindings Channel Direct Exchange Fanout Exchange Topic Exchange KEY WORDS
  5. 5. 01. EXCHANGES Exchanges are where producers publish their messages. 02. QUEUES Queues are where the messages end up and are received by consumers. 03. BINDINDS Bindings are how the messages get routed from the exchange to particular queues AMQP ELEMENTS
  6. 6. CONSUMERS AND PRODUCERS 10 % 100 % 10 % 10% 10 % 10 % 10% NOT ABOUT ECONOMICS AM LP CM KM YH R M HT Producers create messages and publish (send) them to a broker server. Then the broker will determine who(consumers) should get a copy of messages. Message = Payload + Label
  7. 7. FLOWS MessageProducer Exchange QueueBinding Consumer
  8. 8. "lightweight connections that share a single TCP connection". CHANNELS What?
  9. 9. DEFAULT EXCHANGE producer broker consumer consumer consumer geeky2 geeky1 geeky3
  10. 10. Demo ConnectionFactory factory = new ConnectionFactory(); factory.setHost(RABBITMQ_HOST); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); boolean durable = true; channel.queueDeclare(queue, durable, false, isAutoDelete, null); Producer: o channel.basicPublish( "", queue, null, message.getBytes()); Consumer: o QueueingConsumer consumer = new QueueingConsumer(channel); o channel.basicConsume(queue, autoAck, consumer); o QueueingConsumer.Delivery delivery = consumer.nextDelivery(); o String message = new String(delivery.getBody());
  11. 11. DIRECT EXCHANGE producer broker consumer consumer geeky.jvm geeky.groovy geeky.jvm geeky.java
  12. 12. Demo ConnectionFactory factory = new ConnectionFactory(); factory.setHost(RABBITMQ_HOST); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.exchangeDeclare(EXCHANGE_NAME, "direct"); Producer: o channel.basicPublish( exchangeName, serevity, null, message.getBytes()); Consumer: o channel.queueBind(queueName, EXCHANGE_NAME, severity); o QueueingConsumer consumer = new QueueingConsumer(channel); o channel.basicConsume(queue, autoAck, consumer); o QueueingConsumer.Delivery delivery = consumer.nextDelivery(); o String message = new String(delivery.getBody());
  13. 13. FANOUT EXCHANGE producer broker consumer consumer consumer Hello geeky Hello geeky Hellogeeky
  14. 14. Demo ConnectionFactory factory = new ConnectionFactory(); factory.setHost(RABBITMQ_HOST); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.exchangeDeclare(EXCHANGE_NAME, "fanout"); Producer: o channel.basicPublish( EXCHANGE_NAME, "", null, message.getBytes()); Consumer: o String queueName = channel.queueDeclare().getQueue(); o channel.queueBind(queueName, EXCHANGE_NAME, ""); o QueueingConsumer consumer = new QueueingConsumer(channel); o channel.basicConsume(queue, isAck, consumer); o QueueingConsumer.Delivery delivery = consumer.nextDelivery(); o String message = new String(delivery.getBody());
  15. 15. TOPIC EXCHANGE producer broker consumer consumer consumer geeky.# *.java.* *.groovy.* *.*.spring
  16. 16. Demo ConnectionFactory factory = new ConnectionFactory(); factory.setHost(RABBITMQ_HOST); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); boolean durable = true; channel.exchangeDeclare(EXCHANGE_NAME, "topic"); Producer: o channel.basicPublish( EXCHANGE_NAME, routingKey, null, message.getBytes()); Consumer: o String queueName = channel.queueDeclare().getQueue(); o channel.queueBind(queueName, EXCHANGE_NAME, bindingKey); o QueueingConsumer consumer = new QueueingConsumer(channel); o channel.basicConsume(queue, isAck, consumer); o QueueingConsumer.Delivery delivery = consumer.nextDelivery(); o String message = new String(delivery.getBody());
  17. 17. Rabbitmqctl o rabbitmqctl start o rabbitmqctl stop o rabbitmqctl list_queues o rabbitmqctl list_exchanges o rabbitmqctl list_bindings o rabbitmqctl list_users o rabbitmqctl add_user [username] [password] o rabbitmqctl delete_user [username] o rabbitmqctl changepassword [username] [new password]
  18. 18. 01. http://www.springsource.org/spring-amqp 03.http://www.rabbitmq.com 04.http://hg.rabbitmq.com/rabbitmq-java-client/ READ MORE... 02.https://github.com/SpringSource/spring-amqp 05.https://github.com/up1/geeky_week3_demo
  19. 19. GEEK ACADEMY 2013
  20. 20. THANK YOU FOR YOUR TIME GEEK ACADEMY 2013

×