当前位置: 首页>>代码示例>>Java>>正文


Java MessageConsumer类代码示例

本文整理汇总了Java中io.vertx.reactivex.core.eventbus.MessageConsumer的典型用法代码示例。如果您正苦于以下问题:Java MessageConsumer类的具体用法?Java MessageConsumer怎么用?Java MessageConsumer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessageConsumer类属于io.vertx.reactivex.core.eventbus包,在下文中一共展示了MessageConsumer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import io.vertx.reactivex.core.eventbus.MessageConsumer; //导入依赖的package包/类
@Override
public void start(Future<Void> future) {
    String company = TraderUtils.pickACompany();
    int numberOfShares = TraderUtils.pickANumber();
    System.out.println("Java-RX compulsive trader configured for company " + company + " and shares: " +
        numberOfShares);


    ServiceDiscovery.create(vertx, discovery -> {
        Single<PortfolioService> retrieveThePortfolioService = RXEventBusService.rxGetProxy(discovery, PortfolioService.class,
            rec -> rec.getName().equalsIgnoreCase("portfolio"));

        Single<MessageConsumer<JsonObject>> retrieveTheMarket = MessageSource.rxGetConsumer(discovery,
            rec -> rec.getName().equalsIgnoreCase("market-data"));

        //TODO
        //----

        // TODO 1 - "wait" for both single to be completed (using Single.zip or Single.zipWith methods)

        // TODO 2 - When both single have completed, attach the handler to the message consumer to execute the
        // trading logic

        // TODO 3 - Use the TraderUtils.drumpTradingLogic method returning a Completable. Don't forget to
        // subscribe to it, or nothing will happen. Return "true" to comply with the "zip" operator
        // signature.


        // TODO 4 - Transform the output into a Completable (toCompletable) and subscribe to it using:
        //.subscribe(CompletableHelper.toObserver(future)) - it reports the failure or success to the `done`
        // future.
        
        // To remove
        future.complete();
        //----

    });
}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-workshop,代码行数:39,代码来源:RXCompulsiveTraderVerticle.java

示例2: start

