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

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 

Recently uploaded (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 

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