SlideShare a Scribd company logo
1 of 56
Download to read offline
Advanced Messaging with AMQP
 Dave Syer, SpringSource, 2011
Agenda
●   Overview of AMQP
●   Example use cases
●   What makes AMQP different?
●   Comparison with JMS
●   Spring AMQP
What is Messaging?




         What can I use Messaging for?
           How does AMQP help?
What is Messaging?




         What is a Messaging Protocol?
                 What is it not?
Messaging Use Cases


     Things a Message Broker Can Do
 ●   Work distribution
 ●   Pipelining
 ●   Store-and-forward of messages
 ●   Absorbing spikes of activity (again, decoupling)
 ●   Routing to different consumers based on message properties
Messaging Use Cases


     Patterns:
 ●   spatial decoupling (aka communication)
 ●   temporal decoupling (aka buffering)
 ●   logical decoupling (aka routing)
     Promote: flexibility, resilience, performance, and scale
     Conclusion: There is an enormous range of applications and
     problems to which messaging is an effective solution.
AMQP




   AMQP = Advanced Message Queueing
               Protocol
Why AMQP?


    AMQP is Especially Nice Because
●   All resources are dynamically created and destroyed by clients as
    they need them – no static pre-configuration
●   A clean and simple model: just three key nouns to learn
●   Open standard, developed by the AMQP Working Group (VMware is
    a member)
●   Lots of client libraries available in many languages, for free
●   An excellent, freely available, open source broker implementation,
    called RabbitMQ.
AMQP 101

Advanced != Complicated

             Create an exchange...



                       X


                   “my_exchange”
                   type = fanout
AMQP 101

Advanced != Complicated

              ...create a queue...



                       X


                   “my_exchange”     “my_queue”
                   type = fanout
AMQP 101

Advanced != Complicated

               ...add a binding...



                        X


                    “my_exchange”    “my_queue”
                    type = fanout
AMQP 101

Advanced != Complicated

             ...all inside a broker...



                        X


                    “my_exchange”    “my_queue”
                    type = fanout
AMQP 101

Advanced != Complicated

             ...publish a message...



                        X


                    “my_exchange”   “my_queue”
                    type = fanout
AMQP 101

Advanced != Complicated

            ...message sits in queue.



                        X


                    “my_exchange”   “my_queue”
                    type = fanout
AMQP 101

Advanced != Complicated

           Publish another message...



                        X


                    “my_exchange”   “my_queue”
                    type = fanout
AMQP 101

Advanced != Complicated

             ...it also sits in queue.



                         X


                     “my_exchange”   “my_queue”
                     type = fanout
AMQP 101

Advanced != Complicated

     Consumer retrieves messages in order...



                        X


                    “my_exchange”   “my_queue”
                    type = fanout
AMQP 101

Advanced != Complicated

     Consumer retrieves messages in order...



                        X


                    “my_exchange”   “my_queue”
                    type = fanout
AMQP 101

Advanced != Complicated
    With no binding, the message is discarded
         (producer can ask to be notified)


                        X


                    “my_exchange”   “my_queue”
                    type = fanout
AMQP 101

Advanced != Complicated

                     Publish several messages...
 E
     D
         C
             B
                 A
                              X


                          “my_exchange”   “my_queue”
                          type = fanout
AMQP 101

Advanced != Complicated
   and they are distributed amongst consumers
               on the same queue...

                                             D A
                    X                        E B

                                                C
                “my_exchange”   “my_queue”
                type = fanout
AMQP 101

Advanced != Complicated
     Let's create another queue and bind it to
               the same exchange...


                     X
                                 “my_queue”

                 “my_exchange”
                 type = fanout   “your_queue”
AMQP 101

Advanced != Complicated

            ..with a fanout exchange...


    B
        A
                    X
                                “my_queue”

                “my_exchange”
                type = fanout   “your_queue”
AMQP 101

Advanced != Complicated

       ..all messages go to every queue...



                   X                 B A
                               “my_queue”

               “my_exchange”         B A
               type = fanout   “your_queue”
AMQP 101