import io.vertx.reactivex.core.eventbus.MessageConsumer; //导入依赖的package包/类
/**
 * 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) {
    // creates the jdbc client.

    ServiceDiscovery.create(vertx, discovery -> {

        // Discover and configure the database.
        Single<JDBCClient> jdbc = JDBCDataSource.rxGetJDBCClient(discovery,
            svc -> svc.getName().equals("audit-database"),
            getDatabaseConfiguration()
        ).doOnSuccess(jdbcClient -> this.jdbc = jdbcClient);

        // TODO
        // ----

        Single<MessageConsumer<JsonObject>> readySingle = Single
            .error(new UnsupportedOperationException("Not implemented yet"));

        // ----

        // signal a verticle start failure
        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();
            // indicate our readiness state
            ready = true;
        }, future::fail);
    });


}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-workshop,代码行数:42,代码来源:AuditVerticle.java

示例3: start

import io.vertx.reactivex.core.eventbus.MessageConsumer; //导入依赖的package包/类
/**
 * 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) {
    // creates the jdbc client.

    ServiceDiscovery.create(vertx, discovery -> {

        // Discover and configure the database.
        Single<JDBCClient> jdbc = JDBCDataSource.rxGetJDBCClient(discovery,
            svc -> svc.getName().equals("audit-database"),
            getDatabaseConfiguration()
        ).doOnSuccess(jdbcClient -> this.jdbc = jdbcClient);

        // TODO
        // ----

        Single<JDBCClient> databaseReady = jdbc
            .flatMap(client -> initializeDatabase(client, true));
        Single<HttpServer> httpServerReady = configureTheHTTPServer();
        Single<MessageConsumer<JsonObject>> messageConsumerReady = retrieveThePortfolioMessageSource();

        Single<MessageConsumer<JsonObject>> readySingle = Single.zip(databaseReady, httpServerReady,
            messageConsumerReady, (db, http, consumer) -> consumer);

        // ----

        // signal a verticle start failure
        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();
            ready = true;
        }, future::fail);
    });


}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-workshop,代码行数:46,代码来源:AuditVerticle.java

示例4: eventBusMessages

import io.vertx.reactivex.core.eventbus.MessageConsumer; //导入依赖的package包/类
public void eventBusMessages(Vertx vertx) {
  EventBus eb = vertx.eventBus();
  MessageConsumer<String> consumer = eb.<String>consumer("the-address");
  Observable<Message<String>> observable = consumer.toObservable();
  Disposable sub = observable.subscribe(msg -> {
    // Got message
  });

  // Unregisters the stream after 10 seconds
  vertx.setTimer(10000, id -> {
    sub.dispose();
  });
}
 
开发者ID:vert-x3,项目名称:vertx-rx,代码行数:14,代码来源:RxifiedExamples.java

示例5: start

import io.vertx.reactivex.core.eventbus.MessageConsumer; //导入依赖的package包/类
@Override
public void start(Future<Void> future) {
    String company = TraderUtils.pickACompany();
    int numberOfShares = TraderUtils.pickANumber();
    System.out.println("Java-RX compulsive trader configured for company " + company + " and shares: " +
        numberOfShares);


    ServiceDiscovery.create(vertx, discovery -> {
        Single<PortfolioService> retrieveThePortfolioService = RXEventBusService.rxGetProxy(discovery, PortfolioService.class,
            rec -> rec.getName().equalsIgnoreCase("portfolio"));

        Single<MessageConsumer<JsonObject>> retrieveTheMarket = MessageSource.rxGetConsumer(discovery,
            rec -> rec.getName().equalsIgnoreCase("market-data"));

        //TODO
        //----

        // TODO 1 - "wait" for both single to be completed (using Single.zip or Single.zipWith methods)
        retrieveThePortfolioService.zipWith(retrieveTheMarket, (ps, consumer) -> {

        // TODO 2 - When both single have completed, attach the handler to the message consumer to execute the
            // trading logic

            consumer.handler(message ->
                // TODO 3 - Use the TraderUtils.drumpTradingLogic method returning a Completable. Don't forget to
                // subscribe to it, or nothing will happen. Return "true" to comply with the "zip" operator
                // signature.
                
                TraderUtils.dumbTradingLogic(company, numberOfShares, ps, message.body()).subscribe());
            // We need to return something as requested by the "zip" signature.
            return true;
        })

            // TODO 4 - Transform the output into a Completable (toCompletable) and subscribe to it using:
            //.subscribe(CompletableHelper.toObserver(future)) - it reports the failure or success to the `done`
            // future.
            .toCompletable()
            .subscribe(CompletableHelper.toObserver(future));
        //----

    });
}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-workshop,代码行数:44,代码来源:RXCompulsiveTraderVerticle.java

示例6: retrieveThePortfolioMessageSource

import io.vertx.reactivex.core.eventbus.MessageConsumer; //导入依赖的package包/类
private Single<MessageConsumer<JsonObject>> retrieveThePortfolioMessageSource() {
    // Example of Single returning a single item already known:
    return Single.just(vertx.eventBus().consumer("portfolio"));
}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-workshop,代码行数:5,代码来源:AuditVerticle.java

示例7: eventBusBodies

import io.vertx.reactivex.core.eventbus.MessageConsumer; //导入依赖的package包/类
public void eventBusBodies(Vertx vertx) {
  EventBus eb = vertx.eventBus();
  MessageConsumer<String> consumer = eb.<String>consumer("the-address");
  Observable<String> observable = consumer.bodyStream().toObservable();
}
 
开发者ID:vert-x3,项目名称:vertx-rx,代码行数:6,代码来源:RxifiedExamples.java


注:本文中的io.vertx.reactivex.core.eventbus.MessageConsumer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。