0

I'm trying to develop a database service proxy and using an verticle that extends io.vertx.reactivex.core.AbstractVerticle, so that I can use rxJava semantics around database calls. Problem is, when I code generate the service proxy, I get this:

ServiceVertxEBProxy.java:[37,1] a type with the same simple name is already defined by the single-type-import of io.vertx.core.Vertx

The database service is responsible for dealing with the shared dbclient, which I am doing by:

    public Single<SQLConnection> getConnection()
{
    JDBCClient dbClient = JDBCClient.createShared( vertx, CONFIG, DATASOURCE );

    return dbClient.rxGetConnection().flatMap( conn -> {
        Single<SQLConnection> connectionSingle = Single.just( conn );
        return connectionSingle.doFinally( conn::close );
    } );
}

Is it possible to use @ProxyGen to create a proxy client that references rxJava in the service?

For reference, the interface declares factory methods to instantiate the service by following the vertx.io documention.

import io.vertx.reactivex.core.Vertx;

@ProxyGen
public interface ChatDbService
{
    static ChatDbService create( Vertx vertx )
    {
        return new ChatDbServiceImpl( vertx );
    }

    static ChatDbService createProxy( Vertx vertx, String address )
    {
        return new ChatDbServiceVertxEBProxy( vertx.getDelegate(), address );
    }

} 

Help and insight would be appreciated.

Robin Coe
  • 750
  • 7
  • 28

2 Answers2

1

The service proxy generation is not able to work with RxJava as it uses the Vert.x asynchronous model. Since you are not posting the ServiceVertx interface it is not really possible to give you further advices concerning your application, if you can we can further elaborate.

Julien Viet
  • 335
  • 1
  • 3
  • The interface here is the source for the generated ServiceVertxEBProxy in the log message, I missed the prefix when I copied the trace. I also left out the @Fluent method definitions, because it was just the factories that cause the build failure. Being new to vertx+rx, I'm not sure about the plain vert.x model and why it's not asynchronous. Is that because vert.x uses callback semantics, which is synchronous in the message passing semantics? The example I posted is just one of several variants that have this compile failure. I just thought it was a namespace collision, not compatibility. – Robin Coe Sep 12 '18 at 01:36
  • ...is there anything I can put in the question to help diagnose, or is the answer just that I can't use a reactive vertx reference in the service interface? Essentially, I'm doing what the wiki example does; http verticle + db verticle, which I connect with a service proxy. The http verticle calls the proxy method that is implemented in a ServiceImpl that implements the interface. Plan was to start the db verticle and instantiate the dBserviceImpl using the factory. Barring that, I guess I could just use the dbServiceImpl(vertx) constructor directly from the db verticle and bypass the fac? – Robin Coe Sep 12 '18 at 01:49
0

Not sure if this this is what you want, but we wanted @ProxyGen to generate an Rxified API for us and stumbled upon a solution. We found that you need to include this dependency and then @ProxyGen will create a package called reactivex with the Rxified generated service.

    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-rx-java2</artifactId>
    </dependency>
Pete
  • 3,246
  • 4
  • 24
  • 43