SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
Messaging Approaches in Java
        (JMS, AMQP)

         Kirill Afanasjev




              Jug.lv
           Riga,Latvia
Why Messaging?

   1. Start sending binary data with TCP
   2. Add queueing
   3. Add networking abstraction
   4. Add authentification and ACL
   5. Add virtual connections
   6. Add high avalaibility
   7. Add publish/subscribe
   8. Result would be very similar :)
RPC

   CORBA, SOAP Web Services, RMI, XML-RPC
   Synchronous
   Tight coupling
Message oriented middleware

   Sender and receiver know nothing about each
    other, only destination and message format
   Email is for people what messaging is for
    applications
Advantages

   Asynchronous
    A client does not have to request messages in
    order to receive them
    Sender can fire and forget the message to the
    broker
   Reliable
    It is possible to guarantee message is delivered
    safely once and only once
Disadvantages

   Extra component in architecture (message
    transfer agent or message broker)
   Inter-application communication tend to be
    synchronous
   Lack of standarts
Point-to-point
Point-to-point

   Message queues, senders and receivers
   Message is sent to a queue
   Each message has only one consumer
   Queue may be configured to persist messages
   May be used for load balancing
Publish-subscribe
Publish-subscribe

   Publishers, subscribers, topics
   Message may have multiple consumers, or no
    consumer at all
   Each message is delivered to every client
    subscribed to a topic
JMS

   Java Message Oriented Middleware API
   Part of the Java EE
   Defined in specification developed under JSR
    914
   RFC 6167 defines a jms: URI scheme
   JMS 1.0.2b (June 25, 2001)
   JMS 1.1 (March 18, 2002)
   JMS 2 - ?
JMS architecture

   JMS provider (example : ActiveMQ)
   JMS clients
   Messages
   Administered objects (Destinations and
    connection factories)
   Native clients
JMS API

   ConnectionFactory
   Connection
   Session
   Message producer
   Message producer
   Destination
    - Queue
    - Topic
   Message
JMS API
JMS message

   Header
   Properties (optional)
   Body (optional)
JMS message headers
   JMSCorrelationId - (String) This header is set
    by the application for use by other applications.
   JMSDestination
   JMSDeliveryMode - (Integer) This header is set
    by the JMS provider and denotes the delivery
    mode.
   JMSExpiration
JMS message headers

   JMSPriority - (Integer) The priority of the
    message.
   JMSMessageId
   JMSTimestamp - (Long) The time the message
    was sent.
   JMSReplyTo
   JMSType
   JMSRedelivered
JMS message delivery modes

   DeliveryMode.NON_PERSISTENT
   DeliveryMode.PERSISTENT
JMS message selector

   Message consumer receives only messages
    whose headers and properties match the
    selector
   A message selector cannot select messages
    on the basis of content of the message body
JMS provider implementations
   Apache ActiveMQ
   Apache Qpid, using AMQP
   EMS from TIBCO
   OpenJMS, from The OpenJMS Group
   JBoss Messaging and HornetQ from JBoss
   Open Message Queue, from Sun Microsystems
   BEA Weblogic and Oracle AQ from Oracle
   RabbitMQ, using AMQP
   Solace JMS from Solace Systems
   SonicMQ from Progress Software
   StormMQ, using AMQP
   WebSphere MQ (formerly MQSeries) from IBM
Spring JMS support

   Message-driven POJOs
   MessageConverter, to convert between Java
    objects and JMS messages
   JMSTemplate
Sending message with Spring
public class JmsQueueSender {
    private JmsTemplate jmsTemplate;
    private Queue queue;
    public void simpleSend() {
        this.jmsTemplate.send(this.queue, new MessageCreator(){
              public Message createMessage(Session session) {
                  return session.createTextMessage("hello queue world");
              }
        });
    }
}
Receiving message with Spring

 public class ExampleListener implements MessageListener {
     public void onMessage(Message message) {
         if (message instanceof TextMessage) {
             System.out.println(((TextMessage) message).getText());
         }
     }
 }
Apache ActiveMQ

   Open source JMS 1.1 message broker
   Clustering
   Multiple message stores
   TCP, UDP, NIO, SSL, VM connectivity
   OpenWire API for high performance
   Stomp API for easier implementation
   REST API
   Can be used as in-memory JMS provider
Why AMQP, not JMS?

   Bound to Java
   Other protocols (STOMP, e.t.c) do not offer all
    the functionality of the broker
   Single standart for interoperability of brokers
    (AMQP is Protocol, not API)
Why JMS, not AMQP

   More implementations
   Better support in Java world
   Being an API allows for custom protocol
    implementations (VM connector)
AMQP

   Open standart protocol
   Support in all major languages
   Binary wire protocol (JMS defines API only)
   1.0 version of protocol published 07 Oct 2011
AMQP protocol

   Defines how clients and brokers talk
   Data serialization, heartbeat
   Hidden inside client libraries
AMQP model

   Message broker - server
   User
   Connection – physical connection
   Channel – logical connection
   Exchanges – named entities, to which
    messages are sent (may be durable or not)
   Queues – names entities, that store received
    messages (may be exclusive)
AMQP model




   P - producer
   X - exchange
   C - consumer
AMQP model




   P/C – producer/consumer
   Ch – channel
   Conn – connection
   X - exchange
AMQP message

   Header + content body
   Immediate – message will be handled as
    unroutable if there is no client waiting for it
   Expiration
   Priority
   Delivery mode
AMQP bindings

   Relationship between one queue and one
    exchange
   Unconditional
   Conditional on fixed string
   Conditional on pattern match
   Conditional on content inspection
   Conditional on algorithmic comparison
Fanout exchange
   1:N message delivery pattern
   Bind a queue to the exchange and messages
    sent to that exchange get delivered to all the
    bound queues
Direct exchange

   Queue binds to exchange
    with string key
   Publisher sends message
    with key




   Message is passed to the
    queue only if keys are equal
AMQP working group
   Bank of America, N.A.
   Barclays Bank PLC
   Cisco Systems, Inc.
   Credit Suisse
   Goldman Sachs
   JPMorgan Chase Bank & Co.
   Microsoft Corporation
   Novell
   Progress Software
   Red Hat, Inc.
   Software AG
   VMware, Inc.
