Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1
ajitnair Apr 27, 2012 12:30 PMHi,
We have a client-server application that currently uses Errai 1.3.2.Final. I'm trying to use the newer 2.0CR1 release and am having trouble upgrading to it. It appears our Errai RPC calls aren't being executed. Using Firebug in Firefox, we can see that the Errai heartbeats are working fine. But for the RPC calls we are seeing error messages like this:
[errai] [error] failed to transmit deferred message: CommandType=readAllTableNames:, .....
[errai] -> no subscribers to deliver to for subject: .......
It seems the client isn't seeing the RPC server.
We use both Spring and Guice in our code. Our setup is as follows:
1. We first instantiate Guice and bind the Errai classes to it like this:
// Manually bind Errai required classes in a Guice Injector.
Injector guiceInjector = Guice.createInjector(new AbstractModule() {
public void configure() {
bind(MessageBus.class).to(ServerMessageBusImpl.class);
bind(ServerMessageBus.class).to(ServerMessageBusImpl.class);
bind(ErraiServiceConfigurator.class).to(ErraiServiceConfiguratorImpl.class);
bind(ErraiService.class).to(ErraiServiceImpl.class);
}
});
2. Then we setup the service locator like this:
// Trigger initialization of the Errai Bus by requesting an instance of ErraiService.
@SuppressWarnings("rawtypes")
ErraiService erraiService = guiceInjector.getInstance(ErraiService.class);
// Place the application level singleton instance of ErraiService in a place that the
// Errai Servlet can later find it.
OurErraiServiceLocator.setErraiService(erraiService);
where OurErraiServiceLocator implements the ServiceLocator interface.
3. Then the Spring container is initialized where all of our Services are wired into the app.
4. And finally we register all the services now loaded in the Spring container with Errai. For each method in each service we create a bind point like this:
String bindPoint = RebindUtils.createCallSignature(serviceMethod); and then add it to a map (named messageEndpoints) with a callback like this:
messageEndpoints.put(bindPoint,
new ConversationalEndpointCallback(
new ServiceInstanceProvider() { <---- This used to be of type Provider<T> in the code using v1.3.2
@Override
public Object get(Message msg) { <--------- This used to be an empty parameter list in 1.3.2
return springServiceBean; <------------ THis is the bean obtained from the Spring container
}
}, serviceMethod, erraiMessageBus));
And finally we register the map with Errai like this:
5. erraiMessageBus.subscribe(remoteInterface.getName() + ":RPC", new RemoteServiceCallback(messageEndpoints));
Is this the right way to be registering Errai RPC services that were loaded in Spring? It has been working fine when using Errai 1.3.2. Or is there another way to be doing this?
Should we be registering the RPC services differently in 2