Advanced != Complicated

           ...and can be consumed...


                                              A
                   X                   B
                               “my_queue”

               “my_exchange”         B A
               type = fanout   “your_queue”
AMQP 101

Advanced != Complicated

              ...at different rates...


                                                 A
                   X                    B
                                “my_queue”

               “my_exchange”
               type = fanout    “your_queue”   B A
AMQP 101

Advanced != Complicated

 ...depending on the consumer, network and broker


                                               B A
                    X
                                “my_queue”

                “my_exchange”
                type = fanout   “your_queue”   B A
AMQP 101

Advanced != Complicated

  Let's change the exchange to be a direct type...



                     X
                                “my_queue”


                “my_exchange”   “your_queue”
                type = direct
AMQP 101

Advanced != Complicated

     ...then the bindings have to have a key...


                             bk = “vodka”
                         X
                             bk               “my_queue”
                                =   “be
                                        er”

                    “my_exchange”             “your_queue”
                    type = direct


     bk = Binding Key
AMQP 101

Advanced != Complicated

 ...and the messages have to have a routing key...

   rk = “vodka”

                              bk = “vodka”
                          X
                              bk               “my_queue”
                                 =   “be
                                         er”

                     “my_exchange”             “your_queue”
                     type = direct


      rk = Routing Key
      bk = Binding Key
AMQP 101

Advanced != Complicated
            ...a direct exchange matches the
               routing key to a binding key...
   rk = “beer”

                              bk = “vodka”
                          X
                              bk               “my_queue”
                                 =   “be
                                         er”

                     “my_exchange”             “your_queue”
                     type = direct


      rk = Routing Key
      bk = Binding Key
AMQP 101

Advanced != Complicated
           ...a direct exchange matches the
              routing key to a binding key...


                             bk = “vodka”
                         X
                             bk               “my_queue”
                                =   “be
                                        er”

                    “my_exchange”             “your_queue”
                    type = direct


     rk = Routing Key
     bk = Binding Key
AMQP 101

Advanced != Complicated

       ...messages with no matching binding...

   rk = “tequila”

                              bk = “vodka”
                          X
                              bk               “my_queue”
                                 =   “be
                                         er”

                     “my_exchange”             “your_queue”
                     type = direct


      rk = Routing Key
      bk = Binding Key
AMQP 101

Advanced != Complicated

                        ...are discarded


                              bk = “vodka”
                          X
                              bk               “my_queue”
                                 =   “be
                                         er”

                    “my_exchange”              “your_queue”
                    type = direct


     rk = Routing Key
     bk = Binding Key
AMQP 101

Advanced != Complicated

  Let's change the exchange to be a topic type...



                    X
                               “my_queue”


               “my_exchange”   “your_queue”
               type = topic
AMQP 101

Advanced != Complicated

           ...permits wildcard in bindings...


                             bk = “a.*.c”
                         X
                             bk              “my_queue”
                                =   “#.
                                        e”

                    “my_exchange”            “your_queue”
                    type = topic


     bk = Binding Key
AMQP 101

Advanced != Complicated
                Binding keys are period(.)-separated:
                   * matches 1 element
                   # matches 0 or more elements

rk = “a”         A                   bk = “a.*.c”
rk = “a.b”                       X
                 B                   bk
                                        =            “my_queue”
rk = “a.b.c”     C                          “#.
                                                e”
rk = “a.e”       D
                            “my_exchange”            “your_queue”
rk = “a.b.e”     E
                            type = topic


             rk = Routing Key
             bk = Binding Key
AMQP 101

Advanced != Complicated
                Binding keys are period(.)-separated:
                   * matches 1 element
                   # matches 0 or more elements

rk = “a”         X
                 A                   bk = “a.*.c”
rk = “a.b”                       X
                 B                   bk
                                        =            “my_queue”
rk = “a.b.c”     C                          “#.
                                                e”
rk = “a.e”       D
                            “my_exchange”            “your_queue”
rk = “a.b.e”     E
                            type = topic


             rk = Routing Key
             bk = Binding Key
AMQP 101

