public <T extends Queryable> MessageConsumer<JsonObject> registerServiceConsumer(String address, T implementation) { MessageConsumer<JsonObject> serviceConsumer; if (!messageConsumers.containsKey(address)) { serviceConsumer = ProxyHelper.registerService(Queryable.class, vertx, implementation, address); messageConsumers.put(address, serviceConsumer); } else { serviceConsumer = messageConsumers.get(address); } consumerRegistrations.add(address); return serviceConsumer; }
public void start(Vertx vertx, String address) { service = ProxyHelper.registerService(HelloService.class, vertx, this, address); }
public void start(Vertx vertx, String address) { service = ProxyHelper.registerService(HelloService.class, vertx, this, address); }
public void start(Vertx vertx, String address) { service = ProxyHelper.registerService(HelloService.class, vertx, this, address); }
public void start(Vertx vertx, String address) { service = ProxyHelper.registerService(HelloService.class, vertx, this, address); }
@Override public void start() throws Exception { service = new RecommendationServiceImpl(vertx, config()); //TODO Change address to your own. ProxyHelper.registerService(RecommendationService.class, vertx, service, "devoxx.recommendations"); }
@Override public void start() throws Exception { service = new DataStorageServiceImpl(vertx, config()); //TODO Change address to something more specific ProxyHelper.registerService(DataStorageService.class, vertx, service, "devoxx.places"); }
@Override public void start() throws Exception { // Create the client object service = new MongoServiceImpl(MongoClient.createNonShared(vertx, config())); // And register it on the event bus against the configured address String address = config().getString("address"); if (address == null) { throw new IllegalStateException("address field must be specified in config for client verticle"); } ProxyHelper.registerService(MongoService.class, vertx, service, address); }
@Override public void start() throws Exception { ProxyHelper.registerService(Service.class, vertx, new ServiceProvider(), "my.service"); } }
@Override public void start() throws Exception { service = new ConsulServiceImpl(ConsulClient.create(vertx, new ConsulClientOptions(config()))); String address = config().getString("address"); if (address == null) { throw new IllegalStateException("address field must be specified in config for client verticle"); } messageConsumer = ProxyHelper.registerService(ConsulService.class, vertx, service, address); }
@Override public void start() { service = new MailServiceImpl(MailClient.createNonShared(vertx, new MailConfig(config()))); // And register it on the event bus against the configured address final String address = config().getString("address"); if (address == null) { throw new IllegalStateException("address field must be specified in config for client verticle"); } ProxyHelper.registerService(MailService.class, vertx, service, address); }
@Override public void start(Future<Void> future) throws Exception { super.start(); // create the service instance CounterService counterService = new DefaultCounterServiceImpl(vertx, config()); // register the service proxy on event bus ProxyHelper.registerService(CounterService.class, vertx, counterService, CounterService.SERVICE_ADDRESS); // publish the service in the discovery infrastructure publishEventBusService(CounterService.SERVICE_NAME, CounterService.SERVICE_ADDRESS, CounterService.class) .setHandler(future.completer()); } }
@Test public void testConnectionWithCloseFutureTimeout() { consumer.unregister(); consumer = ProxyHelper.registerService(TestService.class, vertx, service, SERVICE_ADDRESS, (long) 2); checkConnectionWithCloseFuture(proxy, System.currentTimeMillis(), 2L); await(); }
@Override public void start(Future<Void> future) throws Exception { super.start(); // create the service instance accountService = new JdbcAccountServiceImpl(vertx, config()); // register the service proxy on event bus ProxyHelper.registerService(AccountService.class, vertx, accountService, SERVICE_ADDRESS); // publish the service and REST endpoint in the discovery infrastructure publishEventBusService(SERVICE_NAME, SERVICE_ADDRESS, AccountService.class) .compose(servicePublished -> deployRestVerticle()) .setHandler(future.completer()); }
@Override public void start(Future<Void> future) throws Exception { super.start(); crudService = new StoreCRUDServiceImpl(vertx, config()); ProxyHelper.registerService(StoreCRUDService.class, vertx, crudService, SERVICE_ADDRESS); // publish service and deploy REST verticle publishEventBusService(SERVICE_NAME, SERVICE_ADDRESS, StoreCRUDService.class) .compose(servicePublished -> deployRestVerticle(crudService)) .setHandler(future.completer()); }
@Test public void testConnectionTimeout() { consumer.unregister(); consumer = ProxyHelper.registerService(TestService.class, vertx, service, SERVICE_ADDRESS, (long) 2); checkConnection(proxy, 2L); await(); }
@Override public void start(Future<Void> future) throws Exception { super.start(); // create the service instance ProductService productService = new ProductServiceImpl(vertx, config()); // register the service proxy on event bus ProxyHelper.registerService(ProductService.class, vertx, productService, SERVICE_ADDRESS); // publish the service in the discovery infrastructure initProductDatabase(productService) .compose(databaseOkay -> publishEventBusService(ProductService.SERVICE_NAME, SERVICE_ADDRESS, ProductService.class)) .compose(servicePublished -> deployRestService(productService)) .setHandler(future.completer()); }
@Test public void testFailedPublication() { HelloService svc = new HelloServiceImpl("stuff"); ProxyHelper.registerService(HelloService.class, vertx, svc, "address"); Record record = new Record() .setName("Hello") .setRegistration("this-is-not-allowed") .setLocation(new JsonObject().put(Record.ENDPOINT, "address")); Restafari.Response response = given().request().body(record.toJson().toString()).post("/discovery"); assertThat(response.getStatusCode()).isEqualTo(500); }
@Test public void testFailedPublication() { HelloService svc = new HelloServiceImpl("stuff"); ProxyHelper.registerService(HelloService.class, vertx, svc, "address"); Record record = new Record() .setName("Hello") .setRegistration("this-is-not-allowed") .setLocation(new JsonObject().put(Record.ENDPOINT, "address")); Restafari.Response response = given().request().body(record.toJson().toString()).post("/discovery"); assertThat(response.getStatusCode()).isEqualTo(500); }
@Override public void start(Future<Void> future) throws Exception { super.start(); this.orderService = new OrderServiceImpl(vertx, config()); ProxyHelper.registerService(OrderService.class, vertx, orderService, SERVICE_ADDRESS); initOrderDatabase() .compose(databaseOkay -> publishEventBusService(SERVICE_NAME, SERVICE_ADDRESS, OrderService.class)) .compose(servicePublished -> prepareDispatcher()) .compose(dispatcherPrepared -> deployRestVerticle()) .setHandler(future.completer()); }