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


Java DeliveryOptions.setHeaders方法代码示例

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


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

示例1: manageError

import io.vertx.core.eventbus.DeliveryOptions; //导入方法依赖的package包/类
public void manageError(Message<JsonObject> message, Throwable cause, String serviceName) {
    int code = MainApiException.INTERNAL_SERVER_ERROR.getStatusCode();
    String statusMessage = MainApiException.INTERNAL_SERVER_ERROR.getStatusMessage();
    DeliveryOptions deliveryOptions = new DeliveryOptions();
    if (cause instanceof MainApiException) {
        code = ((MainApiException)cause).getStatusCode();
        statusMessage = ((MainApiException)cause).getStatusMessage();
        deliveryOptions.setHeaders(((MainApiException)cause).getHeaders());
    } else {
        logUnexpectedError(serviceName, cause);
    }
    deliveryOptions.addHeader(SwaggerRouter.CUSTOM_STATUS_CODE_HEADER_KEY, String.valueOf(code));
    deliveryOptions.addHeader(SwaggerRouter.CUSTOM_STATUS_MESSAGE_HEADER_KEY, statusMessage);

    message.reply(null, deliveryOptions);
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:17,代码来源:VerticleHelper.java

示例2: getAsyncResultHandler

import io.vertx.core.eventbus.DeliveryOptions; //导入方法依赖的package包/类
public <T> Handler<AsyncResult<ResourceResponse<T>>> getAsyncResultHandler(Message<JsonObject> message, String serviceName, boolean withJsonEncode, TypeReference<T> type) {
    return result -> {
        if (result.succeeded()) {
            DeliveryOptions deliveryOptions = new DeliveryOptions();
            deliveryOptions.setHeaders(result.result().getHeaders());
            if(withJsonEncode) {
                message.reply(Json.encode(result.result().getResponse()), deliveryOptions);
            } else {
                message.reply(result.result().getResponse(), deliveryOptions);
            }
        } else {
            Throwable cause = result.cause();
            manageError(message, cause, serviceName);
        }
    };
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:17,代码来源:VerticleHelper.java

示例3: getAsyncResultHandler

import io.vertx.core.eventbus.DeliveryOptions; //导入方法依赖的package包/类
public <T> Handler<AsyncResult<ResourceResponse<T>>> getAsyncResultHandler(Message<JsonObject> message, String serviceName, boolean withJsonEncode, TypeReference<T> type) {
    return result -> {
        if (result.succeeded()) {
            DeliveryOptions deliveryOptions = new DeliveryOptions();
            deliveryOptions.setHeaders(result.result().getHeaders());
            if(withJsonEncode) {
                message.reply(result.result().toJson(), deliveryOptions);
            } else {
                message.reply(result.result().getResponse(), deliveryOptions);
            }
        } else {
            Throwable cause = result.cause();
            manageError(message, cause, serviceName);
        }
    };
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:17,代码来源:VerticleHelper.java

示例4: processIncoming

import io.vertx.core.eventbus.DeliveryOptions; //导入方法依赖的package包/类
/**
 * Check incoming messages for final destinations and then forward them if they are not
 * duplicates
 * 
 * @param incomingData received from event bus
 */
protected void processIncoming(final Message<JsonObject> incomingData) {
	final MultiMap headers = incomingData.headers();
	final List<String> finalDestination = headers.getAll(Constants.BUS_FINAL_DESTINATION);
	if ((finalDestination != null) && !finalDestination.isEmpty()) {
		final JsonObject j = incomingData.body();
		// Forwarding the original headers
		final DeliveryOptions dOpts = new DeliveryOptions();
		dOpts.setHeaders(headers);
		final Future<Void> duplicate = Future.future(f -> {
			if (f.succeeded()) {
				// Forwarding it to where it should go
				final EventBus eb = this.getVertx().eventBus();
				finalDestination.forEach(d -> {
					eb.send(d, j, dOpts);
				});
			} else {
				this.logger.info("Dropped duplicate Object:" + String.valueOf(j));
			}
		});
		// The duplicate check happens here!
		this.checkForDuplicate(duplicate, j);
	} else {
		this.logger.fatal(new Exception("Incoming message without final destination" + incomingData.toString()));
	}

}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:33,代码来源:AbstractSFDCDedupVerticle.java

示例5: getRxResultHandler

import io.vertx.core.eventbus.DeliveryOptions; //导入方法依赖的package包/类
public <T> Action1<ResourceResponse<T>> getRxResultHandler(Message<JsonObject> message, boolean withJsonEncode, TypeReference<T> type) {
    return result -> {
        DeliveryOptions deliveryOptions = new DeliveryOptions();
        deliveryOptions.setHeaders(result.getHeaders());
        if (withJsonEncode) {
            message.reply(Json.encode(result.getResponse()), deliveryOptions);
        } else {
            message.reply(result.getResponse(), deliveryOptions);
        }
    };
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:12,代码来源:VerticleHelper.java

示例6: getRxResultHandler

import io.vertx.core.eventbus.DeliveryOptions; //导入方法依赖的package包/类
public <T> Action1<ResourceResponse<T>> getRxResultHandler(Message<JsonObject> message, boolean withJsonEncode, TypeReference<T> type) {
    return result -> {
        DeliveryOptions deliveryOptions = new DeliveryOptions();
        deliveryOptions.setHeaders(result.getHeaders());
        if (withJsonEncode) {
            message.reply(result.toJson(), deliveryOptions);
        } else {
            message.reply(result.getResponse(), deliveryOptions);
        }
    };
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:12,代码来源:VerticleHelper.java


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