Advanced != Complicated
                Binding keys are period(.)-separated:
                   * matches 1 element
                   # matches 0 or more elements

                                     bk = “a.*.c”
rk = “a.b”                       X
                 B                   bk
                                        =            “my_queue”
rk = “a.b.c”     C                          “#.
                                                e”
rk = “a.e”       D
                            “my_exchange”            “your_queue”
rk = “a.b.e”     E
                            type = topic


             rk = Routing Key
             bk = Binding Key
AMQP 101

Advanced != Complicated
                Binding keys are period(.)-separated:
                   * matches 1 element
                   # matches 0 or more elements

                                     bk = “a.*.c”
                                 X
rk = “a.b”      X
                B                    bk              “my_queue”
rk = “a.b.c”                            =   “#.
                 C                              e”
rk = “a.e”       D
                            “my_exchange”            “your_queue”
rk = “a.b.e”     E
                            type = topic


             rk = Routing Key
             bk = Binding Key
AMQP 101

Advanced != Complicated
                Binding keys are period(.)-separated:
                   * matches 1 element
                   # matches 0 or more elements

                                     bk = “a.*.c”
                                 X
                                     bk              “my_queue”
rk = “a.b.c”                            =   “#.
                 C                              e”
rk = “a.e”       D
                            “my_exchange”            “your_queue”
rk = “a.b.e”     E
                            type = topic


             rk = Routing Key
             bk = Binding Key
AMQP 101

Advanced != Complicated
                Binding keys are period(.)-separated:
                   * matches 1 element
                   # matches 0 or more elements

                                     bk = “a.*.c”
                                 X                           C
                                     bk              “my_queue”
                                        =   “#.
                                                e”
rk = “a.e”       D
                            “my_exchange”            “your_queue”
rk = “a.b.e”     E
                            type = topic


             rk = Routing Key
             bk = Binding Key
AMQP 101

Advanced != Complicated
               Binding keys are period(.)-separated:
                  * matches 1 element
                  # matches 0 or more elements

                                   bk = “a.*.c”
                               X                           C
                                   bk              “my_queue”
                                      =   “#.
                                              e”
                                                            D
                          “my_exchange”            “your_queue”
rk = “a.b.e”   E
                          type = topic


           rk = Routing Key
           bk = Binding Key
AMQP 101

Advanced != Complicated
           Binding keys are period(.)-separated:
              * matches 1 element
              # matches 0 or more elements

                             bk = “a.*.c”
                         X                           C
                             bk              “my_queue”
                                =   “#.
                                        e”
                                                   E D
                    “my_exchange”            “your_queue”
                    type = topic


     rk = Routing Key
     bk = Binding Key
Other Stuff the AMQP Broker Does

Yes, all the standard things
 ●   Errors can be raised for messages that do not get routed to any
     queues
 ●   Messages can be consumed so that the broker does not forget about
     the message until the client explicitly acknowledges the message
 ●   Messages can be published with a property indicating whether the
     message should be written to disk
 ●   Transactions: making publication and acknowledgement of several
     messages atomic
 ●   Flow control: e.g. used to stop publishers from overwhelming the
     broker in extreme situations
Conclusion: Why AMQP?

An Open Protocol has some advantages...
 ●   Makes it easier to have multiple implementations that interoperate at
     the wire-level
 ●   Avoids vendor lock-in: easy to rip out and replace individual
     components with alternative implementations
 ●   Allows third-parties to write client libraries for other languages
 ●   Decouples flag-day upgrades for both client libraries and broker
 ●   Allows third-party traffic analysis tools to inspect and decode
     interactions between the clients and brokers
 ●   Promotes similarities in APIs presented by different client libraries
Introducing RabbitMQ

RabbitMQ, AMQP and Messaging
 ●   RabbitMQ consists of the broker (server) and several clients
 ●   (Java, .Net, plus others)
 ●   They speak the AMQP protocol to each other
 ●   Anyone can write (and many have) other clients which also speak
     AMQP and work with RabbitMQ
 ●   RabbitMQ is freely available and open source, licensed under the
     Mozilla Public License v1.1
 ●   It’s already in many popular Linux distributions (Ubuntu, Debian,
     Fedora, Gentoo) and can be easily installed on OS X both through
     MacPorts and Homebrew
