SlideShare a Scribd company logo
A Study in JMS
(Java Messaging
Service)
JMS OverviewJMS Overview
The Java Message Service is a Java API that
allows applications to create, send, receive,
and read messages
The JMS API minimizes the set of concepts a
programmer must learn to use messaging
products but provides enough features to
support sophisticated messaging applications
JMS Overview (cont)JMS Overview (cont)
The JMS API enables communication that is
not only loosely coupled but also:
Asynchronous. A JMS provider can deliver
messages to a client as they arrive; a client does
not have to request messages in order to receive
them.
Reliable. The JMS API can ensure that a
message is delivered once and only once. Lower
levels of reliability are available for applications
that can afford to miss messages or to receive
duplicate messages.
JMS Overview (cont)JMS Overview (cont)
Messages can be consumed in either of two ways:
Synchronously. A subscriber or a receiver explicitly fetches
the message from the destination by calling the receive
method. The receive method can block until a message
arrives or can time out if a message does not arrive within a
specified time limit.
Asynchronously. A client can register a message listener
with a consumer. A message listener is similar to an event
listener. 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.
JMS And JNDIJMS And JNDI
JMS does not not define a standard address syntax by which
clients communicate with each other. Instead JMS utilizes Java
Naming & Directory Interface(JNDI).
JNDI provides a mechanism by which clients can perform a
“lookup” to find the correct information to connect to each other.
Using JNDI provides the following advantages:
It hides provider-specific details from JMS clients.
It abstracts JMS administrative information into Java objects that
are easily organized and administrated from a common
management console.
Since there will be JNDI providers for all popular naming services,
this means JMS providers can deliver one implementation of
administered objects that will run everywhere. Thereby eliminating
deployment and configuration issues.
JMS Advantages over RPCJMS Advantages over RPC
RPC relies on the physical connection of the client
and server to the network; it is a synchronous
protocol.
What happens if the client is disconnected?
Network could go down
Client could be a laptop that is used on the road.
In this case, the end user might still want to carry on
working, but can't if an RPC model is being used—at
least not without a great deal of work by the
programmer.
Messaging BenefitsMessaging Benefits
JMS vs RPCJMS vs RPC
Messaging provides the ability to send data
asynchronously and in a disconnected manner.
Two messaging models
Point-to-point
Publish-and-Subscribe
In an email like model, these would be equivalent to
sending and receiving e-mails directly (point-to-point),
or subscribing to a list server and sending and
receiving e-mails through the list server (publish-and-
subscribe).
What is the cost?What is the cost?
JMS vs RPCJMS vs RPC
Applications become asynchronous by nature
What if we require a method to give us a return
value?
What if we require the data (the messages) to be
delivered in a specific order?
Using messaging, JMS, we have to deal with
these problems ourselves. RPC handled
these issues for the programmer.
Messages ExplainedMessages Explained
A message typically consists of a header and a body.
The message header contains vendor-specified
values, but could also contain application-specific
data as well.
Headers are typically name/value pairs.
The body contains data; the type of the data is
defined by the specification.
Text
A serialized Java object
One of a number of other types of data.
Publisher SamplePublisher Sample
See MyTopicPublisher.java for source.
1. Perform a JNDI API lookup of the TopicConnectionFactory and topic
topic = (Topic) jndiContext.lookup(topicName);
2. Create a connection and a session
topicConnection = topicConnectionFactory.createTopicConnection();
topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
3. Create a TopicPublisher
topicPublisher = topicSession.createPublisher(topic);
4. Create a TextMessage
Message = topicSession.createTextMessage();
message.setText("This is message " + (i + 1));
5. Publishe one or more messages to the topic
topicPublisher.publish(message);
6. Close the connection, which automatically closes the session and
TopicPublisher
Subscriber SampleSubscriber Sample
See MyTopicSubscriber.java for source.
1.Perform a JNDI API lookup of the TopicConnectionFactory and
topic (same as publisher)
2.Create a connection and a session (same as publisher)
3.Create a TopicSubscriber
topicSubscriber = topicSession.createSubscriber(topic);
4.Create an instance of the TextListener class and registers it as
the message listener for the TopicSubscriber
topicListener = new TextListener();
topicSubscriber.setMessageListener(topicListener);
5.Start the connection, causing message delivery to begin
topicConnection.start();
6.Close the connection, which automatically closes the session
and TopicSubscriber
topicConnection.close();
TextListener SampleTextListener Sample
1. public void onMessage(Message message) {
2. TextMessage msg = null;
3.
4. try {
5. if (message instanceof TextMessage) {
6. msg = (TextMessage) message;
7. System.out.println("Reading message: " + msg.getText());
8. } else {
9. System.out.println("Message of wrong type: " +
10. message.getClass().getName());
11. }
12. } catch (JMSException e) {
13. System.out.println("JMSException in onMessage(): " + e.toString());
14. } catch (Throwable t) {
15. System.out.println("Exception in onMessage():" + t.getMessage());
16. }
17.}
Running The SampleRunning The Sample
1. Start the JMS provider. In this case the J2EE SDK
From a command prompt run the following command:
j2ee –verbose
Wait until the server displays the message "J2EE server startup
complete
1. Create the Administered Object. This is the object to which
you will publish and subscribe.
From a second command prompt run the following command
j2eeadmin -addJmsDestination CS522Topic topic
To verify the topic was created, view the list of Administered
Objects by typing:
j2eeadmin –listJmsDestination
Running The Sample (cont)Running The Sample (cont)
3. Run the subscriber program
From a command prompt run the following command within the
directory that contains the MyTopicSubscriber.class:
java -Djms.properties=%J2EE_HOME
%configjms_client.properties MyTopicSubscriber
-topic=CS522Topic
3. Run the Publisher program
From a command prompt run the following command within the
directory that contains the MyTopicPublisher.class:
java -Djms.properties=%J2EE_HOME
%configjms_client.properties MyTopicPublisher
-topic=CS522Topic -count=500 -delay=500
5. You will see text output in both the Publisher and Subscriber
windows
ReferencesReferences
http://java.sun.com/products/jms/tutorial/1_3_1
http://java.sun.com/products/jndi/

More Related Content

What's hot

Jms
JmsJms
Jms
JmsJms
Jms session (1)
Jms session (1)Jms session (1)
Jms session (1)
Marwa Dosoky
 
Enterprise messaging with jms
Enterprise messaging with jmsEnterprise messaging with jms
Enterprise messaging with jms
Sridhar Reddy
 
JMS Introduction
JMS IntroductionJMS Introduction
JMS Introduction
Alex Su
 
Jms deep dive [con4864]
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]
Ryan Cuprak
 
Message Oriented Middleware
Message Oriented MiddlewareMessage Oriented Middleware
Message Oriented Middleware
Behzad Altaf
 
test
testtest
test
techweb08
 
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
Harinath Krishnamoorthy
 
Ppt2
Ppt2Ppt2
Module5 enterprise java beans
Module5 enterprise java beansModule5 enterprise java beans
Module5 enterprise java beans
pronab Kurmi
 

What's hot (12)

Jms
JmsJms
Jms
 
Jms
JmsJms
Jms
 
Jms session (1)
Jms session (1)Jms session (1)
Jms session (1)
 
Enterprise messaging with jms
Enterprise messaging with jmsEnterprise messaging with jms
Enterprise messaging with jms
 
JMS Introduction
JMS IntroductionJMS Introduction
JMS Introduction
 
Jms deep dive [con4864]
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]
 
Message Oriented Middleware
Message Oriented MiddlewareMessage Oriented Middleware
Message Oriented Middleware
 
test
testtest
test
 
test
testtest
test
 
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
 
Ppt2
Ppt2Ppt2
Ppt2
 
Module5 enterprise java beans
Module5 enterprise java beansModule5 enterprise java beans
Module5 enterprise java beans
 

Viewers also liked

Business Lifestyle Magazine - Outlook Business
Business Lifestyle Magazine - Outlook BusinessBusiness Lifestyle Magazine - Outlook Business
Business Lifestyle Magazine - Outlook Business
purnima23
 
18 ciencias-de-la-naturaleza-2-eso-2-actividades-de-verano-dpto-de-fisica-y-q...
18 ciencias-de-la-naturaleza-2-eso-2-actividades-de-verano-dpto-de-fisica-y-q...18 ciencias-de-la-naturaleza-2-eso-2-actividades-de-verano-dpto-de-fisica-y-q...
18 ciencias-de-la-naturaleza-2-eso-2-actividades-de-verano-dpto-de-fisica-y-q...
Belén Rosado Domínguez
 
