當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。