org.apache.camel.Message.removeHeader()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(269)

本文整理了Java中org.apache.camel.Message.removeHeader()方法的一些代码示例,展示了Message.removeHeader()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.removeHeader()方法的具体详情如下:
包路径:org.apache.camel.Message
类名称:Message
方法名:removeHeader

Message.removeHeader介绍

暂无

代码示例

代码示例来源:origin: io.syndesis.connector/connector-odata-model

  1. protected void ignoreResponseHeaders(Message in) {
  2. in.removeHeader(Olingo4Constants.PROPERTY_PREFIX + Olingo4Constants.RESPONSE_HTTP_HEADERS);
  3. }
  4. }

代码示例来源:origin: io.syndesis/odata-model

  1. protected void ignoreResponseHeaders(Message in) {
  2. in.removeHeader(Olingo4Constants.PROPERTY_PREFIX + Olingo4Constants.RESPONSE_HTTP_HEADERS);
  3. }
  4. }

代码示例来源:origin: org.apache.camel/camel-gae

  1. protected void readRequestHeaders(GHttpEndpoint endpoint, Exchange exchange, HttpServletRequest request) {
  2. // EXPERIMENTAL // TODO: resolve gzip encoding issues
  3. exchange.getIn().removeHeader("Accept-Encoding");
  4. exchange.getIn().removeHeader("Content-Encoding");
  5. }

代码示例来源:origin: org.apache.camel/camel-exec

  1. /**
  2. * Gets and removes the <code> <code>headerName</code> header form the input
  3. * <code>message</code> (the header will not be propagated)
  4. */
  5. protected <T> T getAndRemoveHeader(Message message, String headerName, T defaultValue, Class<T> headerType) {
  6. T h = message.getHeader(headerName, defaultValue, headerType);
  7. message.removeHeader(headerName);
  8. return h;
  9. }
  10. }

代码示例来源:origin: ru.yandex.qatools.camelot/camelot-commons

  1. @SuppressWarnings("suspicious")
  2. public boolean isCompleted(Exchange exchange) throws ReflectiveOperationException {
  3. return exchange == null
  4. || exchange.getIn() == null
  5. || (boolean) exchange.getIn().removeHeader(FINISHED_EXCHANGE);
  6. }
  7. }

代码示例来源:origin: org.apache.camel/camel-http-common

  1. @Override
  2. public void process(Exchange exchange) throws Exception {
  3. if (path != null) {
  4. exchange.getIn().setHeader(Exchange.HTTP_PATH, path);
  5. } else {
  6. exchange.getIn().removeHeader(Exchange.HTTP_PATH);
  7. }
  8. if (query != null) {
  9. exchange.getIn().setHeader(Exchange.HTTP_QUERY, query);
  10. } else {
  11. exchange.getIn().removeHeader(Exchange.HTTP_QUERY);
  12. }
  13. }

代码示例来源:origin: org.apache.camel/camel-mail

  1. private void extractHeader(String headerMame, Message camelMessage, InternetHeaders headers) {
  2. String h = camelMessage.getHeader(headerMame, String.class);
  3. if (h != null) {
  4. headers.addHeader(headerMame, h);
  5. camelMessage.removeHeader(headerMame);
  6. }
  7. }

代码示例来源:origin: org.apache.camel/camel-reactive-streams

  1. public static DispatchCallback<Exchange> detachCallback(Exchange exchange) {
  2. DispatchCallback<Exchange> callback = getCallback(exchange);
  3. if (callback != null) {
  4. exchange.getIn().removeHeader(ReactiveStreamsConstants.REACTIVE_STREAMS_CALLBACK);
  5. }
  6. return callback;
  7. }

代码示例来源:origin: org.apache.camel/camel-http-common

  1. @Override
  2. public void process(Exchange exchange) throws Exception {
  3. // cleanup and remove the headers we used
  4. exchange.getMessage().removeHeader(Exchange.HTTP_PATH);
  5. exchange.getMessage().removeHeader(Exchange.HTTP_QUERY);
  6. }

代码示例来源:origin: org.apache.camel/camel-ftp

  1. @Override
  2. public void process(Exchange exchange) throws Exception {
  3. // store any existing file header which we want to keep and propagate
  4. final String existing = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
  5. // create the target file name
  6. String target = createFileName(exchange);
  7. try {
  8. processExchange(exchange, target);
  9. } finally {
  10. // remove the write file name header as we only want to use it once (by design)
  11. exchange.getIn().removeHeader(Exchange.OVERRULE_FILE_NAME);
  12. // and restore existing file name
  13. exchange.getIn().setHeader(Exchange.FILE_NAME, existing);
  14. }
  15. }

