Click here to Skip to main content
Click here to Skip to main content

Asynchronous Message Passing Using JMS

By , 11 Mar 2012
 

Introduction

This article is written to give you basic understanding on how to make asynchronous message passing using JMS (Java Messaging Service). There are many tutorials available on how to create JMS Producer, JMS Queue Listener, JMS Consumer, etc. But as per my knowledge none explain how to use message passing architecture in simple words. This article will give you better understanding on how to use JMS for messaging architecture.

Background  

Consider a problem as follows: 

Create a web application sends a book id in a JMS Queue message. The business logic retrieves the message asynchronously and retrieves the book details from the database. It arranges all the data in an XML and returns back to the client. The client parses that XML and displays the data.

The solution of this problem is explained into the following diagram:

Solution

To solve this problem, we need to create one JMS Message Producer (JSP page or servlet) that will produce BookID i.e. whose details need to be fetched from DataBase. This BookID will be stored into BookIDQueue and one Message-Driven Session Bean which will execute when a new message added into BookIDQueue because it is a kind of JMS Queue Listener that responds to onMessage event. As stated into diagram the a remote EJB will be called from the Message Driven Bean onMessage that will fetch book details from DataBase using JPA and generate an XML for book details. This XML will be then added into BookDetailQueue by the same remote EJB. Then one JMS Queue Consumer will be created in servlet that will read the messages of the queue and get them one by one and parses the message i.e. XML and get the book details.

This was the architectural design of the solution.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Raj Champaneriya
Student Riversand
India India
Member
is final year M.Sc.I.T. student of J. P. Dawer Institute of Science and Information Technology, Surat, Gujarat, India and working at Riversand Technologies Inc. as software developer intern.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Question[My vote of 1] Nothing Original.......mentorMd. Marufuzzaman2 Jun '12 - 2:36 
AnswerRe: [My vote of 1] Nothing Original.......memberRaj Champaneriya2 Jun '12 - 8:19 
QuestionDelete this....mvpDave Kreskowiak11 Mar '12 - 10:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 11 Mar 2012
Article Copyright 2012 by Raj Champaneriya
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid