Java – Asynchronous Java

Architecturehadoopjava

I'm wondering if I wanted to implement a web service based on java that does web analytics, what sort of architecture should I use. The actualy processing of the Big Data would be done by Hadoop.

However I am not sure what I would need to do to make it asynchronous, or is Hadoop already asynchronous by nature? Could I do something with JMS? If so, how would that fit into the whole thing? Would it be something along the lines that upon receiving the web service request, I use JMS to send a message to Hadoop to handle a particular data, and then wait for it to come back to me? I am not too familiar with asynchronous java so I'm not sure where to start.

Best Answer

" I use JMS to send a message to Hadoop to handle a particular data, and then wait for it to come back to me" -- this is using an asynchronous protocol to implement a synchronous interaction.

Is there any need for your program to wait for the reply? If there is couldn't you have another process handle the replies?

There are several asynchronous patterns you could use depending on your requirements:-

  • "Fire and Forget" simply put the request in a queue and trust the receiving process to apply the changes.
  • "Send and Poll" - loop around put all your requests on the queue, process all the replies.
  • "sender and receiver processes" -- have different processes, programs threads or whatever, one or more to send requests, one or more to handle replies.
Related Topic