AMQP in Java world
   Grails plug in
   Java client
   Scala / Lift support
   Spring AMQP project 1.0.0.RELEASE
    (http://www.springsource.org/spring-amqp)
Spring AMQP project

   Similar to Spring JMS support
   AMQPTemplate
   MessageListener
   Transactions
   e.t.c
Apache QPID

   JMS interface for AMQP
   Message broker implemented in Java
   Version 0.12 :(
AMQP future

   ActiveMQ, HornetQ, e.t.c has plans to support
    AMQP
   1.0 version?
RabbitMQ

   Leading implementation of AMQP
   Developed by SpringSource division of Vmware
   Full range of commercial support services
   Implemented in Erlang
   Clustering built-in
RabbitMQ performance

   We use it for login data processing
   Each user login in game = 1 message to the
    queue
   Performance depends on
    persistence/transactions enabled
   At 20k 1-kilobyte persistent messages per
    second with sub-millisecond latency RabbitMQ
    was far from being a bottleneck
Book to read

   Hohpe, Gregor; Bobby
    Woolf (2003).
    Enterprise Integration
    Patterns: Designing,
    Building, and Deploying
    Messaging Solutions.
    ISBN 0-321-20068-3.
Book to read

   ActiveMQ in Action
    Bruce Snyder, Dejan
    Bosanac and Rob
    Davies
    ISBN 1933988940
Book to read

   RabbitMQ in Action
    Alvaro Videla and
    Jason J.W. Williams
    ISBN:
    9781935182979
Questions?

   ?

Contenu connexe

Tendances

JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging ServicePeter R. Egli
 
Enterprise Messaging with Apache ActiveMQ
Enterprise Messaging with Apache ActiveMQEnterprise Messaging with Apache ActiveMQ
Enterprise Messaging with Apache ActiveMQelliando dias
 
JMS Introduction
JMS IntroductionJMS Introduction
JMS IntroductionAlex Su
 
Keynote: Idiomatic RabbitMQ - Gavin M Roy
Keynote: Idiomatic RabbitMQ - Gavin M RoyKeynote: Idiomatic RabbitMQ - Gavin M Roy
Keynote: Idiomatic RabbitMQ - Gavin M RoyRabbitMQ Summit
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSBruce Snyder
 
Message Queue (MQ) Testing
Message Queue (MQ) TestingMessage Queue (MQ) Testing
Message Queue (MQ) TestingUjjwal Gupta
 
Easy enterprise application integration with RabbitMQ and AMQP
Easy enterprise application integration with RabbitMQ and AMQPEasy enterprise application integration with RabbitMQ and AMQP
Easy enterprise application integration with RabbitMQ and AMQPRabbit MQ
 
Jms deep dive [con4864]
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]Ryan Cuprak
 
RabbitMQ and AMQP with .net client library
RabbitMQ and AMQP with .net client libraryRabbitMQ and AMQP with .net client library
RabbitMQ and AMQP with .net client libraryMohammed Shaban
 
Websphere MQ admin guide
Websphere MQ admin guideWebsphere MQ admin guide
Websphere MQ admin guideRam Babu
 
Rabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging PatternsRabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging PatternsJavier Arias Losada
 
Rabbitmq & Kafka Presentation
Rabbitmq & Kafka PresentationRabbitmq & Kafka Presentation
Rabbitmq & Kafka PresentationEmre Gündoğdu
 
Ibm websphere mq
Ibm websphere mqIbm websphere mq
Ibm websphere mqRakeshtoodi
 

Tendances (20)

Spring JMS
Spring JMSSpring JMS
Spring JMS
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging Service
 
Differences between JMS and AMQP
Differences between JMS and AMQPDifferences between JMS and AMQP
Differences between JMS and AMQP
 
Enterprise Messaging with Apache ActiveMQ
Enterprise Messaging with Apache ActiveMQEnterprise Messaging with Apache ActiveMQ
Enterprise Messaging with Apache ActiveMQ
 
JMS
JMSJMS
JMS
 
JMS Introduction
JMS IntroductionJMS Introduction
JMS Introduction
 
Jms
JmsJms
Jms
 
Keynote: Idiomatic RabbitMQ - Gavin M Roy
Keynote: Idiomatic RabbitMQ - Gavin M RoyKeynote: Idiomatic RabbitMQ - Gavin M Roy
Keynote: Idiomatic RabbitMQ - Gavin M Roy
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMSEnterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMS
 
Message Queue (MQ) Testing
Message Queue (MQ) TestingMessage Queue (MQ) Testing
Message Queue (MQ) Testing
 
Jms
JmsJms
Jms
 
Jms
JmsJms
Jms
 
Easy enterprise application integration with RabbitMQ and AMQP
Easy enterprise application integration with RabbitMQ and AMQPEasy enterprise application integration with RabbitMQ and AMQP
Easy enterprise application integration with RabbitMQ and AMQP
 
Jms deep dive [con4864]
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]
 
RabbitMQ and AMQP with .net client library
RabbitMQ and AMQP with .net client libraryRabbitMQ and AMQP with .net client library
RabbitMQ and AMQP with .net client library
 
Websphere MQ admin guide
Websphere MQ admin guideWebsphere MQ admin guide
Websphere MQ admin guide
 
Rabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging PatternsRabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging Patterns
 
WebSphere MQ introduction
WebSphere MQ introductionWebSphere MQ introduction
WebSphere MQ introduction
 
Rabbitmq & Kafka Presentation
Rabbitmq & Kafka PresentationRabbitmq & Kafka Presentation
Rabbitmq & Kafka Presentation
 
Ibm websphere mq
Ibm websphere mqIbm websphere mq
Ibm websphere mq
 

Similaire à Messaging in Java

ActiveMQ interview Questions and Answers
ActiveMQ interview Questions and AnswersActiveMQ interview Questions and Answers
ActiveMQ interview Questions and Answersjeetendra mandal
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging QueuesNaukri.com
 
An Introduction to the Message Queuning Technology
An Introduction to the Message Queuning TechnologyAn Introduction to the Message Queuning Technology
An Introduction to the Message Queuning TechnologyHarinath Krishnamoorthy
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQJames Carr
 
WSO2 Product Release Webinar Introducing the WSO2 Message Broker
WSO2 Product Release Webinar   Introducing the WSO2 Message BrokerWSO2 Product Release Webinar   Introducing the WSO2 Message Broker
WSO2 Product Release Webinar Introducing the WSO2 Message BrokerWSO2
 
The Art of Message Queues - TEKX
The Art of Message Queues - TEKXThe Art of Message Queues - TEKX
The Art of Message Queues - TEKXMike Willbanks
 
Elegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache CamelElegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache CamelPradeep Elankumaran
 
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...StreamNative
 
Using the JMS 2.0 API with Apache Pulsar - Pulsar Virtual Summit Europe 2021
Using the JMS 2.0 API with Apache Pulsar - Pulsar Virtual Summit Europe 2021Using the JMS 2.0 API with Apache Pulsar - Pulsar Virtual Summit Europe 2021
Using the JMS 2.0 API with Apache Pulsar - Pulsar Virtual Summit Europe 2021StreamNative
 
Jms introduction
Jms introductionJms introduction
Jms introductionBui Kiet
 
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure FunctionsMessaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure FunctionsJohn Staveley
 
Ranker jms implementation
Ranker jms implementationRanker jms implementation
Ranker jms implementationEosSoftware
 

Similaire à Messaging in Java (20)

ActiveMQ interview Questions and Answers
ActiveMQ interview Questions and AnswersActiveMQ interview Questions and Answers
ActiveMQ interview Questions and Answers
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues
 
An Introduction to the Message Queuning Technology
An Introduction to the Message Queuning TechnologyAn Introduction to the Message Queuning Technology
An Introduction to the Message Queuning Technology
 
Jms intro
Jms introJms intro
Jms intro
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQHigh powered messaging with RabbitMQ
High powered messaging with RabbitMQ
 
WSO2 Product Release Webinar Introducing the WSO2 Message Broker
WSO2 Product Release Webinar   Introducing the WSO2 Message BrokerWSO2 Product Release Webinar   Introducing the WSO2 Message Broker
WSO2 Product Release Webinar Introducing the WSO2 Message Broker
 
The Art of Message Queues - TEKX
The Art of Message Queues - TEKXThe Art of Message Queues - TEKX
The Art of Message Queues - TEKX
 
Elegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache CamelElegant Systems Integration w/ Apache Camel
Elegant Systems Integration w/ Apache Camel
 
IBM MQ vs Apache ActiveMQ
IBM MQ vs Apache ActiveMQIBM MQ vs Apache ActiveMQ
IBM MQ vs Apache ActiveMQ
 
Jms
JmsJms
Jms
 
Riding with camel
Riding with camelRiding with camel
Riding with camel
 
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
 
Using the JMS 2.0 API with Apache Pulsar - Pulsar Virtual Summit Europe 2021
Using the JMS 2.0 API with Apache Pulsar - Pulsar Virtual Summit Europe 2021Using the JMS 2.0 API with Apache Pulsar - Pulsar Virtual Summit Europe 2021
Using the JMS 2.0 API with Apache Pulsar - Pulsar Virtual Summit Europe 2021
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Jms introduction
Jms introductionJms introduction
Jms introduction
 
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure FunctionsMessaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
 
ppt
pptppt
ppt
 
ppt
pptppt
ppt
 
Ranker jms implementation
Ranker jms implementationRanker jms implementation
Ranker jms implementation
 

Plus de Dmitry Buzdin

How Payment Cards Really Work?
How Payment Cards Really Work?How Payment Cards Really Work?
How Payment Cards Really Work?Dmitry Buzdin
 
Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Dmitry Buzdin
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?Dmitry Buzdin
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?Dmitry Buzdin
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDmitry Buzdin
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureDmitry Buzdin
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIsDmitry Buzdin
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахDmitry Buzdin
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fmDmitry Buzdin
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIDmitry Buzdin
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsDmitry Buzdin
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional ProgrammingDmitry Buzdin
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contestDmitry Buzdin
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery Dmitry Buzdin
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOpsDmitry Buzdin
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump AnalysisDmitry Buzdin
 

Plus de Dmitry Buzdin (20)

How Payment Cards Really Work?
How Payment Cards Really Work?How Payment Cards Really Work?
How Payment Cards Really Work?
 
Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop Infrastructure
 
JOOQ and Flyway
JOOQ and FlywayJOOQ and Flyway
JOOQ and Flyway
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
 
Whats New in Java 8
Whats New in Java 8Whats New in Java 8
Whats New in Java 8
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на Одноклассниках
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fm
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part II
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching Solutions
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contest
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump Analysis
 

Dernier

Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Patrick Viafore
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGDSC PJATK
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfFIDO Alliance
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024TopCSSGallery
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101vincent683379
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 

Dernier (20)

Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 

Messaging in Java

  • 1. Messaging Approaches in Java (JMS, AMQP) Kirill Afanasjev Jug.lv Riga,Latvia
  • 2. Why Messaging?  1. Start sending binary data with TCP  2. Add queueing  3. Add networking abstraction  4. Add authentification and ACL  5. Add virtual connections  6. Add high avalaibility  7. Add publish/subscribe  8. Result would be very similar :)
  • 3. RPC  CORBA, SOAP Web Services, RMI, XML-RPC  Synchronous  Tight coupling
  • 4. Message oriented middleware  Sender and receiver know nothing about each other, only destination and message format  Email is for people what messaging is for applications
  • 5. Advantages  Asynchronous A client does not have to request messages in order to receive them Sender can fire and forget the message to the broker  Reliable It is possible to guarantee message is delivered safely once and only once
  • 6. Disadvantages  Extra component in architecture (message transfer agent or message broker)  Inter-application communication tend to be synchronous  Lack of standarts
  • 8. Point-to-point  Message queues, senders and receivers  Message is sent to a queue  Each message has only one consumer  Queue may be configured to persist messages  May be used for load balancing
  • 10. Publish-subscribe  Publishers, subscribers, topics  Message may have multiple consumers, or no consumer at all  Each message is delivered to every client subscribed to a topic
  • 11. JMS  Java Message Oriented Middleware API  Part of the Java EE  Defined in specification developed under JSR 914  RFC 6167 defines a jms: URI scheme  JMS 1.0.2b (June 25, 2001)  JMS 1.1 (March 18, 2002)  JMS 2 - ?
  • 12. JMS architecture  JMS provider (example : ActiveMQ)  JMS clients  Messages  Administered objects (Destinations and connection factories)  Native clients
  • 13. JMS API  ConnectionFactory  Connection  Session  Message producer  Message producer  Destination - Queue - Topic  Message
  • 15. JMS message  Header  Properties (optional)  Body (optional)
  • 16. JMS message headers  JMSCorrelationId - (String) This header is set by the application for use by other applications.  JMSDestination  JMSDeliveryMode - (Integer) This header is set by the JMS provider and denotes the delivery mode.  JMSExpiration
  • 17. JMS message headers  JMSPriority - (Integer) The priority of the message.  JMSMessageId  JMSTimestamp - (Long) The time the message was sent.  JMSReplyTo  JMSType  JMSRedelivered
  • 18. JMS message delivery modes  DeliveryMode.NON_PERSISTENT  DeliveryMode.PERSISTENT
  • 19. JMS message selector  Message consumer receives only messages whose headers and properties match the selector  A message selector cannot select messages on the basis of content of the message body
  • 20. JMS provider implementations  Apache ActiveMQ  Apache Qpid, using AMQP  EMS from TIBCO  OpenJMS, from The OpenJMS Group  JBoss Messaging and HornetQ from JBoss  Open Message Queue, from Sun Microsystems  BEA Weblogic and Oracle AQ from Oracle  RabbitMQ, using AMQP  Solace JMS from Solace Systems  SonicMQ from Progress Software  StormMQ, using AMQP  WebSphere MQ (formerly MQSeries) from IBM
  • 21. Spring JMS support  Message-driven POJOs  MessageConverter, to convert between Java objects and JMS messages  JMSTemplate
  • 22. Sending message with Spring public class JmsQueueSender { private JmsTemplate jmsTemplate; private Queue queue; public void simpleSend() { this.jmsTemplate.send(this.queue, new MessageCreator(){ public Message createMessage(Session session) { return session.createTextMessage("hello queue world"); } }); } }
  • 23. Receiving message with Spring public class ExampleListener implements MessageListener { public void onMessage(Message message) { if (message instanceof TextMessage) { System.out.println(((TextMessage) message).getText()); } } }
  • 24. Apache ActiveMQ  Open source JMS 1.1 message broker  Clustering  Multiple message stores  TCP, UDP, NIO, SSL, VM connectivity  OpenWire API for high performance  Stomp API for easier implementation  REST API  Can be used as in-memory JMS provider
  • 25. Why AMQP, not JMS?  Bound to Java  Other protocols (STOMP, e.t.c) do not offer all the functionality of the broker  Single standart for interoperability of brokers (AMQP is Protocol, not API)
  • 26. Why JMS, not AMQP  More implementations  Better support in Java world  Being an API allows for custom protocol implementations (VM connector)
  • 27. AMQP  Open standart protocol  Support in all major languages  Binary wire protocol (JMS defines API only)  1.0 version of protocol published 07 Oct 2011
  • 28. AMQP protocol  Defines how clients and brokers talk  Data serialization, heartbeat  Hidden inside client libraries
  • 29. AMQP model  Message broker - server  User  Connection – physical connection  Channel – logical connection  Exchanges – named entities, to which messages are sent (may be durable or not)  Queues – names entities, that store received messages (may be exclusive)
  • 30. AMQP model  P - producer  X - exchange  C - consumer
  • 31. AMQP model  P/C – producer/consumer  Ch – channel  Conn – connection  X - exchange
  • 32. AMQP message  Header + content body  Immediate – message will be handled as unroutable if there is no client waiting for it  Expiration  Priority  Delivery mode
  • 33. AMQP bindings  Relationship between one queue and one exchange  Unconditional  Conditional on fixed string  Conditional on pattern match  Conditional on content inspection  Conditional on algorithmic comparison
  • 34. Fanout exchange  1:N message delivery pattern  Bind a queue to the exchange and messages sent to that exchange get delivered to all the bound queues
  • 35. Direct exchange  Queue binds to exchange with string key  Publisher sends message with key  Message is passed to the queue only if keys are equal
  • 36. AMQP working group  Bank of America, N.A.  Barclays Bank PLC  Cisco Systems, Inc.  Credit Suisse  Goldman Sachs  JPMorgan Chase Bank & Co.  Microsoft Corporation  Novell  Progress Software  Red Hat, Inc.  Software AG  VMware, Inc.
  • 37. AMQP in Java world  Grails plug in  Java client  Scala / Lift support  Spring AMQP project 1.0.0.RELEASE (http://www.springsource.org/spring-amqp)
  • 38. Spring AMQP project  Similar to Spring JMS support  AMQPTemplate  MessageListener  Transactions  e.t.c
  • 39. Apache QPID  JMS interface for AMQP  Message broker implemented in Java  Version 0.12 :(
  • 40. AMQP future  ActiveMQ, HornetQ, e.t.c has plans to support AMQP  1.0 version?
  • 41. RabbitMQ  Leading implementation of AMQP  Developed by SpringSource division of Vmware  Full range of commercial support services  Implemented in Erlang  Clustering built-in
  • 42. RabbitMQ performance  We use it for login data processing  Each user login in game = 1 message to the queue  Performance depends on persistence/transactions enabled  At 20k 1-kilobyte persistent messages per second with sub-millisecond latency RabbitMQ was far from being a bottleneck
  • 43. Book to read  Hohpe, Gregor; Bobby Woolf (2003). Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions. ISBN 0-321-20068-3.
  • 44. Book to read  ActiveMQ in Action Bruce Snyder, Dejan Bosanac and Rob Davies ISBN 1933988940
  • 45. Book to read  RabbitMQ in Action Alvaro Videla and Jason J.W. Williams ISBN: 9781935182979