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


Java EventBusService.getProxy方法代码示例

本文整理汇总了Java中io.vertx.servicediscovery.types.EventBusService.getProxy方法的典型用法代码示例。如果您正苦于以下问题:Java EventBusService.getProxy方法的具体用法?Java EventBusService.getProxy怎么用?Java EventBusService.getProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.servicediscovery.types.EventBusService的用法示例。


在下文中一共展示了EventBusService.getProxy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authUaaHandler

import io.vertx.servicediscovery.types.EventBusService; //导入方法依赖的package包/类
private void authUaaHandler(RoutingContext context) {
  if (context.user() != null) {
    JsonObject principal = context.user().principal();
    String username = null;  // TODO: Only for demo. Complete this in next version.
    // String username = KeycloakHelper.preferredUsername(principal);
    if (username == null) {
      context.response()
        .putHeader("content-type", "application/json")
        .end(new Account().setId("TEST666").setUsername("Eric").toString()); // TODO: no username should be an error
    } else {
      Future<AccountService> future = Future.future();
      EventBusService.getProxy(discovery, AccountService.class, future.completer());
      future.compose(accountService -> {
        Future<Account> accountFuture = Future.future();
        accountService.retrieveByUsername(username, accountFuture.completer());
        return accountFuture.map(a -> {
          ServiceDiscovery.releaseServiceObject(discovery, accountService);
          return a;
        });
      })
        .setHandler(resultHandlerNonEmpty(context)); // if user does not exist, should return 404
    }
  } else {
    context.fail(401);
  }
}
 
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:27,代码来源:APIGatewayVerticle.java

示例2: start

import io.vertx.servicediscovery.types.EventBusService; //导入方法依赖的package包/类
@Override
public void start(Future<Void> future) {
    super.start();

    // Get configuration
    config = ConfigFactory.load();

    String company = TraderUtils.pickACompany();
    int numberOfShares = TraderUtils.pickANumber();

    EventBus eventBus = vertx.eventBus();
    EventBusService.getProxy(discovery, PortfolioService.class, ar -> {
        if (ar.failed()) {
            System.out.println("Portfolio service could not be retrieved: " + ar.cause());
        } else {
            // Our services:
            PortfolioService portfolio = ar.result();
            MessageConsumer<JsonObject> marketConsumer = eventBus.consumer(config.getString("market.address"));

            // Listen to the market...
            marketConsumer.handler(message -> {
                JsonObject quote = message.body();
                TraderUtils.dumbTradingLogic(company, numberOfShares, portfolio, quote);
            });
        }
    });
}
 
开发者ID:docker-production-aws,项目名称:microtrader,代码行数:28,代码来源:CompulsiveTraderVerticle.java

示例3: example3

