SlideShare une entreprise Scribd logo
1  sur  26
1 /
Messaging Frameworks
Arvind KumarGS
2 /
Agenda
●What is Messaging?
●Why is it important?
●Messaging Fundamentals
●Messaging Protocols
●JMS Domains
●Message consumption
●JMS API
●Building Robust JMS Applications
3 /
What is Messaging
●Messaging is process of communication between two or more disparate
systems.
●Consider two legacy systems that are information silos. One system has
information about allemployees and financesin company ABC. Another
company does auditing for ABC, requires information about the employees and
financesof ABC.
●Messaging can be used for communication between these two systems.
4 /
Whyis it important
●Messaging is a technology that enables high-speed, asynchronous, atomic,
program-to-program communication with reliable delivery.
●Messaging provides fault tolerance and load-balancingcapabilities.
●Messaging can be easily integrated into different heterogeneous systems.
●Messaging allows communication between two loosely coupled systems.
5 /
Messaging Fundamentals
●Messaging capabilities are provided by a separate software system called
messaging system or MOM (Message-oriented middleware).
●A messaging system manages messaging the way a database system manager
data persistence.
●Similar to how a db admin must populate the db with the schema, a messaging
system admin must configure the channels that define the paths of
communication between the applications.
6 /
Messaging Fundamentals
7 /
Messaging protocols
●AMQP : Advanced message queuing protocol. It defines the protocol of
messages, so different clients like RabbitMQ, ActiveMQ (5.8 onwards),
StormMQ.
●JMS: Java Message Service is a Java API that allows applications to create, send,
receive, and read messages. Designed by Sun and several partner companies,
the JMS API defines a common set of interfaces and associated semantics.
8 /
JMS Domains –Point to Point
●Point-to-Point Messaging Domain
–Eachmessage is addressed to a specific queue.
–Receiving clients extract messages from the queues.
–Eachmessage hasonlyone consumer.
–Receiver acknowledges succcessful processing of message.
9 /
JMS Domains –Publish/Subscribe
●Publish/Subscribe Messaging Domain
–clients address messages to a topic, which functions somewhat like abulletin
board.
–Publishers and subscribers can dynamically publish or subscribe to the
content hierarchy.
–System takescare of distributing the messages arriving from a topic’s multiple
publishers to its multiple subscribers.
10/
JMS Domains - Publish/Subscribe
●Eachmessage can have multiple consumers.
●Topics retain messages only aslong as it takes to distribute them to current
subscribers.
●A client that subscribes to a topic canconsume onlymessages published after
the client hascreated a subscription, and the subscriber must continue to be
active in order for it to consume messages.
11/
Messageconsumption
●Synchronously: A subscriber or a receiver explicitlyfetches the message from
the destination by callingthe receive method. The receive method can block
until amessage arrives or can time out if a message does not arrive withina
specified time limit.
●Asynchronously: A client canregister a message listener with a consumer.
Whenever a message arrives at the destination, the JMS provider delivers the
message by calling the listener’s onMessage method, which acts on the
contents of the message.
12/
JMS API
●JMS clients accessobjects like Connection Factory and Destinations through
interfaces that are portable, so no change isnecessary between different
implementations of JMS API.
13/
JMS API
●A connection factory is the object a client uses to create a connection to a
provider.
●A destination is the object a client uses to specify the target of messages it
produces and the source of messages it consumes.
●A connection encapsulates a virtual connection with a JMS provider.
●When you have a ConnectionFactory object, you can use it to create a
Connection:
●Connection connection = connectionFactory.createConnection();
14/
JMS API
●A sessionis a single-threaded context for producing and consuming messages.
You use sessions to create the following:
●Message producers
●Message consumers
●Messages
●Queue browsers
15/
JMS API
●After you create a Connection object, you use it to create a Session:
●Session session = connection.createSession(false,
●Session.AUTO_ACKNOWLEDGE);
●First argument - if it is transactedsession
●Second argument – session automatically acknowledges on receiving.
16/
JMS MessageProducer
●MessageProducer producer = session.createProducer(dest);
●MessageProducer producer = session.createProducer(queue);
●MessageProducer producer = session.createProducer(topic);
●After you have created a message producer, you canuse it to send messages by
using the send method:
●producer.send(message);
17/
JMS MessageConsumers
●MessageConsumer consumer = session.createConsumer(dest);
●MessageConsumer consumer = session.createConsumer(queue);
●MessageConsumer consumer = session.createConsumer(topic);
18/
JMS MessageConsumer
●You use the receive method to consume a message synchronously. You can
use this method at any time after you call the start method:
●connection.start();
●Message m = consumer.receive();
●connection.start();
●Message m = consumer.receive(1000); // time out after a second
●To consume a message asynchronously, you use a message listener.
19/
JMS MessageListeners
●You register the message listener with a specific MessageConsumer by using
the setMessageListener method. For example, if you define a classnamed
Listener that implements the MessageListener interface, you can register the
message listener asfollows:
●Listener myListener = new Listener();
●consumer.setMessageListener(myListener);
●The same listener can obtain messages from either a queue or a topic.
20/
JMS Messages
●Message Bodies, type of message body formats are:
●TextMessage (string)
●MapMessage (key/value pair)
●BytesMessage
●StreamMessage
●ObjectMessage
●Message(empty body)
21/
JMS Messages
●A JMS message can have three parts: a header,properties, and a body. Only
the header is required.
●JMS Headers have number of predefined fields, likeJMSMessageID, which
identifies each message uniquely.
●You can create and set properties for messages, for use in message selectors or
other messaging systems.
22/
JMS MessageSelectors
●You can use aJMS API message selector, which allows a message consumer to
specify the messages that interest it.
●MessageConsumer consumer;
●consumer = session.createConsumer(destination, "myProp = 'blue'");
23/
Building Robust JMS Applications
●Controlling message acknowledgment
●Specifying message persistence
●Setting message priority levels
●Allowing messages to expire
●Creating temporary destinations
24/
Messageacknowledgement
●In transactedsessions, acknowledgment happens automaticallywhen a
transaction iscommitted. If a transactionis rolled back, all consumed messages
are redelivered.
●In nontransacted sessions, when and how a message is acknowledged depend
on the value:
–Session.AUTO_ACKNOWLEDGE (when MessageListener returns successfully)
–Session.CLIENT_ACKNOWLEDGE (on message callacknowledge method)
–Session.DUPS_OK_ACKNOWLEDGE (lazy acknowledge)
25/
Demo–Drone Delivery system
Use JMS Queue to design and implement a drone delivery system.
Objects :
●CommandCenter
●Warehouse
●Drone
●DroneEvent -This are Events sent to a JMS queue by the drones.
●Coordinates - Coordinates to send the drone
●Utility-Helper methods
26/
THANK YOU
●Demo Code availableat -
●https://github.com/arvindkgs/dronedeliverysystem
●My email: mail.arvind85@gmail.com
●Twitter handle:arvind_kgs

Contenu connexe

Tendances

Spring JMS and ActiveMQ
Spring JMS and ActiveMQSpring JMS and ActiveMQ
Spring JMS and ActiveMQGeert Pante
 
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
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingPeter R. Egli
 
Message Oriented Middleware
Message Oriented MiddlewareMessage Oriented Middleware
Message Oriented MiddlewareBehzad Altaf
 
Mule working with components
Mule   working with componentsMule   working with components
Mule working with componentskiranvanga
 
Message Oriented Middleware
Message Oriented MiddlewareMessage Oriented Middleware
Message Oriented MiddlewareManuswath K.B
 
Module5 enterprise java beans
Module5 enterprise java beansModule5 enterprise java beans
Module5 enterprise java beanspronab Kurmi
 
Architecture of message oriented middleware
Architecture of message oriented middlewareArchitecture of message oriented middleware
Architecture of message oriented middlewareLikan Patra
 

Tendances (12)

Spring JMS and ActiveMQ
Spring JMS and ActiveMQSpring JMS and ActiveMQ
Spring JMS and ActiveMQ
 
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
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message Queueing
 
Message Oriented Middleware
Message Oriented MiddlewareMessage Oriented Middleware
Message Oriented Middleware
 
Mule working with components
Mule   working with componentsMule   working with components
Mule working with components
 
Mule flows
Mule flowsMule flows
Mule flows
 
Message Oriented Middleware
Message Oriented MiddlewareMessage Oriented Middleware
Message Oriented Middleware
 
Module5 enterprise java beans
Module5 enterprise java beansModule5 enterprise java beans
Module5 enterprise java beans
 