Trabalho Final
Trabalho FinalTrabalho Final
Trabalho Final
carlosodilonbarros
 
Xpath
XpathXpath
Build Up An Evidence Factory
Build Up An Evidence FactoryBuild Up An Evidence Factory
Build Up An Evidence Factory
Sandor_Tomolak
 
Project Report Outlook (
Project Report Outlook (Project Report Outlook (
Project Report Outlook (
Satyam Sharma
 
Entertainment-Movies Quiz ( Pulp Facts ) at Quizics Informal Meet
Entertainment-Movies Quiz ( Pulp Facts ) at Quizics Informal MeetEntertainment-Movies Quiz ( Pulp Facts ) at Quizics Informal Meet
Entertainment-Movies Quiz ( Pulp Facts ) at Quizics Informal Meet
Muralikrishnan Padmakumar
 
Soal uts matematika kelas 1 semester 2
Soal uts matematika kelas 1 semester 2Soal uts matematika kelas 1 semester 2
Soal uts matematika kelas 1 semester 2
Sekolah Dasar
 
Innovation in der Instandhaltung - Motor für die Zukunft
Innovation in der Instandhaltung - Motor für die ZukunftInnovation in der Instandhaltung - Motor für die Zukunft
Innovation in der Instandhaltung - Motor für die Zukunft
Salzburg Research Forschungsgesellschaft mbH
 
How to make maths interesting shouren bose
How to make maths interesting shouren boseHow to make maths interesting shouren bose
How to make maths interesting shouren bose
shouren bose
 

Viewers also liked (10)

Business Lifestyle Magazine - Outlook Business
Business Lifestyle Magazine - Outlook BusinessBusiness Lifestyle Magazine - Outlook Business
Business Lifestyle Magazine - Outlook Business
 
18 ciencias-de-la-naturaleza-2-eso-2-actividades-de-verano-dpto-de-fisica-y-q...
18 ciencias-de-la-naturaleza-2-eso-2-actividades-de-verano-dpto-de-fisica-y-q...18 ciencias-de-la-naturaleza-2-eso-2-actividades-de-verano-dpto-de-fisica-y-q...
18 ciencias-de-la-naturaleza-2-eso-2-actividades-de-verano-dpto-de-fisica-y-q...
 
Trabalho Final
Trabalho FinalTrabalho Final
Trabalho Final
 
Xpath
XpathXpath
Xpath
 
Build Up An Evidence Factory
Build Up An Evidence FactoryBuild Up An Evidence Factory
Build Up An Evidence Factory
 
Project Report Outlook (
Project Report Outlook (Project Report Outlook (
Project Report Outlook (
 
Entertainment-Movies Quiz ( Pulp Facts ) at Quizics Informal Meet
Entertainment-Movies Quiz ( Pulp Facts ) at Quizics Informal MeetEntertainment-Movies Quiz ( Pulp Facts ) at Quizics Informal Meet
Entertainment-Movies Quiz ( Pulp Facts ) at Quizics Informal Meet
 
Soal uts matematika kelas 1 semester 2
Soal uts matematika kelas 1 semester 2Soal uts matematika kelas 1 semester 2
Soal uts matematika kelas 1 semester 2
 
Innovation in der Instandhaltung - Motor für die Zukunft
Innovation in der Instandhaltung - Motor für die ZukunftInnovation in der Instandhaltung - Motor für die Zukunft
Innovation in der Instandhaltung - Motor für die Zukunft
 
How to make maths interesting shouren bose
How to make maths interesting shouren boseHow to make maths interesting shouren bose
How to make maths interesting shouren bose
 

Similar to Jms intro

Jms
JmsJms
Java message service
Java message serviceJava message service
Java message service
Veeramani S
 
Test DB user
Test DB userTest DB user
Test DB user
techweb08
 
test validation
test validationtest validation
test validation
techweb08
 
Messaging in Java
Messaging in JavaMessaging in Java
Messaging in Java
Dmitry Buzdin
 
Apache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelApache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache Camel
Omi Om
 
What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013
Jagadish Prasath
 
About jms
About jmsAbout jms
About jms
prudhvivreddy
 
Weblogic - Introduction to configure JMS
Weblogic  - Introduction to configure JMSWeblogic  - Introduction to configure JMS
Weblogic - Introduction to configure JMS
Vibrant Technologies & Computers
 
Mule jms
Mule   jmsMule   jms
#7 (Java Message Service)
#7 (Java Message Service)#7 (Java Message Service)
#7 (Java Message Service)
Ghadeer AlHasan
 
Mule with jms
Mule with jmsMule with jms
Mule with jms
kiranvanga
 
ActiveMQ Configuration
ActiveMQ ConfigurationActiveMQ Configuration
ActiveMQ Configuration
Ashish Mishra
 
Messaging Frameworks using JMS
Messaging Frameworks using JMS Messaging Frameworks using JMS
Messaging Frameworks using JMS
Arvind Kumar G.S
 
WebLogic JMS System Best Practices
WebLogic JMS System Best PracticesWebLogic JMS System Best Practices
WebLogic JMS System Best Practices
Trivadis
 
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
StreamNative
 
Introduction-to-JMS-and-MDB java ejb .pptx
Introduction-to-JMS-and-MDB java ejb .pptxIntroduction-to-JMS-and-MDB java ejb .pptx
Introduction-to-JMS-and-MDB java ejb .pptx
momnatanveer321
 
ActiveMQ interview Questions and Answers
ActiveMQ interview Questions and AnswersActiveMQ interview Questions and Answers
ActiveMQ interview Questions and Answers
jeetendra mandal
 
Jms слайды
Jms слайдыJms слайды
Jms слайды
Sergey D
 
Indianapolis mule soft_meetup_12_june_2021
Indianapolis mule soft_meetup_12_june_2021Indianapolis mule soft_meetup_12_june_2021
Indianapolis mule soft_meetup_12_june_2021
ikram_ahamed
 

Similar to Jms intro (20)

Jms
JmsJms
Jms
 
Java message service
Java message serviceJava message service
Java message service
 
Test DB user
Test DB userTest DB user
Test DB user
 
test validation
test validationtest validation
test validation
 
Messaging in Java
Messaging in JavaMessaging in Java
Messaging in Java
 
Apache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelApache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache Camel
 
What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013What's new in JMS 2.0 - OTN Bangalore 2013
What's new in JMS 2.0 - OTN Bangalore 2013
 
About jms
About jmsAbout jms
About jms
 
Weblogic - Introduction to configure JMS
Weblogic  - Introduction to configure JMSWeblogic  - Introduction to configure JMS
Weblogic - Introduction to configure JMS
 
Mule jms
Mule   jmsMule   jms
Mule jms
 
#7 (Java Message Service)
#7 (Java Message Service)#7 (Java Message Service)
#7 (Java Message Service)
 
Mule with jms
Mule with jmsMule with jms
Mule with jms
 
ActiveMQ Configuration
ActiveMQ ConfigurationActiveMQ Configuration
ActiveMQ Configuration
 
Messaging Frameworks using JMS
Messaging Frameworks using JMS Messaging Frameworks using JMS
Messaging Frameworks using JMS
 
WebLogic JMS System Best Practices
WebLogic JMS System Best PracticesWebLogic JMS System Best Practices
WebLogic JMS System Best Practices
 
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
 
Introduction-to-JMS-and-MDB java ejb .pptx
Introduction-to-JMS-and-MDB java ejb .pptxIntroduction-to-JMS-and-MDB java ejb .pptx
Introduction-to-JMS-and-MDB java ejb .pptx
 
ActiveMQ interview Questions and Answers
ActiveMQ interview Questions and AnswersActiveMQ interview Questions and Answers
ActiveMQ interview Questions and Answers
 
Jms слайды
Jms слайдыJms слайды
Jms слайды
 
Indianapolis mule soft_meetup_12_june_2021
Indianapolis mule soft_meetup_12_june_2021Indianapolis mule soft_meetup_12_june_2021
Indianapolis mule soft_meetup_12_june_2021
 

More from Manav Prasad

Experience with mulesoft
Experience with mulesoftExperience with mulesoft
Experience with mulesoft
Manav Prasad
 
Mulesoftconnectors
MulesoftconnectorsMulesoftconnectors
Mulesoftconnectors
Manav Prasad
 
Mule and web services
Mule and web servicesMule and web services
Mule and web services
Manav Prasad
 
Mulesoft cloudhub
Mulesoft cloudhubMulesoft cloudhub
Mulesoft cloudhub
Manav Prasad
 
Perl tutorial
Perl tutorialPerl tutorial
Perl tutorial
Manav Prasad
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
Manav Prasad
 
Jpa
JpaJpa
Spring introduction
Spring introductionSpring introduction
Spring introduction
Manav Prasad
 
Json
Json Json
The spring framework
The spring frameworkThe spring framework
The spring framework
Manav Prasad
 
Rest introduction
Rest introductionRest introduction
Rest introduction
Manav Prasad
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
Manav Prasad
 
Junit
JunitJunit
Xml parsers
Xml parsersXml parsers
Xml parsers
Manav Prasad
 
Xslt
XsltXslt
Xhtml
XhtmlXhtml
Css
CssCss
Introduction to html5
Introduction to html5Introduction to html5
Introduction to html5
Manav Prasad
 
Ajax
AjaxAjax
J query
J queryJ query
J query
Manav Prasad
 

More from Manav Prasad (20)

Experience with mulesoft
Experience with mulesoftExperience with mulesoft
Experience with mulesoft
 
Mulesoftconnectors
MulesoftconnectorsMulesoftconnectors
Mulesoftconnectors
 
Mule and web services
Mule and web servicesMule and web services
Mule and web services
 
Mulesoft cloudhub
Mulesoft cloudhubMulesoft cloudhub
Mulesoft cloudhub
 
Perl tutorial
Perl tutorialPerl tutorial
Perl tutorial
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
Jpa
JpaJpa
Jpa
 
Spring introduction
Spring introductionSpring introduction
Spring introduction
 
Json
Json Json
Json
 
The spring framework
The spring frameworkThe spring framework
The spring framework
 
Rest introduction
Rest introductionRest introduction
Rest introduction
 
Exceptions in java
Exceptions in javaExceptions in java
Exceptions in java
 
Junit
JunitJunit
Junit
 
Xml parsers
Xml parsersXml parsers
Xml parsers
 
Xslt
XsltXslt
Xslt
 
Xhtml
XhtmlXhtml
Xhtml
 
Css
CssCss
Css
 
Introduction to html5
Introduction to html5Introduction to html5
Introduction to html5
 
Ajax
AjaxAjax
Ajax
 
J query
J queryJ query
J query
 

Recently uploaded

Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 

Recently uploaded (20)

Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 

Jms intro

  • 1. A Study in JMS (Java Messaging Service)
  • 2. JMS OverviewJMS Overview The Java Message Service is a Java API that allows applications to create, send, receive, and read messages The JMS API minimizes the set of concepts a programmer must learn to use messaging products but provides enough features to support sophisticated messaging applications
  • 3. JMS Overview (cont)JMS Overview (cont) The JMS API enables communication that is not only loosely coupled but also: Asynchronous. A JMS provider can deliver messages to a client as they arrive; a client does not have to request messages in order to receive them. Reliable. The JMS API can ensure that a message is delivered once and only once. Lower levels of reliability are available for applications that can afford to miss messages or to receive duplicate messages.
  • 4. JMS Overview (cont)JMS Overview (cont) Messages can be consumed in either of two ways: Synchronously. A subscriber or a receiver explicitly fetches the message from the destination by calling the receive method. The receive method can block until a message arrives or can time out if a message does not arrive within a specified time limit. Asynchronously. A client can register a message listener with a consumer. A message listener is similar to an event listener. 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.
  • 5. JMS And JNDIJMS And JNDI JMS does not not define a standard address syntax by which clients communicate with each other. Instead JMS utilizes Java Naming & Directory Interface(JNDI). JNDI provides a mechanism by which clients can perform a “lookup” to find the correct information to connect to each other. Using JNDI provides the following advantages: It hides provider-specific details from JMS clients. It abstracts JMS administrative information into Java objects that are easily organized and administrated from a common management console. Since there will be JNDI providers for all popular naming services, this means JMS providers can deliver one implementation of administered objects that will run everywhere. Thereby eliminating deployment and configuration issues.
  • 6. JMS Advantages over RPCJMS Advantages over RPC RPC relies on the physical connection of the client and server to the network; it is a synchronous protocol. What happens if the client is disconnected? Network could go down Client could be a laptop that is used on the road. In this case, the end user might still want to carry on working, but can't if an RPC model is being used—at least not without a great deal of work by the programmer.
  • 7. Messaging BenefitsMessaging Benefits JMS vs RPCJMS vs RPC Messaging provides the ability to send data asynchronously and in a disconnected manner. Two messaging models Point-to-point Publish-and-Subscribe In an email like model, these would be equivalent to sending and receiving e-mails directly (point-to-point), or subscribing to a list server and sending and receiving e-mails through the list server (publish-and- subscribe).
  • 8. What is the cost?What is the cost? JMS vs RPCJMS vs RPC Applications become asynchronous by nature What if we require a method to give us a return value? What if we require the data (the messages) to be delivered in a specific order? Using messaging, JMS, we have to deal with these problems ourselves. RPC handled these issues for the programmer.
  • 9. Messages ExplainedMessages Explained A message typically consists of a header and a body. The message header contains vendor-specified values, but could also contain application-specific data as well. Headers are typically name/value pairs. The body contains data; the type of the data is defined by the specification. Text A serialized Java object One of a number of other types of data.
  • 10. Publisher SamplePublisher Sample See MyTopicPublisher.java for source. 1. Perform a JNDI API lookup of the TopicConnectionFactory and topic topic = (Topic) jndiContext.lookup(topicName); 2. Create a connection and a session topicConnection = topicConnectionFactory.createTopicConnection(); topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); 3. Create a TopicPublisher topicPublisher = topicSession.createPublisher(topic); 4. Create a TextMessage Message = topicSession.createTextMessage(); message.setText("This is message " + (i + 1)); 5. Publishe one or more messages to the topic topicPublisher.publish(message); 6. Close the connection, which automatically closes the session and TopicPublisher
  • 11. Subscriber SampleSubscriber Sample See MyTopicSubscriber.java for source. 1.Perform a JNDI API lookup of the TopicConnectionFactory and topic (same as publisher) 2.Create a connection and a session (same as publisher) 3.Create a TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic); 4.Create an instance of the TextListener class and registers it as the message listener for the TopicSubscriber topicListener = new TextListener(); topicSubscriber.setMessageListener(topicListener); 5.Start the connection, causing message delivery to begin topicConnection.start(); 6.Close the connection, which automatically closes the session and TopicSubscriber topicConnection.close();
  • 12. TextListener SampleTextListener Sample 1. public void onMessage(Message message) { 2. TextMessage msg = null; 3. 4. try { 5. if (message instanceof TextMessage) { 6. msg = (TextMessage) message; 7. System.out.println("Reading message: " + msg.getText()); 8. } else { 9. System.out.println("Message of wrong type: " + 10. message.getClass().getName()); 11. } 12. } catch (JMSException e) { 13. System.out.println("JMSException in onMessage(): " + e.toString()); 14. } catch (Throwable t) { 15. System.out.println("Exception in onMessage():" + t.getMessage()); 16. } 17.}
  • 13. Running The SampleRunning The Sample 1. Start the JMS provider. In this case the J2EE SDK From a command prompt run the following command: j2ee –verbose Wait until the server displays the message "J2EE server startup complete 1. Create the Administered Object. This is the object to which you will publish and subscribe. From a second command prompt run the following command j2eeadmin -addJmsDestination CS522Topic topic To verify the topic was created, view the list of Administered Objects by typing: j2eeadmin –listJmsDestination
  • 14. Running The Sample (cont)Running The Sample (cont) 3. Run the subscriber program From a command prompt run the following command within the directory that contains the MyTopicSubscriber.class: java -Djms.properties=%J2EE_HOME %configjms_client.properties MyTopicSubscriber -topic=CS522Topic 3. Run the Publisher program From a command prompt run the following command within the directory that contains the MyTopicPublisher.class: java -Djms.properties=%J2EE_HOME %configjms_client.properties MyTopicPublisher -topic=CS522Topic -count=500 -delay=500 5. You will see text output in both the Publisher and Subscriber windows

Editor's Notes

  1. Although a standard address syntax was considered, it was decided that the differences in address semantics between existing MOM products was too wide to bridge with a single syntax.