Welcome!

Java IoT Authors: Yeshim Deniz, Elizabeth White, Liz McMillan, Jyoti Bansal, Jason Bloomberg

Related Topics: Java IoT

Java IoT: Article

Generic Request Response Broker for JMS

A robust and easy-to-use implementation of the Request-Response paradigm

This article describes the design and implementation of a generic request/response broker (RRB) for JMS. RRB augments JMS with a highly efficient implementation of the request-response paradigm.

It's extremely important for many asynchronous applications since JMS has somewhat weak built-in support for the request-response paradigm that might be inadequate for high-load enterprise applications. RRB solves the following common problems. It:

  • Provides a generic high-performance application and JMS provider-independent implementation of the request-response pattern.
  • Supports timeouts for non-blocking clients.
  • Allows efficient handling of a large number of requests/responses.
  • Lets one hide all the JMS details behind the façade interface.
  • Reduces performance degradation when a request travels through multiple façade proxies.
Possible Solutions and Their Performance Comparison
Request-response pattern is popular in enterprise applications: a client application sends a request message to a server app, which handles the request and sends the response back to the client. Here's what JMS offers for this pattern:
  • JMSMessageID and JMSCorrelationID headers can be used to link requests and responses.
  • JMSReplyTo header lets the recipient of a request know where to send the response.
  • TopicRequestor/QueueRequestor helpers allow sending a request and block until a response is received.
TopicRequestor/QueueRequestor is the only JMS built-in "request-response broker" and has three drawbacks:
  • It's a blocking call.
  • You're not allowed to specify a timeout in the only existing request() method, so your thread may be blocked forever if there's no response.
  • It creates and deletes a temporary response destination for every request, which has big performance implications as we'll see later.
Because of these drawbacks, the burden of implementing timeouts and retrieving response messages efficiently is left to the developers of the client applications and that's exactly what RRB is designed to solve (The source code for this article can be downloaded from www.sys-con.com/java/sourcec.cfm.)

Timeout for Non-blocking Clients
Standard JMS lets the client provide a timeout only for the blocking (synchronous) calls in the method MessageConsumer.receive(): a client is blocked until the message is received or the time specified has expired. Of course, a blocking call isn't a preferred way in JMS to get a message. It's better to use a MessageListener object registered with a particular destination that's called whenever a message is received. Unfortunately standard JMS makes no provision for using timeouts with asynchronous calls using listeners: MessageListener only has onMessage() callback methods and no onTimeout(). That means your listener will be called only when a message is posted to the destination you're listening on; it'll never be called if for some reason the message you expected never arrived. In many real-life apps and in almost every request-response scenario you can't wait for a message indefinitely (especially if it's a response). You need to bail out after some timeout.

Efficient Implementation of the Response Handling
In JMS there are three ways to get a response message:

1.  Create/delete a temporary destination per request

  • Pros:
    - Clean design, response destination isn't shared, no filtering required
    - Relatively easy to implement
  • Cons:
    - Inherently bad performance (temporary destinations are always created inside the MOM provider, which generally means two extra network calls: create and delete a temporary destination plus all the housekeeping and resources on the app server to maintain the temp destination).
2.  Use the same destination for multiple responses in combination with JMS selectors for filtering
  • Pros:
    - Relatively clean design, no filtering in the client once the selector is set up
  • Cons:
    - Questionable performance: some vendors don't recommend using selectors
    - Many possible pitfalls (for example, selectors on strings are much slower than on integers)
3.  Use the same destination for multiple responses without JMS selectors
  • Pros:
    - Can be fast depending on the implementation
  • Cons:
    - Filtering has to be done in the client's code
    - Many possible pitfalls that will result in lost or doubly handled messages (for example, when two or more apps use the same "unique" application_id properties for filtering)
    - High load on the client listeners (in case of a response topic) that are called every time a message is received and subsequently discarded by all but one listener
To fully understand the performance impact of the different retrieval options mentioned above I wrote a simple JMS server app (EchoClient.java) and three different JMS client apps for every option: EchoClientMultTempQs.java, EchoClientSelector.java, and EchoClient.java. These clients will show the performance metrics of each message retrieval approach. All the tests were run in the same environment: one physical Linux box using three separate JVMs, echo client, JMS provider, and an echo server.

Option 1. A new temp destination for every response:


java EchoClientMultTempQs echo_server.properties 1000
...
N of reqs/resps = 1000
Total time = 13765 millisecs
Average roundtrip time = 13.765 millisecs

Option 2. The same destination using jms selectors for filtering:


java EchoClientSelector echo_server.properties 1000
...
N of reqs/resps = 1000
Total time = 10705 millisecs
Average roundtrip time = 10.705 millisecs

More Stories By Lev Kochubeevsky

Lev Kochubeevsky is a chief architect at AOL in Dulles, Virginia.
His main areas of interest include high performance enterprise systems,
distributed software architectures, messaging, virtual machines,
simulators
and
debuggers. Lev holds a master degree in computer science.

Comments (5) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
fred 10/08/09 04:04:00 PM EDT

Hi!

You can find the code here!

cheers.

Lev Kochubeevsky 05/21/05 11:31:41 PM EDT

Aleksandr,

Please contact JDJ site admin to report a problem with the source code availability.

Lev Kochubeevsky 05/21/05 11:28:50 PM EDT

Marco,

I used only standard JMS code ( v.1.02 ) in RRB so it will work with any JMS provider.

Marco 05/19/05 11:03:41 AM EDT

Hi,

i would like to know what JMS provider use for trying the example.

Thank you

aleksandr 05/17/05 04:21:43 PM EDT

Can not load source code for this article using
www.sys-con.com/java/sourcec.cfm
link mentioned in this article.

Please advise.

@ThingsExpo Stories
Your homes and cars can be automated and self-serviced. Why can't your storage? From simply asking questions to analyze and troubleshoot your infrastructure, to provisioning storage with snapshots, recovery and replication, your wildest sci-fi dream has come true. In his session at @DevOpsSummit at 20th Cloud Expo, Dan Florea, Director of Product Management at Tintri, will provide a ChatOps demo where you can talk to your storage and manage it from anywhere, through Slack and similar services ...
In his session at @ThingsExpo, Eric Lachapelle, CEO of the Professional Evaluation and Certification Board (PECB), will provide an overview of various initiatives to certifiy the security of connected devices and future trends in ensuring public trust of IoT. Eric Lachapelle is the Chief Executive Officer of the Professional Evaluation and Certification Board (PECB), an international certification body. His role is to help companies and individuals to achieve professional, accredited and worldw...
SYS-CON Events announced today that Linux Academy, the foremost online Linux and cloud training platform and community, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Linux Academy was founded on the belief that providing high-quality, in-depth training should be available at an affordable price. Industry leaders in quality training, provided services, and student certification passes, its goal is to c...
"delaPlex is a software development company. We do team-based outsourcing development," explained Mark Rivers, COO and Co-founder of delaPlex Software, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
SYS-CON Events announced today that SoftLayer, an IBM Company, has been named “Gold Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. SoftLayer, an IBM Company, provides cloud infrastructure as a service from a growing number of data centers and network points of presence around the world. SoftLayer’s customers range from Web startups to global enterprises.
SYS-CON Events announced today that Technologic Systems Inc., an embedded systems solutions company, will exhibit at SYS-CON's @ThingsExpo, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Technologic Systems is an embedded systems company with headquarters in Fountain Hills, Arizona. They have been in business for 32 years, helping more than 8,000 OEM customers and building over a hundred COTS products that have never been discontinued. Technologic Systems’ pr...
SYS-CON Events announced today that CA Technologies has been named “Platinum Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY, and the 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business – from apparel to energy – is being rewritten by software. From ...
In his keynote at @ThingsExpo, Chris Matthieu, Director of IoT Engineering at Citrix and co-founder and CTO of Octoblu, focused on building an IoT platform and company. He provided a behind-the-scenes look at Octoblu’s platform, business, and pivots along the way (including the Citrix acquisition of Octoblu).
SYS-CON Events announced today that Loom Systems will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Founded in 2015, Loom Systems delivers an advanced AI solution to predict and prevent problems in the digital business. Loom stands alone in the industry as an AI analysis platform requiring no prior math knowledge from operators, leveraging the existing staff to succeed in the digital era. With offices in S...
SYS-CON Events announced today that HTBase will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. HTBase (Gartner 2016 Cool Vendor) delivers a Composable IT infrastructure solution architected for agility and increased efficiency. It turns compute, storage, and fabric into fluid pools of resources that are easily composed and re-composed to meet each application’s needs. With HTBase, companies can quickly prov...
SYS-CON Events announced today that T-Mobile will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on ...
SYS-CON Events announced today that Cloud Academy will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud computing technologies. Ge...
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 20th International Cloud Expo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buyers...
SYS-CON Events announced today that Infranics will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Since 2000, Infranics has developed SysMaster Suite, which is required for the stable and efficient management of ICT infrastructure. The ICT management solution developed and provided by Infranics continues to add intelligence to the ICT infrastructure through the IMC (Infra Management Cycle) based on mathemat...
SYS-CON Events announced today that Interoute, owner-operator of one of Europe's largest networks and a global cloud services platform, has been named “Bronze Sponsor” of SYS-CON's 20th Cloud Expo, which will take place on June 6-8, 2017 at the Javits Center in New York, New York. Interoute is the owner-operator of one of Europe's largest networks and a global cloud services platform which encompasses 12 data centers, 14 virtual data centers and 31 colocation centers, with connections to 195 add...
SYS-CON Events announced today that SD Times | BZ Media has been named “Media Sponsor” of SYS-CON's 20th International Cloud Expo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. BZ Media LLC is a high-tech media company that produces technical conferences and expositions, and publishes a magazine, newsletters and websites in the software development, SharePoint, mobile development and commercial UAV markets.
SYS-CON Events announced today that Cloudistics, an on-premises cloud computing company, has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Cloudistics delivers a complete public cloud experience with composable on-premises infrastructures to medium and large enterprises. Its software-defined technology natively converges network, storage, compute, virtualization, and management into a ...
Now that the world has connected “things,” we need to build these devices as truly intelligent in order to create instantaneous and precise results. This means you have to do as much of the processing at the point of entry as you can: at the edge. The killer use cases for IoT are becoming manifest through AI engines on edge devices. An autonomous car has this dual edge/cloud analytics model, producing precise, real-time results. In his session at @ThingsExpo, John Crupi, Vice President and Eng...
There are 66 million network cameras capturing terabytes of data. How did factories in Japan improve physical security at the facilities and improve employee productivity? Edge Computing reduces possible kilobytes of data collected per second to only a few kilobytes of data transmitted to the public cloud every day. Data is aggregated and analyzed close to sensors so only intelligent results need to be transmitted to the cloud. Non-essential data is recycled to optimize storage.
"I think that everyone recognizes that for IoT to really realize its full potential and value that it is about creating ecosystems and marketplaces and that no single vendor is able to support what is required," explained Esmeralda Swartz, VP, Marketing Enterprise and Cloud at Ericsson, in this SYS-CON.tv interview at @ThingsExpo, held June 7-9, 2016, at the Javits Center in New York City, NY.