AMQP and JMS




     How does AMQP compare to JMS?
     When would I use one or the other?
AMQP and JMS



 AMQP                                     JMS
 Protocol                                 API
 No language                              Java
 Industry committee, mainly finance       JEE
 Interoperability from client libraries   Interoperability from proprietary
                                          features
 Resources can be managed by clients Resources often centrally managed
 Not ubiquitous in enterprise             Ubiquitous through JEE
 Flexible usage patterns, emphasise       Two basic producer patterns (Queue
 routing                                  and Topic)
 Designed for large numbers of            Hard to manage large numbers of
 queues and exchanges                     Destinations
AMQP and JMS

 JMS
 • standard in the Java space
 • lots of open source options
 • provided with Java EE application servers
 • Spring JMS

                  Java producers          Message broker   Java consumers


                                                             C
                          P             queue

                                                             C

                          P             queue
                                                             C
JMS

 Sending JMS Messages
    • Inject an instance of Spring's JmsTemplate.
    • Provide the JMS ConnectionFactory in the JmsTemplate bean definition.
@Component
public class MessageSender {
    @Autowired
    private volatile JmsTemplate jmsTemplate;

    public void send(String message) {
      this.jmsTemplate.convertAndSend("example.queue", message);
    }
                               @Bean public ConnnectionFactory cf (){
}                                 return new CachingConnectionFactory(...);
                               }
                               @Bean public JmsTemplate template(){
                                 return new JmsTemplate(this.cf()) ;
                               }
AMQP and JMS

●
      AMQP
    • real standard
    • a product of the the companies with the most mission critical requirements
 • Spring AMQP
AMQP producers          exchanges         Message broker              AMQP consumers


                                                                              C
              P               X          queue

                                                                             C

              P               X         queue
                                                                              C
Spring AMQP

 ●   Java and .NET
 ●   AMQP core abstraction plus RabbitMQ implementation (built on
     rabbit client libraries)
 ●   Higher level patterns for clients: admin, producers and consumers
     ●   ConnectionFactory – extra abstraction on top of Rabbit client (e.g. for re-
         connection)
     ●   RabbitAdmin – declare exchanges, queues, bindings
     ●   RabbitTemplate – convenience methods for send and receive
     ●   MessageListenerContainer – POJO message handler, asynchronous
 ●   Spring Integration support
     http://www.springsource.org/spring-amqp
Spring AMQP: RabbitTemplate



public class MyComponent {
  private RabbitTemplate rabbitTemplate;

    public MyComponent(ConnectionFactory connectionFactory) {
      this.rabbitTemplate = new RabbitTemplate(connectionFactory);
    }

    public void read() throws Exception {
       ...
      String value = rabbitTemplate.receiveAndConvert("myQueueName");
      ...
    }

}
                                               Convenience methods
Spring AMQP: SimpleMessageListenerContainer

 ●   Asynchronous message receiver
 ●   POJO handlers
 ●   Handles re-connection and listener failure (rollback, redelivery)
 ●   Message conversion and error handling strategies


<listener-container connection-factory="connectionFactory">
 <listener ref="handler" method="handle" queue-names="my.queue">
</listener-container>
Q&A

More Related Content

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Recently uploaded (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Featured

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

AMQP Messaging Guide

  • 1. Advanced Messaging with AMQP Dave Syer, SpringSource, 2011
  • 2. Agenda ● Overview of AMQP ● Example use cases ● What makes AMQP different? ● Comparison with JMS ● Spring AMQP
  • 3. What is Messaging? What can I use Messaging for? How does AMQP help?
  • 4. What is Messaging? What is a Messaging Protocol? What is it not?
  • 5. Messaging Use Cases Things a Message Broker Can Do ● Work distribution ● Pipelining ● Store-and-forward of messages ● Absorbing spikes of activity (again, decoupling) ● Routing to different consumers based on message properties
  • 6. Messaging Use Cases Patterns: ● spatial decoupling (aka communication) ● temporal decoupling (aka buffering) ● logical decoupling (aka routing) Promote: flexibility, resilience, performance, and scale Conclusion: There is an enormous range of applications and problems to which messaging is an effective solution.
  • 7. AMQP AMQP = Advanced Message Queueing Protocol
  • 8. Why AMQP? AMQP is Especially Nice Because ● All resources are dynamically created and destroyed by clients as they need them – no static pre-configuration ● A clean and simple model: just three key nouns to learn ● Open standard, developed by the AMQP Working Group (VMware is a member) ● Lots of client libraries available in many languages, for free ● An excellent, freely available, open source broker implementation, called RabbitMQ.
  • 9. AMQP 101 Advanced != Complicated Create an exchange... X “my_exchange” type = fanout
  • 10. AMQP 101 Advanced != Complicated ...create a queue... X “my_exchange” “my_queue” type = fanout
  • 11. AMQP 101 Advanced != Complicated ...add a binding... X “my_exchange” “my_queue” type = fanout
  • 12. AMQP 101 Advanced != Complicated ...all inside a broker... X “my_exchange” “my_queue” type = fanout
  • 13. AMQP 101 Advanced != Complicated ...publish a message... X “my_exchange” “my_queue” type = fanout
  • 14. AMQP 101 Advanced != Complicated ...message sits in queue. X “my_exchange” “my_queue” type = fanout
  • 15. AMQP 101 Advanced != Complicated Publish another message... X “my_exchange” “my_queue” type = fanout
  • 16. AMQP 101 Advanced != Complicated ...it also sits in queue. X “my_exchange” “my_queue” type = fanout
  • 17. AMQP 101 Advanced != Complicated Consumer retrieves messages in order... X “my_exchange” “my_queue” type = fanout
  • 18. AMQP 101 Advanced != Complicated Consumer retrieves messages in order... X “my_exchange” “my_queue” type = fanout
  • 19. AMQP 101 Advanced != Complicated With no binding, the message is discarded (producer can ask to be notified) X “my_exchange” “my_queue” type = fanout
  • 20. AMQP 101 Advanced != Complicated Publish several messages... E D C B A X “my_exchange” “my_queue” type = fanout
  • 21. AMQP 101 Advanced != Complicated and they are distributed amongst consumers on the same queue... D A X E B C “my_exchange” “my_queue” type = fanout
  • 22. AMQP 101 Advanced != Complicated Let's create another queue and bind it to the same exchange... X “my_queue” “my_exchange” type = fanout “your_queue”
  • 23. AMQP 101 Advanced != Complicated ..with a fanout exchange... B A X “my_queue” “my_exchange” type = fanout “your_queue”
  • 24. AMQP 101 Advanced != Complicated ..all messages go to every queue... X B A “my_queue” “my_exchange” B A type = fanout “your_queue”
  • 25. AMQP 101 Advanced != Complicated ...and can be consumed... A X B “my_queue” “my_exchange” B A type = fanout “your_queue”
  • 26. AMQP 101 Advanced != Complicated ...at different rates... A X B “my_queue” “my_exchange” type = fanout “your_queue” B A
  • 27. AMQP 101 Advanced != Complicated ...depending on the consumer, network and broker B A X “my_queue” “my_exchange” type = fanout “your_queue” B A
  • 28. AMQP 101 Advanced != Complicated Let's change the exchange to be a direct type... X “my_queue” “my_exchange” “your_queue” type = direct
  • 29. AMQP 101 Advanced != Complicated ...then the bindings have to have a key... bk = “vodka” X bk “my_queue” = “be er” “my_exchange” “your_queue” type = direct bk = Binding Key
  • 30. AMQP 101 Advanced != Complicated ...and the messages have to have a routing key... rk = “vodka” bk = “vodka” X bk “my_queue” = “be er” “my_exchange” “your_queue” type = direct rk = Routing Key bk = Binding Key
  • 31. AMQP 101 Advanced != Complicated ...a direct exchange matches the routing key to a binding key... rk = “beer” bk = “vodka” X bk “my_queue” = “be er” “my_exchange” “your_queue” type = direct rk = Routing Key bk = Binding Key
  • 32. AMQP 101 Advanced != Complicated ...a direct exchange matches the routing key to a binding key... bk = “vodka” X bk “my_queue” = “be er” “my_exchange” “your_queue” type = direct rk = Routing Key bk = Binding Key
  • 33. AMQP 101 Advanced != Complicated ...messages with no matching binding... rk = “tequila” bk = “vodka” X bk “my_queue” = “be er” “my_exchange” “your_queue” type = direct rk = Routing Key bk = Binding Key
  • 34. AMQP 101 Advanced != Complicated ...are discarded bk = “vodka” X bk “my_queue” = “be er” “my_exchange” “your_queue” type = direct rk = Routing Key bk = Binding Key
  • 35. AMQP 101 Advanced != Complicated Let's change the exchange to be a topic type... X “my_queue” “my_exchange” “your_queue” type = topic
  • 36. AMQP 101 Advanced != Complicated ...permits wildcard in bindings... bk = “a.*.c” X bk “my_queue” = “#. e” “my_exchange” “your_queue” type = topic bk = Binding Key
  • 37. AMQP 101 Advanced != Complicated Binding keys are period(.)-separated: * matches 1 element # matches 0 or more elements rk = “a” A bk = “a.*.c” rk = “a.b” X B bk = “my_queue” rk = “a.b.c” C “#. e” rk = “a.e” D “my_exchange” “your_queue” rk = “a.b.e” E type = topic rk = Routing Key bk = Binding Key
  • 38. AMQP 101 Advanced != Complicated Binding keys are period(.)-separated: * matches 1 element # matches 0 or more elements rk = “a” X A bk = “a.*.c” rk = “a.b” X B bk = “my_queue” rk = “a.b.c” C “#. e” rk = “a.e” D “my_exchange” “your_queue” rk = “a.b.e” E type = topic rk = Routing Key bk = Binding Key
  • 39. AMQP 101 Advanced != Complicated Binding keys are period(.)-separated: * matches 1 element # matches 0 or more elements bk = “a.*.c” rk = “a.b” X B bk = “my_queue” rk = “a.b.c” C “#. e” rk = “a.e” D “my_exchange” “your_queue” rk = “a.b.e” E type = topic rk = Routing Key bk = Binding Key
  • 40. AMQP 101 Advanced != Complicated Binding keys are period(.)-separated: * matches 1 element # matches 0 or more elements bk = “a.*.c” X rk = “a.b” X B bk “my_queue” rk = “a.b.c” = “#. C e” rk = “a.e” D “my_exchange” “your_queue” rk = “a.b.e” E type = topic rk = Routing Key bk = Binding Key
  • 41. AMQP 101 Advanced != Complicated Binding keys are period(.)-separated: * matches 1 element # matches 0 or more elements bk = “a.*.c” X bk “my_queue” rk = “a.b.c” = “#. C e” rk = “a.e” D “my_exchange” “your_queue” rk = “a.b.e” E type = topic rk = Routing Key bk = Binding Key
  • 42. AMQP 101 Advanced != Complicated Binding keys are period(.)-separated: * matches 1 element # matches 0 or more elements bk = “a.*.c” X C bk “my_queue” = “#. e” rk = “a.e” D “my_exchange” “your_queue” rk = “a.b.e” E type = topic rk = Routing Key bk = Binding Key
  • 43. AMQP 101 Advanced != Complicated Binding keys are period(.)-separated: * matches 1 element # matches 0 or more elements bk = “a.*.c” X C bk “my_queue” = “#. e” D “my_exchange” “your_queue” rk = “a.b.e” E type = topic rk = Routing Key bk = Binding Key
  • 44. AMQP 101 Advanced != Complicated Binding keys are period(.)-separated: * matches 1 element # matches 0 or more elements bk = “a.*.c” X C bk “my_queue” = “#. e” E D “my_exchange” “your_queue” type = topic rk = Routing Key bk = Binding Key
  • 45. Other Stuff the AMQP Broker Does Yes, all the standard things ● Errors can be raised for messages that do not get routed to any queues ● Messages can be consumed so that the broker does not forget about the message until the client explicitly acknowledges the message ● Messages can be published with a property indicating whether the message should be written to disk ● Transactions: making publication and acknowledgement of several messages atomic ● Flow control: e.g. used to stop publishers from overwhelming the broker in extreme situations
  • 46. Conclusion: Why AMQP? An Open Protocol has some advantages... ● Makes it easier to have multiple implementations that interoperate at the wire-level ● Avoids vendor lock-in: easy to rip out and replace individual components with alternative implementations ● Allows third-parties to write client libraries for other languages ● Decouples flag-day upgrades for both client libraries and broker ● Allows third-party traffic analysis tools to inspect and decode interactions between the clients and brokers ● Promotes similarities in APIs presented by different client libraries
  • 47. Introducing RabbitMQ RabbitMQ, AMQP and Messaging ● RabbitMQ consists of the broker (server) and several clients ● (Java, .Net, plus others) ● They speak the AMQP protocol to each other ● Anyone can write (and many have) other clients which also speak AMQP and work with RabbitMQ ● RabbitMQ is freely available and open source, licensed under the Mozilla Public License v1.1 ● It’s already in many popular Linux distributions (Ubuntu, Debian, Fedora, Gentoo) and can be easily installed on OS X both through MacPorts and Homebrew
  • 48. AMQP and JMS How does AMQP compare to JMS? When would I use one or the other?
  • 49. AMQP and JMS AMQP JMS Protocol API No language Java Industry committee, mainly finance JEE Interoperability from client libraries Interoperability from proprietary features Resources can be managed by clients Resources often centrally managed Not ubiquitous in enterprise Ubiquitous through JEE Flexible usage patterns, emphasise Two basic producer patterns (Queue routing and Topic) Designed for large numbers of Hard to manage large numbers of queues and exchanges Destinations
  • 50. AMQP and JMS  JMS • standard in the Java space • lots of open source options • provided with Java EE application servers • Spring JMS Java producers Message broker Java consumers C P queue C P queue C
  • 51. JMS  Sending JMS Messages • Inject an instance of Spring's JmsTemplate. • Provide the JMS ConnectionFactory in the JmsTemplate bean definition. @Component public class MessageSender { @Autowired private volatile JmsTemplate jmsTemplate; public void send(String message) { this.jmsTemplate.convertAndSend("example.queue", message); } @Bean public ConnnectionFactory cf (){ } return new CachingConnectionFactory(...); } @Bean public JmsTemplate template(){ return new JmsTemplate(this.cf()) ; }
  • 52. AMQP and JMS ● AMQP • real standard • a product of the the companies with the most mission critical requirements • Spring AMQP AMQP producers exchanges Message broker AMQP consumers C P X queue C P X queue C
  • 53. Spring AMQP ● Java and .NET ● AMQP core abstraction plus RabbitMQ implementation (built on rabbit client libraries) ● Higher level patterns for clients: admin, producers and consumers ● ConnectionFactory – extra abstraction on top of Rabbit client (e.g. for re- connection) ● RabbitAdmin – declare exchanges, queues, bindings ● RabbitTemplate – convenience methods for send and receive ● MessageListenerContainer – POJO message handler, asynchronous ● Spring Integration support http://www.springsource.org/spring-amqp
  • 54. Spring AMQP: RabbitTemplate public class MyComponent { private RabbitTemplate rabbitTemplate; public MyComponent(ConnectionFactory connectionFactory) { this.rabbitTemplate = new RabbitTemplate(connectionFactory); } public void read() throws Exception { ... String value = rabbitTemplate.receiveAndConvert("myQueueName"); ... } } Convenience methods
  • 55. Spring AMQP: SimpleMessageListenerContainer ● Asynchronous message receiver ● POJO handlers ● Handles re-connection and listener failure (rollback, redelivery) ● Message conversion and error handling strategies <listener-container connection-factory="connectionFactory"> <listener ref="handler" method="handle" queue-names="my.queue"> </listener-container>
  • 56. Q&A