views:

2252

answers:

10

I was just reading abit about JMS and Apache ActiveMQ. And was wondering what real world use have people here used JMS or similar message queue technologies for ?

+8  A: 

Use them all the time to process long-running operations asynchronously. A web user won't want to wait for more than 5 seconds for a request to process. If you have one that runs longer than that, one design is to submit the request to a queue and immediately send back a URL that the user can check to see when the job is finished.

Publish/subscribe is another good technique for decoupling senders from many receivers. It's a flexible architecture, because subscribers can come and go as needed.

duffymo
After reading your answer I'm going to add JMS to my queue 'What I'm going to learn this year' :)
Roman
+2  A: 

Distributed (a)synchronous computing.
A real world example could be an application-wide notification framework, which sends mails to the stakeholders at various points during the course of application usage. So the application would act as a Producer by create a Message object, putting it on a particular Queue, and moving forward.
There would be a set of Consumers who would subscribe to the Queue in question, and would take care handling the Message sent across. Note that during the course of this transaction, the Producers are decoupled from the logic of how a given Message would be handled.
Messaging frameworks (ActiveMQ and the likes) act as a backbone to facilitate such Message transactions by providing MessageBrokers.

pugmarx
+8  A: 

JMS (ActiveMQ is a JMS broker implementation) can be used as a mechanism to allow asynchronous request processing. You may wish to do this because the request take a long time to complete or because several parties may be interested in the actual request. Another reason for using it is to allow multiple clients (potentially written in different languages) to access information via JMS. ActiveMQ is a good example here because you can use the STOMP protocol to allow access from a C#/Java/Ruby client.

A real world example is that of a web application that is used to place an order for a particular customer. As part of placing that order (and storing it in a database) you may wish to carry a number of additional tasks:

  • Store the order in some sort of third party back-end system (such as SAP)
  • Send an email to the customer to inform them their order has been placed

To do this your application code would publish a message onto a JMS queue which includes an order id. One part of your application listening to the queue may respond to the event by taking the orderId, looking the order up in the database and then place that order with another third party system. Another part of your application may be responsible for taking the orderId and sending a confirmation email to the customer.

Jon
+1  A: 

We have used messaging to generate online Quotes

Krishna
+13  A: 

I've had so many amazing uses for JMS:

  • Web chat communication for customer service.

  • Debug logging on the backend. All app servers broadcasted debug messages at various levels. A JMS client could then be launched to watch for debug messages. Sure I could've used something like syslog, but this gave me all sorts of ways to filter the output based on contextual information (e.q. by app server name, api call, log level, userid, message type, etc...). I also colorized the output.

  • Debug logging to file. Same as above, only specific pieces were pulled out using filters, and logged to file for general logging.

  • Alerting. Again, a similar setup to the above logging, watching for specific errors, and alerting people via various means (email, text message, IM, Growl pop-up...)

  • Dynamically configuring and controlling software clusters. Each app server would broadcast a "configure me" message, then a configuration daemon that would respond with a message containing all kinds of config info. Later, if all the app servers needed their configurations changed at once, it could be done from the config daemon.

  • And the usual - queued transactions for delayed activity such as billing, order processing, provisioning, email generation...

It's great anywhere you want to guarantee delivery of messages asynchronously.

mikesomeone
+2  A: 

We use it to initiate asynchronous processing that we don't want to interrupt or conflict with an existing transaction.

For example, say you've got an expensive and very important piece of logic like "buy stuff", an important part of buy stuff would be 'notify stuff store'. We make the notify call asynchronous so that whatever logic/processing that is involved in the notify call doesn't block or contend with resources with the buy business logic. End result, buy completes, user is happy, we get our money and because the queue is guaranteed delivery the store gets notified as soon as it opens or as soon as there's a new item in the queue.

Kevin Williams
+1  A: 

I have seen JMS used in different commercial and academic projects. JMS can easily come into your picture, whenever you want to have a totally decoupled distributed systems. Generally speaking, when you need to send your request from one node, and someone in your network takes care of it without/with giving the sender any information about the receiver.

In my case, I have used JMS in developing a message-oriented middleware (MOM) in my thesis, where specific types of object-oriented objects are generated in one side as your request, and compiled and executed on the other side as your response.

paradisonoir
+1  A: 

I've used it to send intraday trades between different fund management systems. If you want to learn more about what a great technology messaging is, I can thoroughly recommend the book "Enterprise Integration Patterns". There are some JMS examples for things like request/reply and publish/subscribe.

Messaging is an excellent tool for integration.

RichardOD
+1  A: 

Apache Camel used in conjunction with ActiveMQ is great way to do Enterprise Integration Patterns

Rob Davies
A: 

Cross-language / cross-platform computing and legacy application integration.

Most JMS brokers offer support for non-Java clients, for example using the Stomp protocol. Clients can be written easily in C, Delphi, Ruby, Perl, Python, PHP, ActionScript/Flash, Smalltalk.

So an existing PHP web shop could post new orders to a JMS broker, this will trigger processing on a Java application server cluster, and also notifies a Delphi front end.

Another typical use case is load balancing: incoming requests will be added to a queue, and the consumers of the queue are running on different computers. Every queue entry will be processed by exactly one client.

mjustin