0

We have a requirement to design and implement the asynchronous web services. Here asynchronous web service communication meaning that a client places a request and he don't wait for the response from service. Although, it can achieved using AJAX or some other form but that is not our requirement.

I am looking to implement it using Message Ques and JMS(needs to read messages from request que and post messages to response que ).

Request: client->Message que->Web Service Response: webservice ->Message Que->Client

Here we are also trying to leverage Enterprise Service Bus for load balancing or any other product.

Is it the right way of implementing or any other way of implementing it. thanks

esha
  • 91
  • 8

1 Answers1

0

You can implement a service where a client can communicate with it asynchronously and provide a callback address to which the service can send response messages.To have this communication pattern work effectively you need to have proper message correlation mechanism between request and response.

This can be implemented simply with SOAP Webservice.

  1. Client sends request with unique request id and call-back address to the service provider.

  2. Service Provider receives the request and immediately ack to client. when response is ready it calls client on the callback address.

  3. Service provider can implement queue to service multiple requests/clients.

Complexity here is you need to manage queue and correlation logic.

Most of the ESB's support asynchronous communication pattern, you can check how it be achived with FUSE ESB

ravthiru
  • 8,878
  • 2
  • 43
  • 52
  • Thanks @ravthiru . Here point 3 talks about ques, do you mean message ques on middle server?. Also my requiremnet is client may not stay on same page after he placed request and won't wait for response. He may come back later. But with your approach its call back . Does it work? – esha Aug 05 '16 at 12:17
  • If you use Middleware like ESB, then it should take care of request Queues. – ravthiru Aug 06 '16 at 01:54
  • Client should implement Response handler to handle server responses received through callback uRL. – ravthiru Aug 06 '16 at 02:04
  • You can implement simple Asynchronous Invocation Model as here http://cxf.apache.org/docs/developing-a-consumer.html – ravthiru Aug 06 '16 at 13:23
  • Thanks @ravthiru for the link again. It suggests two asynchronous methods 1) polling approach 2) call back method . I think these methods are usefull when waiting for the response in the same session of the client. Once the client disconnected, i don't think there is way the response will be received. – esha Aug 08 '16 at 01:55
  • If you want client to handle response even after disconnection, your client need to expose a service to receive response. Basically Client should be running in Web server exposing a callback URL. – ravthiru Aug 08 '16 at 05:07
  • Sorry, I did not get that. How about the Message queues or ESB Queues so the client need not be active right. – esha Aug 08 '16 at 23:18
  • Yes If client is in ESB then it can use Inbound Message Queues. If it is external then client needs to implement the logic – ravthiru Aug 09 '16 at 00:25
  • if client is external to ESB, it can access the ESB and places message and disconnect, and later cosume the response from ESB queues .http://stackoverflow.com/questions/5322675/jms-and-esb-how-they-are-related?rq=1 – esha Aug 09 '16 at 00:35
  • In that case client should implement polling of the queues or consumers of the message – ravthiru Aug 09 '16 at 00:56