Andrea Cosentino created CAMEL-25227:
----------------------------------------
Summary: camel-azure-eventhubs: partition header conflict and no
default header filter
Key: CAMEL-25227
URL: https://issues.apache.org/jira/browse/CAMEL-25227
Project: Camel
Issue Type: Bug
Components: camel-azure
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
Fix For: 4.23.0
Follow-up to CAMEL-24158, which targeted two camel-azure-eventhubs problems:
consume-and-republish routes failing on the partition headers, and
Camel-internal headers being copied onto outbound {{EventData}} application
properties. Neither change is effective on main, camel-4.22.x or camel-4.18.x,
and both are in the 4.22.1 and 4.18.4 releases.
*1. Partition headers*
{{EventHubsConsumer}} always sets {{CamelAzureEventHubsPartitionId}}, and sets
{{CamelAzureEventHubsPartitionKey}} whenever the received event has one.
{{EventHubsConfigurationOptionsProxy}} prefers both headers over the endpoint
options. {{EventHubsProducerOperations.createSendOptions}} throws
{{IllegalArgumentException("Both partitionKey and partitionId are set...")}}
when both are present. The CAMEL-24158 change only stopped setting a null
{{PartitionKey}} header, which never triggered the exception. For
{{from("azure-eventhubs:...").to("azure-eventhubs:...")}}:
- an event with a partition key always fails, whatever the producer is
configured with;
- with {{partitionKey}} configured on the producer, every event fails;
- with {{partitionId}} configured on the producer, the configured value is
overridden by the {{CamelAzureEventHubsPartitionId}} header set by the
consumer, which may refer to a partition that does not exist on the target hub.
*2. Header filtering*
{{EventHubsComponent}} extends {{HeaderFilterStrategyComponent}} but installs
no default strategy, so {{getHeaderFilterStrategy()}} is null and the producer
copies all headers with {{putAll(headers)}}. The 4.14, 4.18 and 4.22
upgrade-guide entries saying the producer "now applies a
{{DefaultHeaderFilterStrategy}}" do not match the code. The consumer's own
{{CamelAzureEventHubsEnqueuedTime}} (a {{java.time.Instant}}) ends up in the
AMQP application properties, and the SDK cannot encode it ("No encoding is
known for map entry value of type: java.time.Instant"). As a result, a default
bridge route fails for every event.
*Proposed changes*
- Install a default {{DefaultHeaderFilterStrategy}}, matching the upgrade-guide
text.
- Stop the producer from implicitly reusing the consumer's partition metadata,
while keeping the consumer headers. Options are dedicated producer override
headers (as camel-kafka does with {{CamelKafkaOverrideTopic}} vs
{{CamelKafkaTopic}}) or letting endpoint options take precedence. Add an
upgrade-guide entry.
- Add unit tests that feed a consumer-built exchange into
{{EventHubsProducerOperations}} with a mocked client: keyed and unkeyed events,
each with no config, {{partitionKey}} and {{partitionId}}. Add a
default-configuration filtering test.
*Workaround*
{{removeHeaders("CamelAzureEventHubs\*")}} between an azure-eventhubs consumer
and an azure-eventhubs producer.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)