import io.vertx.servicediscovery.types.EventBusService; //导入方法依赖的package包/类
public void example3(ServiceDiscovery discovery) {
  EventBusService.getProxy(discovery, MyService.class, ar -> {
    if (ar.succeeded()) {
      MyService service = ar.result();

      // Dont' forget to release the service
      ServiceDiscovery.releaseServiceObject(discovery, service);
    }
  });
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:11,代码来源:EventBusServiceJavaExamples.java

示例4: retrieveCounter

import io.vertx.servicediscovery.types.EventBusService; //导入方法依赖的package包/类
/**
 * Fetch global counter of order from the cache infrastructure.
 *
 * @param key counter key (type)
 * @return async result of the counter
 */
private Future<Long> retrieveCounter(String key) {
  Future<Long> future = Future.future();
  EventBusService.getProxy(discovery, CounterService.class,
    ar -> {
      if (ar.succeeded()) {
        CounterService service = ar.result();
        service.addThenRetrieve(key, future.completer());
      } else {
        future.fail(ar.cause());
      }
    });
  return future;
}
 
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:20,代码来源:CheckoutServiceImpl.java

示例5: getCurrentCart

import io.vertx.servicediscovery.types.EventBusService; //导入方法依赖的package包/类
private Future<ShoppingCart> getCurrentCart(String userId) {
  Future<ShoppingCartService> future = Future.future();
  EventBusService.getProxy(discovery, ShoppingCartService.class, future.completer());
  return future.compose(service -> {
    Future<ShoppingCart> cartFuture = Future.future();
    service.getShoppingCart(userId, cartFuture.completer());
    return cartFuture.compose(c -> {
      if (c == null || c.isEmpty())
        return Future.failedFuture(new IllegalStateException("Invalid shopping cart"));
      else
        return Future.succeededFuture(c);
    });
  });
}
 
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:15,代码来源:CheckoutServiceImpl.java

示例6: saveCheckoutEvent

import io.vertx.servicediscovery.types.EventBusService; //导入方法依赖的package包/类
/**
 * Save checkout cart event for current user.
 *
 * @param userId user id
 * @return async result
 */
private Future<Void> saveCheckoutEvent(String userId) {
  Future<ShoppingCartService> future = Future.future();
  EventBusService.getProxy(discovery, ShoppingCartService.class, future.completer());
  return future.compose(service -> {
    Future<Void> resFuture = Future.future();
    CartEvent event = CartEvent.createCheckoutEvent(userId);
    service.addCartEvent(event, resFuture.completer());
    return resFuture;
  });
}
 
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:17,代码来源:CheckoutServiceImpl.java

示例7: start

import io.vertx.servicediscovery.types.EventBusService; //导入方法依赖的package包/类
@Override
public void start(Future<Void> future) {
  super.start();

  //----
  // Initialize the trader
  String company = TraderUtils.pickACompany();
  int numberOfShares = TraderUtils.pickANumber();
  System.out.println("Java compulsive trader configured for company " + company + " and shares: " + numberOfShares);

  // We need to retrieve two services, create two futures object that will get the services
  Future<MessageConsumer<JsonObject>> marketFuture = Future.future();
  Future<PortfolioService> portfolioFuture = Future.future();
  // Retrieve the services, use the "special" completed to assign the future
  MessageSource.getConsumer(discovery, new JsonObject().put("name", "market-data"), marketFuture);
  EventBusService.getProxy(discovery, PortfolioService.class, portfolioFuture);

  // When done (both services retrieved), execute the handler
  CompositeFuture.all(marketFuture, portfolioFuture).setHandler(ar -> {
    if (ar.failed()) {
      future.fail("One of the required service cannot " +
          "be retrieved: " + ar.cause());
    } else {
      // Our services:
      PortfolioService portfolio = portfolioFuture.result();
      MessageConsumer<JsonObject> marketConsumer = marketFuture.result();

      // Listen the market...
      marketConsumer.handler(message -> {
        JsonObject quote = message.body();
        TraderUtils.dumbTradingLogic(company, numberOfShares, portfolio, quote);
      });

      future.complete();
    }
  });
  // ----
}
 
开发者ID:cescoffier,项目名称:vertx-microservices-workshop,代码行数:39,代码来源:JavaCompulsiveTraderVerticle.java

示例8: getProxy

import io.vertx.servicediscovery.types.EventBusService; //导入方法依赖的package包/类
public <T> void getProxy(Class<T> serviceClass, Handler<AsyncResult<T>> handler) {
    EventBusService.getProxy(serviceDiscovery, serviceClass, handler);
}
 
开发者ID:GwtDomino,项目名称:domino,代码行数:4,代码来源:EventBusServiceDiscovery.java

示例9: getProductService

import io.vertx.servicediscovery.types.EventBusService; //导入方法依赖的package包/类
/**
 * Get product service from the service discovery infrastructure.
 *
 * @return async result of the service.
 */
private Future<ProductService> getProductService() {
  Future<ProductService> future = Future.future();
  EventBusService.getProxy(discovery, ProductService.class, future.completer());
  return future;
}
 
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:11,代码来源:ShoppingCartServiceImpl.java


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