Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse Communications Framework (ECF) » Async delivery of result
Async delivery of result [message #1446481] Thu, 16 October 2014 22:58 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

I'm currently using Akka for async communication between a web server
and an Eclipse instance running on a server. The web client is a Java
code editor that continuously sends the editor content to the web
server, which passes it on to Eclipse. Eclipse sends back problem
markers, which are shown in the editor.

Now I'm considering using remote OSGi services instead. I naturally need
to use the async variant, since the web server (caller) shouldn't block
while waiting for the build on the Eclipse server to finish updating the
problem markers. However, the server (callee) also needs to be able to
answer in an async manner, i.e. when the source code is received, the
service implementation must update the corresponding workspace resource,
trigger the build and later be notified when it is finished. Hence, it
needs to be able to return a kind of inverted Future: an object that it
later will put a value into, and this should be delivered back as the
caller.

Is this possible with ECF?

Hallvard
--
Hallvard Traetteberg, Associate Professor
Dept. of Computer and Information Sciences (IDI)
Norwegian University of Science and Technology (NTNU)
Re: Async delivery of result [message #1446517 is a reply to message #1446481] Fri, 17 October 2014 00:23 Go to previous messageGo to next message
Scott Lewis is currently offline Scott LewisFriend
Messages: 1038
Registered: July 2009
Senior Member
Hi Hallvard,

Hallvard Traetteberg wrote on Thu, 16 October 2014 18:58
Hi,

I'm currently using Akka for async communication between a web server
and an Eclipse instance running on a server. The web client is a Java
code editor that continuously sends the editor content to the web
server, which passes it on to Eclipse. Eclipse sends back problem
markers, which are shown in the editor.

Now I'm considering using remote OSGi services instead. I naturally need
to use the async variant, since the web server (caller) shouldn't block
while waiting for the build on the Eclipse server to finish updating the
problem markers. However, the server (callee) also needs to be able to
answer in an async manner, i.e. when the source code is received, the
service implementation must update the corresponding workspace resource,
trigger the build and later be notified when it is finished. Hence, it
needs to be able to return a kind of inverted Future: an object that it
later will put a value into, and this should be delivered back as the
caller.

Is this possible with ECF?


The short answer is: Yes!

There are a couple of different ways this could be done with ECF's impl of OSGi Remote Services, and I'm first going to respond with just one of these ways.

First approach: With Java8 there is a new, very useful class introduced called java.util.concurrent.CompletableFuture see [1].

With recent versions (since ECF 3.8.1/Luna) we have introduced the use of CompletableFuture for ECF's asychronous remote services. Here [2] is a tutorial that uses async remote services. See toward the bottom of page for use of CompletableFuture. And here [3] is a page giving some more description of asynchronous remote services in general, using either Future or CompletableFuture (up to how you define the asynchronous remote service interface).

As I said, there other ways (that don't require Java8), but given your stated desire to have an 'inverted Future' this seemed like the most direct way to start.

For a more open dialog and support it might be useful for you to also bring this topic up on the ecf-dev mailing list (where more committers and contributors regularly monitor). You can join the mailing list by going here [4].

Thanks,

Scott

[1] http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html
[2] https://wiki.eclipse.org/Tutorial:_Building_your_first_Asynchronous_OSGi_Remote_Service
[3] https://wiki.eclipse.org/ECF/Asynchronous_Remote_Services
[4] https://dev.eclipse.org/mailman/listinfo/ecf-dev

[/quote]
Re: Async delivery of result [message #1446763 is a reply to message #1446517] Fri, 17 October 2014 09:11 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Scott,

I had already read the pages you refer to, which explains how to handle
the async case in the caller end, but I didn't find an explanation of
how to handle the async case in the callee end.

If I understand this correctly, the (server-side) callee implements a
service method defined to return a CompletableFuture. When it is called
it returns a CompletableFuture immediately, and later completes it. In
my case, completion (i.e. call to complete) will happen when the build
is finished and notifies a listener, which may be a lot later and from a
different thread.

I this works as expected, I think ECF's implementation of remote
services will be a lot cleaner for my case than using Akka. Akka is made
for (and superior for) general message passing, but in a
request/response model similar to methods calls, remove services is a
better fit.

Hallvard

On 17.10.14 02:23, Scott Lewis wrote:
> Hi Hallvard,
>
> Hallvard Traetteberg wrote on Thu, 16 October 2014 18:58
>> Hi,
>>
>> I'm currently using Akka for async communication between a web server
>> and an Eclipse instance running on a server. The web client is a Java
>> code editor that continuously sends the editor content to the web
>> server, which passes it on to Eclipse. Eclipse sends back problem
>> markers, which are shown in the editor.
>>
>> Now I'm considering using remote OSGi services instead. I naturally
>> need to use the async variant, since the web server (caller) shouldn't
>> block while waiting for the build on the Eclipse server to finish
>> updating the problem markers. However, the server (callee) also needs
>> to be able to answer in an async manner, i.e. when the source code is
>> received, the service implementation must update the corresponding
>> workspace resource, trigger the build and later be notified when it is
>> finished. Hence, it needs to be able to return a kind of inverted
>> Future: an object that it later will put a value into, and this should
>> be delivered back as the caller.
>>
>> Is this possible with ECF?
>
>
> The short answer is: Yes!
> There are a couple of different ways this could be done with ECF's impl
> of OSGi Remote Services, and I'm first going to respond with just one of
> these ways.
>
> First approach: With Java8 there is a new, very useful class
> introduced called java.util.concurrent.CompletableFuture see [1].
>
> With recent versions (since ECF 3.8.1/Luna) we have introduced the use
> of CompletableFuture for ECF's asychronous remote services. Here [2] is
> a tutorial that uses async remote services. See toward the bottom of
> page for use of CompletableFuture. And here [3] is a page giving some
> more description of asynchronous remote services in general, using
> either Future or CompletableFuture (up to how you define the
> asynchronous remote service interface).
>
> As I said, there other ways (that don't require Java8), but given your
> stated desire to have an 'inverted Future' this seemed like the most
> direct way to start.
>
> For a more open dialog and support it might be useful for you to also
> bring this topic up on the ecf-dev mailing list (where more committers
> and contributors regularly monitor). You can join the mailing list by
> going here [4].
>
> Thanks,
>
> Scott
>
> [1]
> http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html
>
> [2]
> https://wiki.eclipse.org/Tutorial:_Building_your_first_Asynchronous_OSGi_Remote_Service
>
> [3] https://wiki.eclipse.org/ECF/Asynchronous_Remote_Services
> [4] https://dev.eclipse.org/mailman/listinfo/ecf-dev
>
> [/quote]
>
Previous Topic:Announce: ECF 3.9.0 released
Next Topic:ECF 3.9.1 Released
Goto Forum:
  


Current Time: Wed Apr 24 21:29:34 GMT 2024

Powered by FUDForum. Page generated in 0.03882 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top