I'm not sure if Aries Async uses the Promise API in a substitutable way, but the latest version of the Promise API has timeout methods [1].
Perhaps Tim Ward could shed some light on this? One option is simply to try to use the lastest Promise API along with Aries Async. Sincerely, - Ray [1] https://osgi.org/specification/osgi.cmpn/7.0.0/util.promise.html#util.promise-timing.methods On Fri, Jan 25, 2019 at 7:07 AM Lorr, Sebastian < sebastian.l...@its-digital.de> wrote: > Hi there, > > > > I want to call a Service and wait for a given time for a response. > > So I did a async servicecall like this: > > > > // Create mediator, to call service asynchronously > > IMyService mediated = asyncService.mediate(myService, IMyService.class); > > > > // Call service and await promise to be fulfilled > > Promise<Result> promise = asyncService.call(mediated.process()); > > boolean timeoutExceeded = false; > > long startTime = Calendar.getInstance().getTimeInMillis(); > > > > serviceTimeoutMillis = 100; > > // Wait until timeout for promise to be done > > while (!promise.isDone()) { > > Thread.sleep(10); > > if (Calendar.getInstance().getTimeInMillis() > startTime > + serviceTimeoutMillis) { > > timeoutExceeded = true; > > break; > > } > > } > > if (timeoutExceeded) { > throw new TimeoutException("Timeout exceeded"); > } > > > Now the question: is there a better way for waiting for promise-resolve > until a given timeout? > > Maybe some feature of Async that i missed? > > > > > > Thanks in advance, > > > > Sebastian > > > ---------------------------------------------------------------- > Sebastian Lorr > ITS Digital Solutions GmbH > Dillenburger Str. 77 > D-51105 Köln > Tel.: +49 (0)221 820 07 0 > Fax : +49 (0)221 820 07 22 <%2B49%20%280%29221%20820%2007%2022> > Mail: i...@its-telco.de > Web : http://www.its-telco.de > ---------------------------------------------------------------- > Sitz der Gesellschaft: Dortmund > Amtsgericht Dortmund, HRB 28563 > Geschäftsführer: Gunnar Haack, Ludger Schulte, Heinrich Toben, Raimund > Schipp, Ralf Petersilka > ---------------------------------------------------------------- > > Diese E-Mail enthält vertrauliche Informationen. Wenn Sie nicht der > richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, > informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. > Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist > nicht gestattet. > > This e-mail may contain confidential information. If you are not the > intended recipient (or have received this e-mail in error) please notify > the sender immediately and destroy this e-mail. Any unauthorised copying, > disclosure or distribution of the material in this e-mail is strictly > forbidden. > > -- *Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile> (@rotty3000) Senior Software Architect *Liferay, Inc.* <http://www.liferay.com> (@Liferay) Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)