Message oriented middleware
Message oriented middlewareMessage oriented middleware
Message oriented middleware
 
Ibm wmb online training
Ibm wmb online trainingIbm wmb online training
Ibm wmb online training
 
Architecture of message oriented middleware
Architecture of message oriented middlewareArchitecture of message oriented middleware
Architecture of message oriented middleware
 
Jms using j boss
Jms using j bossJms using j boss
Jms using j boss
 

Similaire à Messaging Frameworks using JMS

Similaire à Messaging Frameworks using JMS (20)

Test DB user
Test DB userTest DB user
Test DB user
 
test validation
test validationtest validation
test validation
 
Jms session (1)
Jms session (1)Jms session (1)
Jms session (1)
 
JMS
JMSJMS
JMS
 
test
testtest
test
 
Apache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelApache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache Camel
 
test
testtest
test
 
test
testtest
test
 
test
testtest
test
 
test
testtest
test
 
test
testtest
test
 
test
testtest
test
 
test
testtest
test
 
Jms
JmsJms
Jms
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging Service
 
Apache ActiveMQ
Apache ActiveMQ Apache ActiveMQ
Apache ActiveMQ
 
JMS-Java Message Service
JMS-Java Message ServiceJMS-Java Message Service
JMS-Java Message Service
 
Java Messaging Services
Java Messaging ServicesJava Messaging Services
Java Messaging Services
 
Mule jms-topics
Mule jms-topicsMule jms-topics
Mule jms-topics
 
Jms intro
Jms introJms intro
Jms intro
 

Dernier

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 

