java - How Do Applications handle Asynchronous Responses - via Callback -


i have been doing java few years have not had experience asynchronous programming.

i working on application makes soap web service calls synchronous web services , implementation of consuming application synchronous ie. applications threads block while waiting response.

i trying learn how handle these soap calls in asynchronous way - hell of have high-level questions cant seem find answers to.

i using cxf question not cxf or soap, higher-level, in terms of asynchronous application architecture think.

what want know (working thru scenario) - @ high level - is:

  1. so have thread (a) running in jvm makes call remote web service
  2. it registers callback method , returns future
  3. thread (a) has done bit , gets returned pool once has returned future
  4. the remote web service response returns , thread (b) gets allocated , calls callback method (which populates future result believe)

q1. cant head off blocking thread model - if thread (a) no longer listening network socket how response comes remote service allocated thread (b) - treated new request coming server/container allocates thread service it?

q2. closely related q1 imagine: if no thread has future, or handler (with callback method) on stack, how response remote web service associated callback method needs call?

or, in way of asking, how thread b (now dealing response) given reference future/callback object?


very sorry question long - , gave time read through it! :)

i don't see why you'd add complexity using asynchronous threading.

the way design asynchronous soap service: have 1 service sending out response given client / clients. clients work on response given asynchronously. when done, call soap method return response. response stored in queue (e.g. database table), without logic. you'd have "worker" service working on incoming tasks. if response needed again method on other remote service called. requests store events in database, later asynchronously handled eventhandler. see hexagonal architecture: https://www.youtube.com/watch?v=fgajhegonkg


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -