Skip to main content
added 347 characters in body
Source Link
leoismyname
  • 407
  • 1
  • 6
  • 12

I have got some legacy code in some middle application where request response methods are sync. Now the new interface to the back end is async, but i have to simulate the sync request in middle application. I need to make request call and will wait for the async response to come. It is multi threaded application where there will be multiple simultaneous requests and response.

I am wondering if there is a some kind of blocking queue in java where i can put the request object and wait till the response object with specified id(by equals method) is put back on queue. So there will be two method that will put the object on queue, lets say they are requestSender and responseReceiver. Request sender will put a request and wait and than responseReceiver put all the responses on the queue and when response object matches than only the associated requestSender will get the object and that that will return it to the frontend.

in short is there something like take(object) method in queue and it will only return when specific object get available on the queue.

If that is not possible with the blocking queue than what other approach should i use to simulate sync request-response in the middle application for front end when back end to middle application is async.

Thank you so much in advance.

I have got some legacy code in some middle application where request response methods are sync. Now the new interface to the back end is async, but i have to simulate the sync request in middle application. I need to make request call and will wait for the async response to come. It is multi threaded application where there will be multiple simultaneous requests and response.

I am wondering if there is a some kind of blocking queue in java where i can put the request object and wait till the response object with specified id(by equals method) is put back on queue. So there will be two method that will put the object on queue, lets say they are requestSender and responseReceiver. Request sender will put a request and wait and than responseReceiver put all the responses on the queue and when response object matches than only the associated requestSender will get the object and that that will return it to the frontend.

Thank you so much in advance.

I have got some legacy code in some middle application where request response methods are sync. Now the new interface to the back end is async, but i have to simulate the sync request in middle application. I need to make request call and will wait for the async response to come. It is multi threaded application where there will be multiple simultaneous requests and response.

I am wondering if there is a some kind of blocking queue in java where i can put the request object and wait till the response object with specified id(by equals method) is put back on queue. So there will be two method that will put the object on queue, lets say they are requestSender and responseReceiver. Request sender will put a request and wait and than responseReceiver put all the responses on the queue and when response object matches than only the associated requestSender will get the object and that that will return it to the frontend.

in short is there something like take(object) method in queue and it will only return when specific object get available on the queue.

If that is not possible with the blocking queue than what other approach should i use to simulate sync request-response in the middle application for front end when back end to middle application is async.

Thank you so much in advance.

Source Link
leoismyname
  • 407
  • 1
  • 6
  • 12

BlockingQueue to block and return object till the object with specified id becomes available on the queue

I have got some legacy code in some middle application where request response methods are sync. Now the new interface to the back end is async, but i have to simulate the sync request in middle application. I need to make request call and will wait for the async response to come. It is multi threaded application where there will be multiple simultaneous requests and response.

I am wondering if there is a some kind of blocking queue in java where i can put the request object and wait till the response object with specified id(by equals method) is put back on queue. So there will be two method that will put the object on queue, lets say they are requestSender and responseReceiver. Request sender will put a request and wait and than responseReceiver put all the responses on the queue and when response object matches than only the associated requestSender will get the object and that that will return it to the frontend.

Thank you so much in advance.