1

Let me establish abstraction of the problem context. We have a product that performs some function which we want to keep customizable. We are providing framework wherein the other developer team can modify how certain function behaves by specifying groovy script, which will be called by our framework. Their groovy script usually performs rest calls which turns out to be synchronous. So if we have multiple places in our framework where such groovy scripts can be specified, then each of those rest calls in different specified groovy script results in synchronous blocking of threads. Is their any way we can make those groovy scripts do asynchronous rest calls so that once the call is made, the thread can do some other work (say execute other groovy script), and when the result from that rest call is received the corresponding groovy script resumes immediately after the rest call?

Quick googling "groovy async" give this as a first search result. If I understand the article correctly, it simply makes async call and resumes execution immediately after the call statement. This is not I need in my scenario, I want to suspend execution of the script after async call, let thread do something else, and resume script once call result is received?

Is it doable with some minimal modification required to given groovy script? Say with some custom annotation added to the methods making rest calls (as in case of above linked dzone article)? Does the groovy language provide something like this out of the box? Or does even Java (since I can have pure Java in groovy) provide something like this out of the box? It seems that I have poor experience in async programming for something to strike in my head to resolve this requirement.

Edit

  1. Had a thought about whether I am, in fact, looking for "async rest"? Does async rest (something like this) meet my need?
  2. Someone seems to have voted for closing question with the reason that the answer can be opinion based. I dont want opinions here. I am unaware of any possible solution. So I want to know what is usually used in such situation by developer community. Now their may be different solutions. But I dont want to compare them as better and worse. I just want to know if their is any and if yes what are they. No opinions involved!!!
Mahesha999
  • 22,693
  • 29
  • 116
  • 189

0 Answers0