Dernier (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Messaging Frameworks using JMS

  • 2. 2 / Agenda ●What is Messaging? ●Why is it important? ●Messaging Fundamentals ●Messaging Protocols ●JMS Domains ●Message consumption ●JMS API ●Building Robust JMS Applications
  • 3. 3 / What is Messaging ●Messaging is process of communication between two or more disparate systems. ●Consider two legacy systems that are information silos. One system has information about allemployees and financesin company ABC. Another company does auditing for ABC, requires information about the employees and financesof ABC. ●Messaging can be used for communication between these two systems.
  • 4. 4 / Whyis it important ●Messaging is a technology that enables high-speed, asynchronous, atomic, program-to-program communication with reliable delivery. ●Messaging provides fault tolerance and load-balancingcapabilities. ●Messaging can be easily integrated into different heterogeneous systems. ●Messaging allows communication between two loosely coupled systems.
  • 5. 5 / Messaging Fundamentals ●Messaging capabilities are provided by a separate software system called messaging system or MOM (Message-oriented middleware). ●A messaging system manages messaging the way a database system manager data persistence. ●Similar to how a db admin must populate the db with the schema, a messaging system admin must configure the channels that define the paths of communication between the applications.
  • 7. 7 / Messaging protocols ●AMQP : Advanced message queuing protocol. It defines the protocol of messages, so different clients like RabbitMQ, ActiveMQ (5.8 onwards), StormMQ. ●JMS: Java Message Service is a Java API that allows applications to create, send, receive, and read messages. Designed by Sun and several partner companies, the JMS API defines a common set of interfaces and associated semantics.
  • 8. 8 / JMS Domains –Point to Point ●Point-to-Point Messaging Domain –Eachmessage is addressed to a specific queue. –Receiving clients extract messages from the queues. –Eachmessage hasonlyone consumer. –Receiver acknowledges succcessful processing of message.
  • 9. 9 / JMS Domains –Publish/Subscribe ●Publish/Subscribe Messaging Domain –clients address messages to a topic, which functions somewhat like abulletin board. –Publishers and subscribers can dynamically publish or subscribe to the content hierarchy. –System takescare of distributing the messages arriving from a topic’s multiple publishers to its multiple subscribers.
  • 10. 10/ JMS Domains - Publish/Subscribe ●Eachmessage can have multiple consumers. ●Topics retain messages only aslong as it takes to distribute them to current subscribers. ●A client that subscribes to a topic canconsume onlymessages published after the client hascreated a subscription, and the subscriber must continue to be active in order for it to consume messages.
  • 11. 11/ Messageconsumption ●Synchronously: A subscriber or a receiver explicitlyfetches the message from the destination by callingthe receive method. The receive method can block until amessage arrives or can time out if a message does not arrive withina specified time limit. ●Asynchronously: A client canregister a message listener with a consumer. Whenever a message arrives at the destination, the JMS provider delivers the message by calling the listener’s onMessage method, which acts on the contents of the message.
  • 12. 12/ JMS API ●JMS clients accessobjects like Connection Factory and Destinations through interfaces that are portable, so no change isnecessary between different implementations of JMS API.
  • 13. 13/ JMS API ●A connection factory is the object a client uses to create a connection to a provider. ●A destination is the object a client uses to specify the target of messages it produces and the source of messages it consumes. ●A connection encapsulates a virtual connection with a JMS provider. ●When you have a ConnectionFactory object, you can use it to create a Connection: ●Connection connection = connectionFactory.createConnection();
  • 14. 14/ JMS API ●A sessionis a single-threaded context for producing and consuming messages. You use sessions to create the following: ●Message producers ●Message consumers ●Messages ●Queue browsers
  • 15. 15/ JMS API ●After you create a Connection object, you use it to create a Session: ●Session session = connection.createSession(false, ●Session.AUTO_ACKNOWLEDGE); ●First argument - if it is transactedsession ●Second argument – session automatically acknowledges on receiving.
  • 16. 16/ JMS MessageProducer ●MessageProducer producer = session.createProducer(dest); ●MessageProducer producer = session.createProducer(queue); ●MessageProducer producer = session.createProducer(topic); ●After you have created a message producer, you canuse it to send messages by using the send method: ●producer.send(message);
  • 17. 17/ JMS MessageConsumers ●MessageConsumer consumer = session.createConsumer(dest); ●MessageConsumer consumer = session.createConsumer(queue); ●MessageConsumer consumer = session.createConsumer(topic);
  • 18. 18/ JMS MessageConsumer ●You use the receive method to consume a message synchronously. You can use this method at any time after you call the start method: ●connection.start(); ●Message m = consumer.receive(); ●connection.start(); ●Message m = consumer.receive(1000); // time out after a second ●To consume a message asynchronously, you use a message listener.
  • 19. 19/ JMS MessageListeners ●You register the message listener with a specific MessageConsumer by using the setMessageListener method. For example, if you define a classnamed Listener that implements the MessageListener interface, you can register the message listener asfollows: ●Listener myListener = new Listener(); ●consumer.setMessageListener(myListener); ●The same listener can obtain messages from either a queue or a topic.
  • 20. 20/ JMS Messages ●Message Bodies, type of message body formats are: ●TextMessage (string) ●MapMessage (key/value pair) ●BytesMessage ●StreamMessage ●ObjectMessage ●Message(empty body)
  • 21. 21/ JMS Messages ●A JMS message can have three parts: a header,properties, and a body. Only the header is required. ●JMS Headers have number of predefined fields, likeJMSMessageID, which identifies each message uniquely. ●You can create and set properties for messages, for use in message selectors or other messaging systems.
  • 22. 22/ JMS MessageSelectors ●You can use aJMS API message selector, which allows a message consumer to specify the messages that interest it. ●MessageConsumer consumer; ●consumer = session.createConsumer(destination, "myProp = 'blue'");
  • 23. 23/ Building Robust JMS Applications ●Controlling message acknowledgment ●Specifying message persistence ●Setting message priority levels ●Allowing messages to expire ●Creating temporary destinations
  • 24. 24/ Messageacknowledgement ●In transactedsessions, acknowledgment happens automaticallywhen a transaction iscommitted. If a transactionis rolled back, all consumed messages are redelivered. ●In nontransacted sessions, when and how a message is acknowledged depend on the value: –Session.AUTO_ACKNOWLEDGE (when MessageListener returns successfully) –Session.CLIENT_ACKNOWLEDGE (on message callacknowledge method) –Session.DUPS_OK_ACKNOWLEDGE (lazy acknowledge)
  • 25. 25/ Demo–Drone Delivery system Use JMS Queue to design and implement a drone delivery system. Objects : ●CommandCenter ●Warehouse ●Drone ●DroneEvent -This are Events sent to a JMS queue by the drones. ●Coordinates - Coordinates to send the drone ●Utility-Helper methods
  • 26. 26/ THANK YOU ●Demo Code availableat - ●https://github.com/arvindkgs/dronedeliverysystem ●My email: mail.arvind85@gmail.com ●Twitter handle:arvind_kgs