use of io.vertx.core.eventbus.DeliveryOptions in project VX-API-Gateway by EliMirren.
the class ClientVerticle method startAllAPI.
/**
* 启动所有API
*
* @param rct
*/
public void startAllAPI(RoutingContext rct) {
String appName = rct.request().getParam("appName");
HttpServerResponse response = rct.response().putHeader(CONTENT_TYPE, CONTENT_VALUE_JSON_UTF8);
if (StrUtil.isNullOrEmpty(appName)) {
response.end(ResultFormat.formatAsZero(HTTPStatusCodeMsgEnum.C1400));
} else {
LOG.info(MessageFormat.format("[user : {0}] 执行启动应用{1}:所有API..", rct.session().get("userName"), appName));
// 用于获取所有API的参数
JsonObject message = new JsonObject().put("appName", appName);
// 获取所有API
vertx.eventBus().<JsonArray>send(thisVertxName + VxApiEventBusAddressConstant.FIND_API_ALL, message, data -> {
if (data.succeeded()) {
JsonArray body = data.result().body();
DeliveryOptions option = new DeliveryOptions();
option.setSendTimeout(200 * 301);
JsonObject config = new JsonObject();
config.put("appName", appName);
config.put("apis", body);
vertx.eventBus().<String>send(thisVertxName + VxApiEventBusAddressConstant.DEPLOY_API_START_ALL, config, option, reply -> {
if (reply.succeeded()) {
LOG.info(MessageFormat.format("[user : {0}] 执行启动应用{1}:所有API-->成功", rct.session().get("userName"), appName));
response.end(ResultFormat.format(HTTPStatusCodeMsgEnum.C200, reply.result().body()));
if (vertx.isClustered()) {
vertx.eventBus().publish(VxApiEventBusAddressConstant.DEPLOY_API_START_ALL, config.copy().put("thisVertxName", thisVertxName));
LOG.info("广播通知集群环境中 应用:" + appName + ",启动所有API");
}
} else {
LOG.error(MessageFormat.format("[user : {0}] 执行启动所有API-->查看API:{1}-->失败:{2}", rct.session().get("userName"), appName, reply.cause().toString()));
response.end(ResultFormat.format(HTTPStatusCodeMsgEnum.C500, reply.cause().toString()));
}
});
} else {
LOG.error(MessageFormat.format("[user : {0}] 执行启动所有API-->查看API:{1}-->失败:{2}", rct.session().get("userName"), appName, data.cause().toString()));
response.end(ResultFormat.format(HTTPStatusCodeMsgEnum.C500, data.cause().toString()));
}
});
}
}
use of io.vertx.core.eventbus.DeliveryOptions in project VX-API-Gateway by EliMirren.
the class CLIVerticle method startAllAPI.
/**
* 启动所有API
*
* @param appName
* 应用的名称
*/
public void startAllAPI(String appName) {
if (StrUtil.isNullOrEmpty(appName)) {
if (LOG.isDebugEnabled()) {
LOG.debug("cli->执行启动网关应用->启动所有API-->失败:应用名称为空");
}
return;
}
// 获取所有API
JsonObject message = new JsonObject().put("appName", appName);
vertx.eventBus().<JsonArray>send(thisVertxName + VxApiEventBusAddressConstant.FIND_API_ALL, message, reply -> {
if (reply.succeeded()) {
JsonArray apis = reply.result().body();
DeliveryOptions option = new DeliveryOptions();
option.setSendTimeout(200 * 301);
JsonObject config = new JsonObject();
config.put("appName", appName);
config.put("apis", apis);
String startApiAddress = thisVertxName + VxApiEventBusAddressConstant.DEPLOY_API_START_ALL;
vertx.eventBus().<String>send(startApiAddress, config, option, res -> {
if (res.succeeded()) {
if (LOG.isDebugEnabled()) {
LOG.debug("cli->执行启动网关应用:" + appName + "->启动所有API-->成功");
}
} else {
LOG.error("cli->执行启动网关应用:" + appName + "->启动所有API-->失败:" + reply.cause());
}
});
} else {
LOG.error("cli->执行启动网关应用:" + appName + "->获取所有API-->失败:" + reply.cause());
}
});
}
use of io.vertx.core.eventbus.DeliveryOptions in project mod-invoice by folio-org.
the class AbstractHelper method sendEvent.
protected void sendEvent(MessageAddress messageAddress, JsonObject data) {
DeliveryOptions deliveryOptions = new DeliveryOptions();
// Add okapi headers
okapiHeaders.forEach(deliveryOptions::addHeader);
data.put(LANG, lang);
ctx.owner().eventBus().send(messageAddress.address, data, deliveryOptions);
}
use of io.vertx.core.eventbus.DeliveryOptions in project vertx-zero by silentbalanceyh.
the class DeployRotate method spinDelivery.
@Override
public DeliveryOptions spinDelivery() {
final DeliveryOptions options = new DeliveryOptions();
options.setSendTimeout(delivery.getLong("timeout", options.getSendTimeout()));
return options;
}
use of io.vertx.core.eventbus.DeliveryOptions in project mod-orders by folio-org.
the class HelperUtils method sendEvent.
public static void sendEvent(MessageAddress messageAddress, JsonObject data, RequestContext requestContext) {
DeliveryOptions deliveryOptions = new DeliveryOptions();
// Add okapi headers
Map<String, String> okapiHeaders = requestContext.getHeaders();
okapiHeaders.forEach(deliveryOptions::addHeader);
data.put(LANG, EN);
requestContext.getContext().owner().eventBus().send(messageAddress.address, data, deliveryOptions);
}
Aggregations