• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sync or Async Web Service?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm putting together a web service which will accept a batch of XML, which could be pretty big, and put it onto a queue for processing.

It's turning out to be a bit more complicated than I originally hoped. A synchronous service would be easiest, and simplest, but what are the chances of timing out? I'm not sure. So, I have been planning on an asynchronous service, to play it safe.

For an asynchronous service, Axis2 relies on WS-addressing, which could have firewall issues, per this post from Peer Reynders at https://coderanch.com/t/224525/Web-Services/java/Asynchronous-Web-services-with-Axis.

Peer suggested in that post that using a non-blocking client might work, but that again poses the timeout issue.

Finally, to defeat the timeout problem, he suggests using a correlation identifier, which means that the initial request is assigned an id which is returned to the client. and have the client poll for the result, using the id. A message handler to designed to ignore overly aggressive client polls made within some threshold interval could be added ref http://www.ibm.com/developerworks/webservices/library/ws-asynch2/#4

But, if I configure the service to be asynchronous, then it will create a separate thread to do the processing - including writing to the queue. This would lessen the chances of a timeout, correct?

For the acknowledgment, I could use a correlation identifier/batch number, and maybe send an email to the client. I could get the email from the data itself, or maybe I could look it up on for the customer locally. I don't necessarily even need to send the client an acknowledgment, but it would probably be a good idea.

Does this make sense? In other words, I need to make this service asynchronous to lessen the risk of a timeout, right?








 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jack,

An interesting article about the subject at Working With Asynchronous .NET Web Service Clients.

Regards,
Dan
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

Jack Delerousse wrote:
But, if I configure the service to be asynchronous, then it will create a separate thread to do the processing - including writing to the queue. This would lessen the chances of a timeout, correct?


With reservations for not having completely understood the entire question, here are my thoughts:
The separate thread that processes the request to the web service only inserts the data received, that is the batch data, into a queue. The first step of processing the request is then done and the web service can now return a correlation identifier or such to the client.
Some time later, another thread, constantly running in the background, retrieves data from the queue and processes it.
Finally the processed data, with some association to the correlation identifier, is made available to the (other) web service operation which the client uses to poll for result data.
Reference:
http://java.sun.com/blueprints/guidelines/designing_webservices/html/architecture5.html#1147022

Does this make sense? In other words, I need to make this service asynchronous to lessen the risk of a timeout, right?


Yes, to me, this makes sense.

An alternative that I come to think of is to do SOAP over email. The client mails the request, with the batch data, to some mail address. The email is then processed by the service and, using for instance the reply-to email address, sent back to the client.

If using SOAP is not written in stone, another alternative is a RESTful web service that, as a result of POSTing the batch data, returns an URL at which the client can poll for the result.
Update: Just discovered that JBoss RESTeasy already has built-in support for this kind of asynchronous operations.
Best wishes!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic