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


Java Message.removeHeader方法代码示例

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


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

示例1: onCompletion

import org.apache.camel.Message; //导入方法依赖的package包/类
@Override
public void onCompletion(Exchange exchange) {
	if (wrappedAggregationStrategy != null
			&& wrappedAggregationStrategy instanceof CompletionAwareAggregationStrategy) {
		((CompletionAwareAggregationStrategy) wrappedAggregationStrategy).onCompletion(exchange);
	}

	// Remove exception, fault and redelivery info from exchange
	exchange.setException(null);
	exchange.removeProperty(Exchange.FAILURE_HANDLED);
	exchange.removeProperty(Exchange.FAILURE_ENDPOINT);
	exchange.removeProperty(Exchange.FAILURE_ROUTE_ID);
	exchange.removeProperty(Exchange.ERRORHANDLER_CIRCUIT_DETECTED);
	exchange.removeProperty(Exchange.ERRORHANDLER_HANDLED);
	exchange.removeProperty(Exchange.EXCEPTION_HANDLED);
	exchange.removeProperty(Exchange.EXCEPTION_CAUGHT);

	Message message = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
	message.setFault(false);
	message.removeHeader(Exchange.REDELIVERED);
	message.removeHeader(Exchange.REDELIVERY_COUNTER);
	message.removeHeader(Exchange.REDELIVERY_DELAY);
	message.removeHeader(Exchange.REDELIVERY_EXHAUSTED);
	message.removeHeader(Exchange.REDELIVERY_MAX_COUNTER);
}
 
开发者ID:bszeti,项目名称:camel-springboot,代码行数:26,代码来源:ContinueOnExceptionStrategy.java

示例2: process

import org.apache.camel.Message; //导入方法依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {
    Message in = exchange.getIn();

    String actionName = in.getHeader(SpongeConstants.SPONGE_ACTION, String.class);
    if (actionName != null) {
        // Remove the header so it won't be propagated.
        in.removeHeader(SpongeConstants.SPONGE_ACTION);
    }

    if (actionName == null) {
        actionName = action != null ? action : CamelProducerAction.NAME;
    }

    Object result = engine.getOperations().call(actionName, exchange);

    exchange.getIn().setBody(result);
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:19,代码来源:SpongeProducer.java

示例3: testLookupCaseAgnosticAddHeaderRemoveHeader

import org.apache.camel.Message; //导入方法依赖的package包/类
public void testLookupCaseAgnosticAddHeaderRemoveHeader() {
    Message msg = new DefaultMessage();
    assertNull(msg.getHeader("foo"));

    msg.setHeader("foo", "cheese");

    assertEquals("cheese", msg.getHeader("foo"));
    assertEquals("cheese", msg.getHeader("Foo"));
    assertEquals("cheese", msg.getHeader("FOO"));
    assertNull(msg.getHeader("unknown"));

    msg.setHeader("bar", "beer");

    assertEquals("beer", msg.getHeader("bar"));
    assertEquals("beer", msg.getHeader("Bar"));
    assertEquals("beer", msg.getHeader("BAR"));
    assertNull(msg.getHeader("unknown"));

    msg.removeHeader("bar");
    assertNull(msg.getHeader("bar"));
    assertNull(msg.getHeader("unknown"));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:DefaultMessageHeaderTest.java

示例4: testRemoveWithDifferentCase

import org.apache.camel.Message; //导入方法依赖的package包/类
public void testRemoveWithDifferentCase() {
    Message msg = new DefaultMessage();
    assertNull(msg.getHeader("foo"));

    msg.setHeader("foo", "cheese");
    msg.setHeader("Foo", "bar");

    assertEquals("bar", msg.getHeader("FOO"));
    assertEquals("bar", msg.getHeader("foo"));
    assertEquals("bar", msg.getHeader("Foo"));

    msg.removeHeader("FOO");

    assertEquals(null, msg.getHeader("foo"));
    assertEquals(null, msg.getHeader("Foo"));
    assertEquals(null, msg.getHeader("FOO"));

    assertTrue(msg.getHeaders().isEmpty());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:DefaultMessageHeaderTest.java

示例5: process

import org.apache.camel.Message; //导入方法依赖的package包/类
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
    try {
        Message message = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
        message.removeHeader(headerName);
    } catch (Exception e) {
        exchange.setException(e);
    }

    callback.done(true);
    return true;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:RemoveHeaderProcessor.java

示例6: testRemoveHeaderWithNullValue

import org.apache.camel.Message; //导入方法依赖的package包/类
public void testRemoveHeaderWithNullValue() {
    Message msg = new DefaultMessage();
    assertNull(msg.getHeader("foo"));

    msg.setHeader("tick", null);
    msg.removeHeader("tick");

    assertTrue(msg.getHeaders().isEmpty());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:DefaultMessageHeaderTest.java

示例7: getTopic

import org.apache.camel.Message; //导入方法依赖的package包/类
protected String getTopic(Exchange exchange) {
    Message in = exchange.getIn();
    String topic = in.getHeader(EventAdminConstants.EVENTADMIN_TOPIC, String.class);
    if (topic != null) {
        in.removeHeader(EventAdminConstants.EVENTADMIN_TOPIC);
    }
    if (topic == null) {
        topic = endpoint.getTopic();
    }
    return topic;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:EventAdminProducer.java

示例8: extractHeader

import org.apache.camel.Message; //导入方法依赖的package包/类
private void extractHeader(String headerMame, Message camelMessage, InternetHeaders headers) {
    String h = camelMessage.getHeader(headerMame, String.class);
    if (h != null) {
        headers.addHeader(headerMame, h);
        camelMessage.removeHeader(headerMame);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:MimeMultipartDataFormat.java

示例9: onExchange

import org.apache.camel.Message; //导入方法依赖的package包/类
@Override
protected void onExchange(Exchange exchange) throws Exception {
    Message incomingMessage = exchange.getIn();
    String newResourceUri = incomingMessage.getHeader(AtlasConstants.ATLAS_RESOURCE_URI, String.class);
    if (newResourceUri != null) {
        incomingMessage.removeHeader(AtlasConstants.ATLAS_RESOURCE_URI);

        log.debug("{} set to {} creating new endpoint to handle exchange", AtlasConstants.ATLAS_RESOURCE_URI,
                newResourceUri);
        AtlasEndpoint newEndpoint = findOrCreateEndpoint(getEndpointUri(), newResourceUri);
        newEndpoint.onExchange(exchange);
        return;
    }

    AtlasSession atlasSession = getAtlasContext(incomingMessage).createSession();
    boolean sourceIsXmlOrJson = isSourceXmlOrJson(atlasSession.getMapping());
    Object body = incomingMessage.getBody();
    if (sourceIsXmlOrJson && body instanceof InputStream) {
        // read the whole stream into a String
        // the XML and JSON parsers expect that
        body = incomingMessage.getBody(String.class);
    }

    // TODO Lookup multiple inputs and map with corresponding source docId
    //      https://github.com/atlasmap/camel-atlasmap/issues/18
    atlasSession.setInput(body);
    atlasContext.process(atlasSession);

    List<Audit> errors = new ArrayList<>();
    for (Audit audit : atlasSession.getAudits().getAudit()) {
        switch (audit.getStatus()) {
        case ERROR:
            errors.add(audit);
            break;
        case WARN:
            LOG.warn("{}: docId='{}', path='{}'", audit.getMessage(), audit.getDocId(), audit.getPath());
            break;
        default:
            LOG.info("{}: docId='{}', path='{}'", audit.getMessage(), audit.getDocId(), audit.getPath());
        }
    }
    if (!errors.isEmpty()) {
        StringBuilder buf = new StringBuilder("Errors: ");
        errors.stream().forEach(a -> buf.append(
                String.format("[%s: docId='%s', path='%s'], ", a.getMessage(), a.getDocId(), a.getPath())));
        throw new AtlasException(buf.toString());
    }

    // now lets output the results to the exchange
    Message out = exchange.getOut();
    out.setBody(atlasSession.getOutput());
    out.setHeaders(incomingMessage.getHeaders());
    out.setAttachments(incomingMessage.getAttachments());
}
 
开发者ID:atlasmap,项目名称:camel-atlasmap,代码行数:55,代码来源:AtlasEndpoint.java

示例10: ignoreResponseHeaders

import org.apache.camel.Message; //导入方法依赖的package包/类
protected void ignoreResponseHeaders(Message in) {
    in.removeHeader(Olingo4Constants.PROPERTY_PREFIX + Olingo4Constants.RESPONSE_HTTP_HEADERS);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:4,代码来源:AbstractODataConnector.java

示例11: getAndRemoveHeader

import org.apache.camel.Message; //导入方法依赖的package包/类
/**
 * Gets and removes the <code> <code>headerName</code> header form the input
 * <code>message</code> (the header will not be propagated)
 */
protected <T> T getAndRemoveHeader(Message message, String headerName, T defaultValue, Class<T> headerType) {
    T h = message.getHeader(headerName, defaultValue, headerType);
    message.removeHeader(headerName);
    return h;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:DefaultExecBinding.java


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