• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Http Post

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The original flow is server A will send http post to my server then my server will massage data and send to server B. Server B will response to my server and response back to server A. Please see working flow as following :

'Server A' -> 'My server' -> 'Server B' -> 'My server' -> 'Server A'

The server encounter timeout issue because Server B taking too long to process the data. Therefore i intend to change the flow as below:

'Server A' -> 'My server' -> 'Server A'(immediately reply back to server A as acknowledge)

After response back to server A, then only 'My server' -> 'Server B' -> 'My server'. Is that anyway to do so?

 
Saloon Keeper
Posts: 7627
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How will your server get back to server A? Does it have an HTTP callback where your server can post the results?
 
ts wong
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't need callback to Server A after first time acknowledge. I knew this process can be done by thread. Besides of thread is there other way to do so?
 
Tim Moores
Saloon Keeper
Posts: 7627
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I don't need callback to Server A after first time acknowledge.


Does that mean server A does not need the results? If your server sends an immediate HTTP response to server A, then there is no way to send another response later.
 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Tim is trying to say, that server A needs a servlet, JSP page or something similar that your server can call when it's actually done. The process is then like this:
 
Saloon Keeper
Posts: 28070
198
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTTP is based on a strict request/response protocol. For each request there can be one and only one response. Furthermore, responses cannot come unsolicited, only in response to a request. Finally, the response can only be returned to the place the request came from.

So no, client cannot request server A to request to server B to respond directly to client.

The usual way to handle time-related problems like this is to hand the intermediate processing over to an out-of-band component, which makes the server B request and gets back the result. Client can then poll server A until server A is ready to pass back the results from server B. This not only satisfies HTTP restrictions, it hides details of the back-end processes, so that the client is insulated from changes in the back end.

One very critical thing to note when using an out-of-band manager for long-running processes (what I usually call an engine), is that servlets and JSPs are expressly forbidden by the J2EE standard to either wait on long-running processes OR to spawn threads. So the engine thread needs to be spawned outside of the servlet/JSP request-processing context. This was formerly done in a servlet's init() method, but commonly these days is done in a servletcontext listener.
 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic