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