/** * Same as {@link #createRecord(String, String, String, JsonObject)} without additional metadata. * * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload * @return the created record */ static Record createRecord(String name, String address, String type) { return createRecord(name, address, type, null); }
public <T> void getConsumer(JsonObject jsonFilter, Handler<AsyncResult<MessageConsumer<T>>> handler) { MessageSource.getConsumer(serviceDiscovery, jsonFilter, handler); } }
/** * Same as {@link #createRecord(String, String, String, JsonObject)} without additional metadata. * * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload * @return the created record */ static Record createRecord(String name, String address, String type) { return createRecord(name, address, type, null); }
public <T> void getConsumer(Function<Record, Boolean> filter, Handler<AsyncResult<MessageConsumer<T>>> handler) { MessageSource.getConsumer(serviceDiscovery, filter, handler); }
/** * Same as {@link #createRecord(String, String, Class, JsonObject)} without additional metadata, and no type for * the payload. * * @param name the name of the service * @param address the address on which the data is sent. * @return the created record */ static Record createRecord(String name, String address) { return createRecord(name, address, (String) null); }
public static <T>void getConsumer(io.vertx.servicediscovery.types.MessageSource j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.function.Function<java.util.Map<String, Object>, java.lang.Boolean> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.eventbus.MessageConsumer<java.lang.Object>>> resultHandler) { io.vertx.servicediscovery.types.MessageSource.getConsumer(discovery, filter != null ? new java.util.function.Function<io.vertx.servicediscovery.Record, java.lang.Boolean>() { public java.lang.Boolean apply(io.vertx.servicediscovery.Record t) { java.util.Map<String, Object> o = t != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(t.toJson()) : null; java.lang.Boolean p = filter.apply(o); return p; } } : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.eventbus.MessageConsumer<java.lang.Object>>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.core.eventbus.MessageConsumer<java.lang.Object>> ar) { resultHandler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromObject(event))); } } : null); } }
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.MessageSource#createRecord} without additional metadata, and no type for * the payload. * @param name the name of the service * @param address the address on which the data is sent. * @return the created record */ public static Record createRecord(String name, String address) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address); return ret; }
public static <T>void getConsumer(io.vertx.servicediscovery.types.MessageSource j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.eventbus.MessageConsumer<java.lang.Object>>> resultHandler) { io.vertx.servicediscovery.types.MessageSource.getConsumer(discovery, filter != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(filter) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.eventbus.MessageConsumer<java.lang.Object>>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.core.eventbus.MessageConsumer<java.lang.Object>> ar) { resultHandler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromObject(event))); } } : null); } public static <T>void getConsumer(io.vertx.servicediscovery.types.MessageSource j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.function.Function<java.util.Map<String, Object>, java.lang.Boolean> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.eventbus.MessageConsumer<java.lang.Object>>> resultHandler) {
/** * Create a record representing a data producer. * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload (fully qualified name of the class) * @param metadata additional metadata * @return the created record */ public static Record createRecord(String name, String address, String type, JsonObject metadata) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type, metadata); return ret; }
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, must not be <code>null</code> * @param resultHandler The result handler */ public static <T> void getConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<io.vertx.rxjava.core.eventbus.MessageConsumer<T>>> resultHandler) { io.vertx.servicediscovery.types.MessageSource.getConsumer(discovery.getDelegate(), filter, new Handler<AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>>>() { public void handle(AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.eventbus.MessageConsumer.newInstance(ar.result(), io.vertx.lang.rx.TypeArg.unknown()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.MessageSource#createRecord} without additional metadata. * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload * @return the created record */ public static Record createRecord(String name, String address, String type) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type); return ret; }
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ public static <T> void getConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<io.vertx.rxjava.core.eventbus.MessageConsumer<T>>> resultHandler) { io.vertx.servicediscovery.types.MessageSource.getConsumer(discovery.getDelegate(), filter, new Handler<AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>>>() { public void handle(AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.eventbus.MessageConsumer.newInstance(ar.result(), io.vertx.lang.rx.TypeArg.unknown()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * Same as {@link #createRecord(String, String, Class, JsonObject)} without additional metadata, and no type for * the payload. * * @param name the name of the service * @param address the address on which the data is sent. * @return the created record */ static Record createRecord(String name, String address) { return createRecord(name, address, (String) null); }
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ public static <T> void getConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<io.vertx.rxjava.core.eventbus.MessageConsumer<T>>> resultHandler) { io.vertx.servicediscovery.types.MessageSource.getConsumer(discovery.getDelegate(), filter, new Handler<AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>>>() { public void handle(AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.eventbus.MessageConsumer.newInstance(ar.result(), io.vertx.lang.rx.TypeArg.unknown()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.MessageSource#createRecord} without additional metadata, and no type for * the payload. * @param name the name of the service * @param address the address on which the data is sent. * @return the created record */ public static Record createRecord(String name, String address) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address); return ret; }
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, must not be <code>null</code> * @param resultHandler The result handler */ public static <T> void getConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<io.vertx.rxjava.core.eventbus.MessageConsumer<T>>> resultHandler) { io.vertx.servicediscovery.types.MessageSource.getConsumer(discovery.getDelegate(), filter, new Handler<AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>>>() { public void handle(AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.eventbus.MessageConsumer.newInstance(ar.result(), io.vertx.lang.rx.TypeArg.unknown()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.MessageSource#createRecord} without additional metadata. * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload * @return the created record */ public static Record createRecord(String name, String address, String type) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type); return ret; }
private Future<MessageConsumer<JsonObject>> getMarketSource(ServiceDiscovery discovery) { Future<MessageConsumer<JsonObject>> future = Future.future(); MessageSource.getConsumer(discovery, rec -> rec.getName().equalsIgnoreCase("market-data"), future); return future; }
/** * Create a record representing a data producer. * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload (fully qualified name of the class) * @param metadata additional metadata * @return the created record */ public static Record createRecord(String name, String address, String type, JsonObject metadata) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type, metadata); return ret; }
@Override public void start(Future<Void> future) throws Exception { super.start(); MessageSource.<JsonObject>getConsumer(discovery, new JsonObject().put("name", "shopping-order-message-source"), ar -> { if (ar.succeeded()) { MessageConsumer<JsonObject> orderConsumer = ar.result(); orderConsumer.handler(message -> { Order wrappedOrder = wrapRawOrder(message.body()); dispatchOrder(wrappedOrder, message); }); future.complete(); } else { future.fail(ar.cause()); } }); }