io.vertx.rxjava.ext.jdbc.JDBCClient Java Examples
The following examples show how to use
io.vertx.rxjava.ext.jdbc.JDBCClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuditVerticle.java From vertx-microservices-workshop with Apache License 2.0 | 6 votes |
/** * Starts the verticle asynchronously. The the initialization is completed, it calls * `complete()` on the given {@link Future} object. If something wrong happens, * `fail` is called. * * @param future the future to indicate the completion */ @Override public void start(Future<Void> future) { super.start(); // creates the jdbc client. jdbc = JDBCClient.createNonShared(vertx, config()); // TODO // ---- Single<MessageConsumer<JsonObject>> readySingle = Single.error(new UnsupportedOperationException("not yet implemented")); // ---- readySingle.doOnSuccess(consumer -> { // on success we set the handler that will store message in the database consumer.handler(message -> storeInDatabase(message.body())); }).subscribe(consumer -> { // complete the verticle start with a success future.complete(); }, error -> { // signal a verticle start failure future.fail(error); }); }
Example #2
Source File: CartEventDataSourceImpl.java From vertx-blueprint-microservice with Apache License 2.0 | 5 votes |
public CartEventDataSourceImpl(io.vertx.core.Vertx vertx, JsonObject json) { this.client = JDBCClient.createNonShared(Vertx.newInstance(vertx), json); // TODO: Should not init the table here. client.rxGetConnection() .flatMap(connection -> connection.rxExecute(INIT_STATEMENT) .doAfterTerminate(connection::close) ) .subscribe(); }
Example #3
Source File: AuditVerticle.java From vertx-microservices-workshop with Apache License 2.0 | 5 votes |
/** * Starts the verticle asynchronously. The the initialization is completed, it calls * `complete()` on the given {@link Future} object. If something wrong happens, * `fail` is called. * * @param future the future to indicate the completion */ @Override public void start(Future<Void> future) { super.start(); // creates the jdbc client. jdbc = JDBCClient.createNonShared(vertx, config()); // ---- Single<Void> databaseReady = initializeDatabase(config().getBoolean("drop", false)); Single<Void> httpEndpointReady = configureTheHTTPServer() .flatMap(server -> rxPublishHttpEndpoint("audit", "localhost", server.actualPort())); Single<MessageConsumer<JsonObject>> messageConsumerReady = retrieveThePortfolioMessageSource(); Single<MessageConsumer<JsonObject>> readySingle = Single.zip( databaseReady, httpEndpointReady, messageConsumerReady, (db, http, consumer) -> consumer); // ---- readySingle.doOnSuccess(consumer -> { // on success we set the handler that will store message in the database consumer.handler(message -> storeInDatabase(message.body())); }).subscribe(consumer -> { // complete the verticle start with a success future.complete(); }, error -> { // signal a verticle start failure future.fail(error); }); }
Example #4
Source File: SQLTestBase.java From vertx-rx with Apache License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); client = new JDBCClient(io.vertx.ext.jdbc.JDBCClient.create(vertx, config)); client.rxGetConnection().flatMapCompletable(conn -> { Completable setup = conn.rxExecute("drop table folks if exists").toCompletable() .andThen(conn.rxExecute("create table folks (firstname varchar(255) not null)").toCompletable()); for (String name : NAMES) { setup = setup.andThen(conn.rxExecute(String.format(INSERT_FOLK_SQL, name)).toCompletable()); } return setup.doAfterTerminate(conn::close); }).await(); }
Example #5
Source File: UsingConnectionSafetyTest.java From vertx-rx with Apache License 2.0 | 4 votes |
@Override public void setUp() throws Exception { super.setUp(); client = new JDBCClient(io.vertx.ext.jdbc.JDBCClient.create(vertx, config)); }