This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.4.x by this push:
new b90a5db8f10 CAMEL-20699, CAMEL-20691: Fix Azure ServiceBus header
propagation (#13879)
b90a5db8f10 is described below
commit b90a5db8f1065d90b44335ef35c1f94874adf5b2
Author: Dylan Piergies <[email protected]>
AuthorDate: Wed Apr 24 20:16:34 2024 +0100
CAMEL-20699, CAMEL-20691: Fix Azure ServiceBus header propagation (#13879)
* CAMEL-20699: Fix Azure ServiceBus consumer broker property propagation
* CAMEL-20691: Fix propagation of application properties
---
.../azure/servicebus/ServiceBusConfiguration.java | 3 +--
.../azure/servicebus/ServiceBusConsumer.java | 2 +-
.../servicebus/ServiceBusHeaderFilterStrategy.java | 31 ++++++++++++++++++++++
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java
index eeb5ff76dea..b8e9873a64e 100644
---
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java
+++
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConfiguration.java
@@ -31,7 +31,6 @@ import
com.azure.messaging.servicebus.models.ServiceBusReceiveMode;
import com.azure.messaging.servicebus.models.SubQueue;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.spi.*;
-import org.apache.camel.support.DefaultHeaderFilterStrategy;
import static
org.apache.camel.component.azure.servicebus.CredentialType.CONNECTION_STRING;
@@ -59,7 +58,7 @@ public class ServiceBusConfiguration implements Cloneable,
HeaderFilterStrategyA
private AmqpTransportType amqpTransportType = AmqpTransportType.AMQP;
@UriParam(label = "common",
description = "To use a custom HeaderFilterStrategy to filter
Service Bus application properties to and from Camel message headers.")
- private HeaderFilterStrategy headerFilterStrategy = new
DefaultHeaderFilterStrategy();
+ private HeaderFilterStrategy headerFilterStrategy = new
ServiceBusHeaderFilterStrategy();
@UriParam(label = "consumer", defaultValue = "receiveMessages")
private ServiceBusConsumerOperationDefinition consumerOperation =
ServiceBusConsumerOperationDefinition.receiveMessages;
@UriParam(label = "consumer")
diff --git
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConsumer.java
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConsumer.java
index f3394150162..3727f35869b 100644
---
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConsumer.java
+++
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConsumer.java
@@ -186,7 +186,7 @@ public class ServiceBusConsumer extends DefaultConsumer {
// propagate headers
final HeaderFilterStrategy headerFilterStrategy =
getConfiguration().getHeaderFilterStrategy();
-
message.setHeaders(receivedMessage.getApplicationProperties().entrySet().stream()
+
message.getHeaders().putAll(receivedMessage.getApplicationProperties().entrySet().stream()
.filter(entry ->
!headerFilterStrategy.applyFilterToExternalHeaders(entry.getKey(),
entry.getValue(), exchange))
.collect(Collectors.toMap(Map.Entry::getKey,
Map.Entry::getValue)));
diff --git
a/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusHeaderFilterStrategy.java
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusHeaderFilterStrategy.java
new file mode 100644
index 00000000000..5ab2a97e08a
--- /dev/null
+++
b/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusHeaderFilterStrategy.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.azure.servicebus;
+
+import org.apache.camel.support.DefaultHeaderFilterStrategy;
+
+public class ServiceBusHeaderFilterStrategy extends
DefaultHeaderFilterStrategy {
+ public ServiceBusHeaderFilterStrategy() {
+ super();
+ initialise();
+ }
+
+ private void initialise() {
+ setOutFilterStartsWith("Camel", "camel", "org.apache.camel.");
+ setInFilterStartsWith("Camel", "camel", "org.apache.camel.");
+ }
+}