You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Krzysztof Chmielewski <kr...@gmail.com> on 2017/11/27 20:42:59 UTC

Compute async Job from Ignite Service and return IgniteFuture

Hi Team,
I have a question regarding Ignite Services and Compute async.

If we have a deployed IgniteService like this

public class MySercviceImpl implements Service, MyService {


@IgniteInstanceResource
  private Ignite ignite;
  
  @Override
  public IgniteFuture<Void> doStuff() {
    
    IgniteFuture<Void> runAsync =
ignite.compute(ignite.cluster().forLocal()).runAsync(new IgniteRunnable() {
      
      private static final long serialVersionUID = 1L;

      @Override
      public void run() {
       System.out.println(Thread.currentThread() + " Hello");
       System.out.println("World");
      }
    });
  
    return runAsync;
  }
}

Is it correct to call this service's method from a client and waits on
returned future? Something like this:
MyService serviceProxy = ignite.services().serviceProxy("MyService",
MyService.class, false);
IgniteFuture<Void> future = serviceProxy.doStuff();
future.get();

I've noticed that my client stuck on  doStuff.get();

Thanks
Krzysztof





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Compute async Job from Ignite Service and return IgniteFuture

Posted by vkulichenko <va...@gmail.com>.
Alexey,

The point of service proxy is that you use your own API to do remote
invocations. I don't think that adding this generic "reflection-like" API
makes sense here. For asynchronous executions I would just use Compute Grid.

-Val



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Compute async Job from Ignite Service and return IgniteFuture

Posted by Alexey Kukushkin <ku...@gmail.com>.
Val,

My understanding is Krzysztof asks how to call a long-running service
asynchronously. It looks like right now Ignite does not support that.

What do you think about extending Ignite so that we could write something
like:

IgniteServices services = ignite.services();

AsyncServiceProxy asyncProxy =
services.asyncServiceProxy("LongRunningService");

IgniteFuture<String> futureResult = asyncProxy.invoke("longMethod", param1,
param2);

<< DO something before the service complete >>

futureResult.chain(res -> { << Do something after the service completes. >>
});

Re: Compute async Job from Ignite Service and return IgniteFuture

Posted by Krzysztof Chmielewski <kr...@gmail.com>.
Hi, thanks for clarification.

My use case it that I have some logic that is hidden from client but client
can execute this logic by calling Ignite Service. 

Some of those operation may take a while, so I thought that it would be nice
to run it asynchronously and return Future object so the client would be
able to know the end result if he wants. 

Thanks
Krzysztof 



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Compute async Job from Ignite Service and return IgniteFuture

Posted by vkulichenko <va...@gmail.com>.
Krzysztof,

This will no work because service is invoked in server side and the returned
future gets serialized and sent to client. The deserialized instance is
obviously never completed. What are you trying to achieve?

-Val



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/