代码示例来源:origin: org.apache.camel/camel-crypto-cms

  1. @Override
  2. public void process(Exchange exchange) throws Exception { // NOPMD see
  3. // method
  4. // processSignedDataHader
  5. InputStream signature = exchange.getIn().getHeader(CryptoCmsConstants.CAMEL_CRYPTO_CMS_SIGNED_DATA, InputStream.class);
  6. if (signature == null) {
  7. LOG.debug("No signed data found in header {}. Assuming signed data contained in message body", CryptoCmsConstants.CAMEL_CRYPTO_CMS_SIGNED_DATA);
  8. super.process(exchange);
  9. } else {
  10. LOG.debug("Signed data header {} found.", CryptoCmsConstants.CAMEL_CRYPTO_CMS_SIGNED_DATA);
  11. processSignedDataHeader(exchange, signature);
  12. // remove header
  13. exchange.getIn().removeHeader(CryptoCmsConstants.CAMEL_CRYPTO_CMS_SIGNED_DATA);
  14. }
  15. }

代码示例来源:origin: at.researchstudio.sat/won-node

  1. @Override
  2. public void process(Exchange exchange) throws Exception {
  3. WonMessage wonMessage = (WonMessage) exchange.getIn().getHeader(WonCamelConstants.MESSAGE_HEADER);
  4. if (wonMessage == null){
  5. logger.debug("did not find a WonMessage in header {}, this is unexpected ", WonCamelConstants.MESSAGE_HEADER);
  6. return;
  7. }
  8. //remove the factory from the camel message so it does not slow down the rest of the processing chain
  9. Object factory = exchange.getIn().removeHeader(WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER);
  10. if (factory == null){
  11. logger.debug("did not find an outbound message for message {} in header {}, this is unexpected ", wonMessage.getMessageURI(), WonCamelConstants.OUTBOUND_MESSAGE_FACTORY_HEADER);
  12. return;
  13. }
  14. OutboundMessageFactoryProcessor factoryProcessor = (OutboundMessageFactoryProcessor) factory;
  15. WonMessage outboundMessage = factoryProcessor.process(wonMessage);
  16. if (outboundMessage == null){
  17. logger.debug("factory did not produce an outgoing WonMessage based on WonMessage {}, this is unexpected", wonMessage.getMessageURI());
  18. }
  19. exchange.getIn().setHeader(WonCamelConstants.OUTBOUND_MESSAGE_HEADER, outboundMessage);
  20. }
  21. }

代码示例来源:origin: edu.amherst.acdc/acrepo-jsonld-cache

  1. /**
  2. * Define how the message should be processed.
  3. *
  4. * @param exchange the current camel message exchange
  5. */
  6. public void process(final Exchange exchange) throws IOException {
  7. final Message in = exchange.getIn();
  8. final CamelContext ctx = exchange.getContext();
  9. final StringBuilder key = new StringBuilder("/buckets/");
  10. try {
  11. final String prefix = ctx.resolvePropertyPlaceholders("{{riak.bucket}}");
  12. key.append(prefix);
  13. } catch (final Exception ex) {
  14. throw new RuntimeCamelException("Could not resolve properties", ex);
  15. }
  16. key.append("/keys/");
  17. key.append(URLEncoder.encode(
  18. in.getHeader(FcrepoHeaders.FCREPO_IDENTIFIER, String.class), "UTF-8"));
  19. in.removeHeader(Exchange.HTTP_URL);
  20. in.setHeader(Exchange.HTTP_PATH, key.toString());
  21. }
  22. }

代码示例来源:origin: org.apache.camel/camel-cache

  1. public void process(Exchange exchange) throws Exception {
  2. LOG.trace("Cache Name: {}", config.getCacheName());
  3. Map<String, Object> headers = exchange.getIn().getHeaders();
  4. String key = (headers.containsKey(CacheConstants.CACHE_KEY))
  5. ? exchange.getIn().getHeader(CacheConstants.CACHE_KEY, String.class)
  6. : getEndpoint().getKey();
  7. String operation = (headers.containsKey(CacheConstants.CACHE_OPERATION)) ? (String)headers
  8. .get(CacheConstants.CACHE_OPERATION) : getEndpoint().getOperation();
  9. if (operation == null) {
  10. throw new CacheException(CacheConstants.CACHE_OPERATION + " header not specified in message");
  11. }
  12. if ((key == null) && (!checkIsEqual(operation, CacheConstants.CACHE_OPERATION_DELETEALL))) {
  13. throw new CacheException(CacheConstants.CACHE_KEY + " is not specified in message header or endpoint URL.");
  14. }
  15. performCacheOperation(exchange, operation, key);
  16. //cleanup the cache headers
  17. exchange.getIn().removeHeader(CacheConstants.CACHE_KEY);
  18. exchange.getIn().removeHeader(CacheConstants.CACHE_OPERATION);
  19. }

代码示例来源:origin: org.fusesource.eca/eca-core

  1. /**
  2. * Evaluates the exchange
  3. */
  4. protected void sendToConsumers(Exchange exchange) throws Exception {
  5. // ensure route id is correct set due CAMEL-4806
  6. // TODO: Remove this when CAMEL-4806 is in released Fuse Camel version
  7. // and override prepareExchange method instead and set from route id detail there
  8. String routeId = (String) exchange.getIn().removeHeader("EcaRouteId");
  9. if (exchange.getFromRouteId() == null) {
  10. exchange.setFromRouteId(routeId);
  11. }
  12. getEndpoint().evaluate(exchange);
  13. }

代码示例来源:origin: org.switchyard/switchyard-bus-camel

  1. @Override
  2. public void removeProperty(Property property) {
  3. switch (property.getScope()) {
  4. case EXCHANGE:
  5. _exchange.removeProperty(property.getName());
  6. break;
  7. default:
  8. _message.removeHeader(property.getName());
  9. break;
  10. }
  11. }

代码示例来源:origin: jboss-switchyard/core

  1. @Override
  2. public void removeProperty(Property property) {
  3. switch (property.getScope()) {
  4. case EXCHANGE:
  5. _exchange.removeProperty(property.getName());
  6. break;
  7. default:
  8. _message.removeHeader(property.getName());
  9. break;
  10. }
  11. }

代码示例来源:origin: org.apache.camel/camel-netty-http

  1. @Override
  2. protected Object getRequestBody(Exchange exchange) throws Exception {
  3. // creating the url to use takes 2-steps
  4. String uri = NettyHttpHelper.createURL(exchange, getEndpoint());
  5. URI u = NettyHttpHelper.createURI(exchange, uri, getEndpoint());
  6. HttpRequest request = getEndpoint().getNettyHttpBinding().toNettyRequest(exchange.getIn(), u.toString(), getConfiguration());
  7. String actualUri = request.getUri();
  8. exchange.getIn().setHeader(Exchange.HTTP_URL, actualUri);
  9. // Need to check if we need to close the connection or not
  10. if (!HttpHeaders.isKeepAlive(request)) {
  11. // just want to make sure we close the channel if the keepAlive is not true
  12. exchange.setProperty(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, true);
  13. }
  14. if (getConfiguration().isBridgeEndpoint()) {
  15. // Need to remove the Host key as it should be not used when bridging/proxying
  16. exchange.getIn().removeHeader("host");
  17. }
  18. return request;
  19. }

代码示例来源:origin: org.apache.camel/camel-rabbitmq

  1. private boolean processInOnly(Exchange exchange, AsyncCallback callback) throws Exception {
  2. // remove the OVERRIDE header so it does not propagate
  3. String exchangeName = (String) exchange.getIn().removeHeader(RabbitMQConstants.EXCHANGE_OVERRIDE_NAME);
  4. // If it is BridgeEndpoint we should ignore the message header of EXCHANGE_OVERRIDE_NAME
  5. if (exchangeName == null || getEndpoint().isBridgeEndpoint()) {
  6. exchangeName = getEndpoint().getExchangeName();
  7. } else {
  8. log.debug("Overriding header: {} detected sending message to exchange: {}", RabbitMQConstants.EXCHANGE_OVERRIDE_NAME, exchangeName);
  9. }
  10. String key = exchange.getIn().getHeader(RabbitMQConstants.ROUTING_KEY, String.class);
  11. // we just need to make sure RoutingKey option take effect if it is not BridgeEndpoint
  12. if (key == null || getEndpoint().isBridgeEndpoint()) {
  13. key = getEndpoint().getRoutingKey() == null ? "" : getEndpoint().getRoutingKey();
  14. }
  15. if (ObjectHelper.isEmpty(key) && ObjectHelper.isEmpty(exchangeName)) {
  16. throw new IllegalArgumentException("ExchangeName and RoutingKey is not provided in the endpoint: " + getEndpoint());
  17. }
  18. basicPublish(exchange, exchangeName, key);
  19. callback.done(true);
  20. return true;
  21. }

代码示例来源:origin: io.syndesis.connector/connector-webhook

  1. @Test
  2. public void shouldAddWrapperProcessorIfSyndesisJsonSchemaGiven() throws Exception {
  3. final WebhookConnectorCustomizer customizer = new WebhookConnectorCustomizer();
  4. customizer.setCamelContext(mock(CamelContext.class));
  5. customizer.setOutputDataShape(new DataShape.Builder().kind(DataShapeKinds.JSON_SCHEMA).specification(SIMPLE_SCHEMA).build());
  6. customizer.customize(component, Collections.emptyMap());
  7. final Processor beforeConsumer = component.getBeforeConsumer();
  8. assertThat(beforeConsumer).isInstanceOf(Pipeline.class);
  9. final Pipeline pipeline = (Pipeline) beforeConsumer;
  10. final Collection<Processor> processors = pipeline.getProcessors();
  11. assertThat(processors).hasSize(2).anySatisfy(p -> assertThat(p).isInstanceOf(HttpRequestWrapperProcessor.class));
  12. final HttpRequestWrapperProcessor wrapper = (HttpRequestWrapperProcessor) processors.stream().filter(p -> p instanceof HttpRequestWrapperProcessor)
  13. .findFirst().get();
  14. assertThat(wrapper.getParameters()).containsOnly("source", "status");
  15. final Processor removeHeader = processors.stream().filter(p -> !(p instanceof HttpRequestWrapperProcessor)).findFirst().get();
  16. final Exchange exchange = mock(Exchange.class);
  17. final Message in = mock(Message.class);
  18. when(exchange.getIn()).thenReturn(in);
  19. removeHeader.process(exchange);
  20. verify(in).removeHeader(Exchange.HTTP_URI);
  21. }

相关文章