This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 42204f7ce629 CAMEL-25879: camel-infinispan - the key option of the 
producer takes precedence over the key header (#28174)
42204f7ce629 is described below

commit 42204f7ce629087c0d170e0082056f272526d889
Author: Federico Mariani <[email protected]>
AuthorDate: Thu Oct 22 07:24:29 2026 +0200

    CAMEL-25879: camel-infinispan - the key option of the producer takes 
precedence over the key header (#28174)
    
    The producer resolved the key of every operation from the CamelInfinispanKey
    header first, so the events of an Infinispan consumer, which set that header
    to the key of the event, overrode a key configured on the producer endpoint.
    
    The producer now uses the key option when it is set, and the header only 
when
    the endpoint does not set key. The component docs describe the precedence of
    the key and cache name headers, and the 4.24 upgrade guide lists the change.
    
    Closes #28174
---
 .../catalog/components/infinispan-embedded.json    |  4 +--
 .../camel/catalog/components/infinispan.json       |  4 +--
 .../camel/catalog/docs/infinispan-component.adoc   | 19 ++++++++++++
 .../docs/infinispan-embedded-component.adoc        | 19 ++++++++++++
 .../infinispan/InfinispanConfiguration.java        |  3 +-
 .../component/infinispan/InfinispanProducer.java   | 36 ++++++++++++++--------
 .../infinispan/InfinispanProducerTestSupport.java  |  6 ++--
 .../infinispan/embedded/infinispan-embedded.json   |  4 +--
 .../main/docs/infinispan-embedded-component.adoc   | 19 ++++++++++++
 .../component/infinispan/remote/infinispan.json    |  4 +--
 .../src/main/docs/infinispan-component.adoc        | 19 ++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    | 14 +++++++++
 .../dsl/InfinispanComponentBuilderFactory.java     |  3 +-
 .../InfinispanEmbeddedComponentBuilderFactory.java |  3 +-
 .../InfinispanEmbeddedEndpointBuilderFactory.java  |  6 ++--
 .../InfinispanRemoteEndpointBuilderFactory.java    |  6 ++--
 16 files changed, 139 insertions(+), 30 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/infinispan-embedded.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/infinispan-embedded.json
index c50ae628c899..b884448a4a18 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/infinispan-embedded.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/infinispan-embedded.json
@@ -32,7 +32,7 @@
     "eventTypes": { "index": 5, "kind": "property", "displayName": "Event 
Types", "group": "consumer", "label": "consumer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Specifies the set of 
event types to register by the consumer.Multiple event can be [...]
     "sync": { "index": 6, "kind": "property", "displayName": "Sync", "group": 
"consumer", "label": "consumer", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": true, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "If true, the consumer 
will receive notifications synchronously" },
     "defaultValue": { "index": 7, "kind": "property", "displayName": "Default 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific default 
value for some producer operations" },
-    "key": { "index": 8, "kind": "property", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific key for 
producer operations" },
+    "key": { "index": 8, "kind": "property", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific key for 
producer operations. When set, it takes precedence over the CamelInfinispa [...]
     "lazyStartProducer": { "index": 9, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
     "oldValue": { "index": 10, "kind": "property", "displayName": "Old Value", 
"group": "producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific old 
value for some producer operations" },
     "operation": { "index": 11, "kind": "property", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.infinispan.InfinispanOperation", "enum": [ "PUT", 
"PUTASYNC", "PUTALL", "PUTALLASYNC", "PUTIFABSENT", "PUTIFABSENTASYNC", "GET", 
"GETORDEFAULT", "CONTAINSKEY", "CONTAINSVALUE", "REMOVE", "REMOVEASYNC", 
"REPLACE", "REPLACEASYNC", "SIZE", "CLEAR", "CLEARASYNC", "QUERY", "STATS", 
"COMPUTE", "COMPU [...]
@@ -80,7 +80,7 @@
     "exceptionHandler": { "index": 7, "kind": "parameter", "displayName": 
"Exception Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", 
"deprecated": false, "autowired": false, "secret": false, "description": "To 
let the consumer use a custom ExceptionHandler. Notice if the option 
bridgeErrorHandler is enabled then this option is not in use. By def [...]
     "exchangePattern": { "index": 8, "kind": "parameter", "displayName": 
"Exchange Pattern", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "enum", "javaType": 
"org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the exchange pattern when the consumer creates an exchange." },
     "defaultValue": { "index": 9, "kind": "parameter", "displayName": "Default 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific default 
value for some producer operations" },
-    "key": { "index": 10, "kind": "parameter", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific key for 
producer operations" },
+    "key": { "index": 10, "kind": "parameter", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific key for 
producer operations. When set, it takes precedence over the CamelInfinis [...]
     "oldValue": { "index": 11, "kind": "parameter", "displayName": "Old 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific old 
value for some producer operations" },
     "operation": { "index": 12, "kind": "parameter", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.infinispan.InfinispanOperation", "enum": [ "PUT", 
"PUTASYNC", "PUTALL", "PUTALLASYNC", "PUTIFABSENT", "PUTIFABSENTASYNC", "GET", 
"GETORDEFAULT", "CONTAINSKEY", "CONTAINSVALUE", "REMOVE", "REMOVEASYNC", 
"REPLACE", "REPLACEASYNC", "SIZE", "CLEAR", "CLEARASYNC", "QUERY", "STATS", 
"COMPUTE", "COMP [...]
     "value": { "index": 13, "kind": "parameter", "displayName": "Value", 
"group": "producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific value 
for producer operations" },
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/infinispan.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/infinispan.json
index 39e6f3ebde04..f203e7c39022 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/infinispan.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/infinispan.json
@@ -31,7 +31,7 @@
     "customListener": { "index": 4, "kind": "property", "displayName": "Custom 
Listener", "group": "consumer", "label": "consumer", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteCustomListener", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Returns the custom  [...]
     "eventTypes": { "index": 5, "kind": "property", "displayName": "Event 
Types", "group": "consumer", "label": "consumer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Specifies the set of 
event types to register by the consumer.Multiple event can be sep [...]
     "defaultValue": { "index": 6, "kind": "property", "displayName": "Default 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific default 
value for some producer operations" },
-    "key": { "index": 7, "kind": "property", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific key for 
producer operations" },
+    "key": { "index": 7, "kind": "property", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific key for 
producer operations. When set, it takes precedence over the CamelInfinispanKey 
[...]
     "lazyStartProducer": { "index": 8, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
     "oldValue": { "index": 9, "kind": "property", "displayName": "Old Value", 
"group": "producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific old value 
for some producer operations" },
     "operation": { "index": 10, "kind": "property", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.infinispan.InfinispanOperation", "enum": [ "PUT", 
"PUTASYNC", "PUTALL", "PUTALLASYNC", "PUTIFABSENT", "PUTIFABSENTASYNC", "GET", 
"GETORDEFAULT", "CONTAINSKEY", "CONTAINSVALUE", "REMOVE", "REMOVEASYNC", 
"REPLACE", "REPLACEASYNC", "SIZE", "CLEAR", "CLEARASYNC", "QUERY", "STATS", 
"COMPUTE", "COMPU [...]
@@ -88,7 +88,7 @@
     "exceptionHandler": { "index": 6, "kind": "parameter", "displayName": 
"Exception Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", 
"deprecated": false, "autowired": false, "secret": false, "description": "To 
let the consumer use a custom ExceptionHandler. Notice if the option 
bridgeErrorHandler is enabled then this option is not in use. By def [...]
     "exchangePattern": { "index": 7, "kind": "parameter", "displayName": 
"Exchange Pattern", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "enum", "javaType": 
"org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the exchange pattern when the consumer creates an exchange." },
     "defaultValue": { "index": 8, "kind": "parameter", "displayName": "Default 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific default 
value for some producer operations" },
-    "key": { "index": 9, "kind": "parameter", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific key for 
producer operations" },
+    "key": { "index": 9, "kind": "parameter", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific key for 
producer operations. When set, it takes precedence over the CamelInfinispanKe 
[...]
     "oldValue": { "index": 10, "kind": "parameter", "displayName": "Old 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific old value 
for some producer operations" },
     "operation": { "index": 11, "kind": "parameter", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.infinispan.InfinispanOperation", "enum": [ "PUT", 
"PUTASYNC", "PUTALL", "PUTALLASYNC", "PUTIFABSENT", "PUTIFABSENTASYNC", "GET", 
"GETORDEFAULT", "CONTAINSKEY", "CONTAINSVALUE", "REMOVE", "REMOVEASYNC", 
"REPLACE", "REPLACEASYNC", "SIZE", "CLEAR", "CLEARASYNC", "QUERY", "STATS", 
"COMPUTE", "COMP [...]
     "value": { "index": 12, "kind": "parameter", "displayName": "Value", 
"group": "producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific value for 
producer operations" },
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-component.adoc
index a6a5b9645c52..829f22845288 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-component.adoc
@@ -200,6 +200,25 @@ The resulting value is returned in the exchange *body*.
 Write methods like put(key, value) and remove(key) do not return the previous 
value by default.
 ====
 
+=== Key and cache name headers
+
+The `key` option of the endpoint takes precedence over the 
`CamelInfinispanKey` header. When the endpoint does not set
+`key`, the producer uses the `CamelInfinispanKey` header.
+
+The `CamelInfinispanCacheName` header takes precedence over the cache name of 
the endpoint.
+
+An `infinispan` consumer sets `CamelInfinispanKey` and 
`CamelInfinispanCacheName` to the key and the cache of the event.
+When a route sends those events to an `infinispan` producer, the producer 
works on the cache of the event, and on the key
+of the event unless the endpoint sets `key`. To use the cache and the key 
configured on the producer endpoint, remove
+the headers first:
+
+[source,java]
+----
+from("infinispan:source")
+    .removeHeaders("CamelInfinispan*")
+    .to("infinispan:target?operation=PUT&key=myKey&value=myValue");
+----
+
 == Examples
 
 * Put a key/value into a named cache:
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-embedded-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-embedded-component.adoc
index 6be7f5019d0f..3221910ea61b 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-embedded-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/infinispan-embedded-component.adoc
@@ -214,6 +214,25 @@ This section lists all available operations, along with 
their header information
 Write methods like put(key, value) and remove(key) do not return the previous 
value by default.
 ====
 
+=== Key and cache name headers
+
+The `key` option of the endpoint takes precedence over the 
`CamelInfinispanKey` header. When the endpoint does not set
+`key`, the producer uses the `CamelInfinispanKey` header.
+
+The `CamelInfinispanCacheName` header takes precedence over the cache name of 
the endpoint.
+
+An `infinispan-embedded` consumer sets `CamelInfinispanKey` and 
`CamelInfinispanCacheName` to the key and the cache of the event.
+When a route sends those events to an `infinispan-embedded` producer, the 
producer works on the cache of the event, and on the key
+of the event unless the endpoint sets `key`. To use the cache and the key 
configured on the producer endpoint, remove
+the headers first:
+
+[source,java]
+----
+from("infinispan-embedded:source")
+    .removeHeaders("CamelInfinispan*")
+    .to("infinispan-embedded:target?operation=PUT&key=myKey&value=myValue");
+----
+
 == Examples
 
 * Put a key/value into a named cache:
diff --git 
a/components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
 
b/components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
index 0a96215cfab6..297894cc2cac 100644
--- 
a/components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
+++ 
b/components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanConfiguration.java
@@ -26,7 +26,8 @@ public abstract class InfinispanConfiguration {
               enums = 
"PUT,PUTASYNC,PUTALL,PUTALLASYNC,PUTIFABSENT,PUTIFABSENTASYNC,GET,GETORDEFAULT,CONTAINSKEY,CONTAINSVALUE,REMOVE,REMOVEASYNC,REPLACE,REPLACEASYNC,SIZE,CLEAR,CLEARASYNC,QUERY,STATS,COMPUTE,COMPUTEASYNC")
     private InfinispanOperation operation = InfinispanOperation.PUT;
 
-    @UriParam(label = "producer", description = "Set a specific key for 
producer operations")
+    @UriParam(label = "producer",
+              description = "Set a specific key for producer operations. When 
set, it takes precedence over the CamelInfinispanKey header.")
     private Object key;
 
     @UriParam(label = "producer", description = "Set a specific value for 
producer operations")
diff --git 
a/components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanProducer.java
 
b/components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanProducer.java
index 196e174d2c33..21b394bc890a 100644
--- 
a/components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanProducer.java
+++ 
b/components/camel-infinispan/camel-infinispan-common/src/main/java/org/apache/camel/component/infinispan/InfinispanProducer.java
@@ -68,7 +68,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("PUT")
     public void onPut(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object value = message.getHeader(InfinispanConstants.VALUE, 
configuration::getValue);
         final Object result;
 
@@ -94,7 +94,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("PUTASYNC")
     public void onPutAsync(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object value = message.getHeader(InfinispanConstants.VALUE, 
configuration::getValue);
         final CompletableFuture<Object> result;
 
@@ -167,7 +167,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("PUTIFABSENT")
     public void onPutIfAbsent(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object value = message.getHeader(InfinispanConstants.VALUE, 
configuration::getValue);
         final Object result;
 
@@ -193,7 +193,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("PUTIFABSENTASYNC")
     public void onPutIfAbsentAsync(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object value = message.getHeader(InfinispanConstants.VALUE, 
configuration::getValue);
         final CompletableFuture<Object> result;
 
@@ -219,7 +219,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("GET")
     public void onGet(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object result = cache.get(key);
 
         setResult(message, result);
@@ -228,7 +228,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("GETORDEFAULT")
     public void onGetOrDefault(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object defaultValue = 
message.getHeader(InfinispanConstants.DEFAULT_VALUE, 
configuration::getDefaultValue);
         final Object result = cache.getOrDefault(key, defaultValue);
 
@@ -238,7 +238,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("CONTAINSKEY")
     public void onContainsKey(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object result = cache.containsKey(key);
 
         setResult(message, result);
@@ -256,7 +256,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("REMOVE")
     public void onRemove(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object value = message.getHeader(InfinispanConstants.VALUE, 
configuration::getValue);
         final Object result;
 
@@ -272,7 +272,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("REMOVEASYNC")
     public void onRemoveAsync(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object value = message.getHeader(InfinispanConstants.VALUE, 
configuration::getValue);
         final CompletableFuture<Object> resultRemoveAsyncKey;
         final CompletableFuture<Boolean> resultRemoveAsyncKeyValue;
@@ -289,7 +289,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("REPLACE")
     public void onReplace(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object value = message.getHeader(InfinispanConstants.VALUE, 
configuration::getValue);
         final Object oldValue = 
message.getHeader(InfinispanConstants.OLD_VALUE, configuration::getOldValue);
         final Object result;
@@ -328,7 +328,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("REPLACEASYNC")
     public void onReplaceAsync(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object value = message.getHeader(InfinispanConstants.VALUE, 
configuration::getValue);
         final Object oldValue = 
message.getHeader(InfinispanConstants.OLD_VALUE, configuration::getOldValue);
         final CompletableFuture<Object> resultWithNewValue;
@@ -396,7 +396,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("COMPUTE")
     public void onCompute(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final Object result = cache.compute(key, 
configuration.getRemappingFunction());
 
         setResult(message, result);
@@ -406,7 +406,7 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
     @InvokeOnHeader("COMPUTEASYNC")
     public void onComputeAsync(Message message) {
         final BasicCache<Object, Object> cache = getCache(message);
-        final Object key = message.getHeader(InfinispanConstants.KEY, 
configuration::getKey);
+        final Object key = getKey(message);
         final CompletableFuture<Object> result = cache.computeAsync(key, 
configuration.getRemappingFunction());
 
         setResult(message, result);
@@ -420,6 +420,16 @@ public abstract class InfinispanProducer<M extends 
InfinispanManager, C extends
         return manager.getCache(message, this.cacheName);
     }
 
+    /**
+     * Resolves the cache key: the key configured on the endpoint takes 
precedence over the
+     * {@link InfinispanConstants#KEY} header. Note that {@link 
#getCache(Message)} uses the opposite precedence: the
+     * {@link InfinispanConstants#CACHE_NAME} header wins over the cache of 
the endpoint.
+     */
+    protected Object getKey(Message message) {
+        Object key = configuration.getKey();
+        return key != null ? key : message.getHeader(InfinispanConstants.KEY);
+    }
+
     protected boolean hasLifespan(Message message) {
         return hasExpiry(message, InfinispanConstants.LIFESPAN_TIME, 
InfinispanConstants.LIFESPAN_TIME_UNIT,
                 lifespanReported);
diff --git 
a/components/camel-infinispan/camel-infinispan-common/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTestSupport.java
 
b/components/camel-infinispan/camel-infinispan-common/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTestSupport.java
index 1f93ee29468e..8575d9399951 100644
--- 
a/components/camel-infinispan/camel-infinispan-common/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTestSupport.java
+++ 
b/components/camel-infinispan/camel-infinispan-common/src/test/java/org/apache/camel/component/infinispan/InfinispanProducerTestSupport.java
@@ -859,7 +859,7 @@ public interface InfinispanProducerTestSupport {
     }
 
     @Test
-    default void 
publishKeyAndValueByExplicitlySpecifyingTheKeyAndValueOptionsHeaderHavePriorities()
 {
+    default void 
publishKeyAndValueByExplicitlySpecifyingTheKeyAndValueOptionsKeyOptionHasPriority()
 {
         fluentTemplate()
                 .to("direct:explicitput")
                 .withHeader(InfinispanConstants.KEY, KEY_ONE)
@@ -867,6 +867,8 @@ public interface InfinispanProducerTestSupport {
                 .withHeader(InfinispanConstants.OPERATION, 
InfinispanOperation.PUT)
                 .send();
 
-        assertEquals(VALUE_ONE, getCache().get(KEY_ONE));
+        // the key option of the endpoint wins over the key header, the value 
header still wins over the value option
+        assertEquals(VALUE_ONE, getCache().get("a"));
+        assertNull(getCache().get(KEY_ONE));
     }
 }
diff --git 
a/components/camel-infinispan/camel-infinispan-embedded/src/generated/resources/META-INF/org/apache/camel/component/infinispan/embedded/infinispan-embedded.json
 
b/components/camel-infinispan/camel-infinispan-embedded/src/generated/resources/META-INF/org/apache/camel/component/infinispan/embedded/infinispan-embedded.json
index c50ae628c899..b884448a4a18 100644
--- 
a/components/camel-infinispan/camel-infinispan-embedded/src/generated/resources/META-INF/org/apache/camel/component/infinispan/embedded/infinispan-embedded.json
+++ 
b/components/camel-infinispan/camel-infinispan-embedded/src/generated/resources/META-INF/org/apache/camel/component/infinispan/embedded/infinispan-embedded.json
@@ -32,7 +32,7 @@
     "eventTypes": { "index": 5, "kind": "property", "displayName": "Event 
Types", "group": "consumer", "label": "consumer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Specifies the set of 
event types to register by the consumer.Multiple event can be [...]
     "sync": { "index": 6, "kind": "property", "displayName": "Sync", "group": 
"consumer", "label": "consumer", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": true, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "If true, the consumer 
will receive notifications synchronously" },
     "defaultValue": { "index": 7, "kind": "property", "displayName": "Default 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific default 
value for some producer operations" },
-    "key": { "index": 8, "kind": "property", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific key for 
producer operations" },
+    "key": { "index": 8, "kind": "property", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific key for 
producer operations. When set, it takes precedence over the CamelInfinispa [...]
     "lazyStartProducer": { "index": 9, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
     "oldValue": { "index": 10, "kind": "property", "displayName": "Old Value", 
"group": "producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific old 
value for some producer operations" },
     "operation": { "index": 11, "kind": "property", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.infinispan.InfinispanOperation", "enum": [ "PUT", 
"PUTASYNC", "PUTALL", "PUTALLASYNC", "PUTIFABSENT", "PUTIFABSENTASYNC", "GET", 
"GETORDEFAULT", "CONTAINSKEY", "CONTAINSVALUE", "REMOVE", "REMOVEASYNC", 
"REPLACE", "REPLACEASYNC", "SIZE", "CLEAR", "CLEARASYNC", "QUERY", "STATS", 
"COMPUTE", "COMPU [...]
@@ -80,7 +80,7 @@
     "exceptionHandler": { "index": 7, "kind": "parameter", "displayName": 
"Exception Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", 
"deprecated": false, "autowired": false, "secret": false, "description": "To 
let the consumer use a custom ExceptionHandler. Notice if the option 
bridgeErrorHandler is enabled then this option is not in use. By def [...]
     "exchangePattern": { "index": 8, "kind": "parameter", "displayName": 
"Exchange Pattern", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "enum", "javaType": 
"org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the exchange pattern when the consumer creates an exchange." },
     "defaultValue": { "index": 9, "kind": "parameter", "displayName": "Default 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific default 
value for some producer operations" },
-    "key": { "index": 10, "kind": "parameter", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific key for 
producer operations" },
+    "key": { "index": 10, "kind": "parameter", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific key for 
producer operations. When set, it takes precedence over the CamelInfinis [...]
     "oldValue": { "index": 11, "kind": "parameter", "displayName": "Old 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific old 
value for some producer operations" },
     "operation": { "index": 12, "kind": "parameter", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.infinispan.InfinispanOperation", "enum": [ "PUT", 
"PUTASYNC", "PUTALL", "PUTALLASYNC", "PUTIFABSENT", "PUTIFABSENTASYNC", "GET", 
"GETORDEFAULT", "CONTAINSKEY", "CONTAINSVALUE", "REMOVE", "REMOVEASYNC", 
"REPLACE", "REPLACEASYNC", "SIZE", "CLEAR", "CLEARASYNC", "QUERY", "STATS", 
"COMPUTE", "COMP [...]
     "value": { "index": 13, "kind": "parameter", "displayName": "Value", 
"group": "producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.embedded.InfinispanEmbeddedConfiguration",
 "configurationField": "configuration", "description": "Set a specific value 
for producer operations" },
diff --git 
a/components/camel-infinispan/camel-infinispan-embedded/src/main/docs/infinispan-embedded-component.adoc
 
b/components/camel-infinispan/camel-infinispan-embedded/src/main/docs/infinispan-embedded-component.adoc
index 6be7f5019d0f..3221910ea61b 100644
--- 
a/components/camel-infinispan/camel-infinispan-embedded/src/main/docs/infinispan-embedded-component.adoc
+++ 
b/components/camel-infinispan/camel-infinispan-embedded/src/main/docs/infinispan-embedded-component.adoc
@@ -214,6 +214,25 @@ This section lists all available operations, along with 
their header information
 Write methods like put(key, value) and remove(key) do not return the previous 
value by default.
 ====
 
+=== Key and cache name headers
+
+The `key` option of the endpoint takes precedence over the 
`CamelInfinispanKey` header. When the endpoint does not set
+`key`, the producer uses the `CamelInfinispanKey` header.
+
+The `CamelInfinispanCacheName` header takes precedence over the cache name of 
the endpoint.
+
+An `infinispan-embedded` consumer sets `CamelInfinispanKey` and 
`CamelInfinispanCacheName` to the key and the cache of the event.
+When a route sends those events to an `infinispan-embedded` producer, the 
producer works on the cache of the event, and on the key
+of the event unless the endpoint sets `key`. To use the cache and the key 
configured on the producer endpoint, remove
+the headers first:
+
+[source,java]
+----
+from("infinispan-embedded:source")
+    .removeHeaders("CamelInfinispan*")
+    .to("infinispan-embedded:target?operation=PUT&key=myKey&value=myValue");
+----
+
 == Examples
 
 * Put a key/value into a named cache:
diff --git 
a/components/camel-infinispan/camel-infinispan/src/generated/resources/META-INF/org/apache/camel/component/infinispan/remote/infinispan.json
 
b/components/camel-infinispan/camel-infinispan/src/generated/resources/META-INF/org/apache/camel/component/infinispan/remote/infinispan.json
index 39e6f3ebde04..f203e7c39022 100644
--- 
a/components/camel-infinispan/camel-infinispan/src/generated/resources/META-INF/org/apache/camel/component/infinispan/remote/infinispan.json
+++ 
b/components/camel-infinispan/camel-infinispan/src/generated/resources/META-INF/org/apache/camel/component/infinispan/remote/infinispan.json
@@ -31,7 +31,7 @@
     "customListener": { "index": 4, "kind": "property", "displayName": "Custom 
Listener", "group": "consumer", "label": "consumer", "required": false, "type": 
"object", "javaType": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteCustomListener", 
"deprecated": false, "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Returns the custom  [...]
     "eventTypes": { "index": 5, "kind": "property", "displayName": "Event 
Types", "group": "consumer", "label": "consumer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Specifies the set of 
event types to register by the consumer.Multiple event can be sep [...]
     "defaultValue": { "index": 6, "kind": "property", "displayName": "Default 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific default 
value for some producer operations" },
-    "key": { "index": 7, "kind": "property", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific key for 
producer operations" },
+    "key": { "index": 7, "kind": "property", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific key for 
producer operations. When set, it takes precedence over the CamelInfinispanKey 
[...]
     "lazyStartProducer": { "index": 8, "kind": "property", "displayName": 
"Lazy Start Producer", "group": "producer", "label": "producer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Whether the producer should be started lazy (on the first message). By 
starting lazy you can use this to allow CamelContext and routes to startup in 
situations where a producer may otherwise fail [...]
     "oldValue": { "index": 9, "kind": "property", "displayName": "Old Value", 
"group": "producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific old value 
for some producer operations" },
     "operation": { "index": 10, "kind": "property", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.infinispan.InfinispanOperation", "enum": [ "PUT", 
"PUTASYNC", "PUTALL", "PUTALLASYNC", "PUTIFABSENT", "PUTIFABSENTASYNC", "GET", 
"GETORDEFAULT", "CONTAINSKEY", "CONTAINSVALUE", "REMOVE", "REMOVEASYNC", 
"REPLACE", "REPLACEASYNC", "SIZE", "CLEAR", "CLEARASYNC", "QUERY", "STATS", 
"COMPUTE", "COMPU [...]
@@ -88,7 +88,7 @@
     "exceptionHandler": { "index": 6, "kind": "parameter", "displayName": 
"Exception Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "object", "javaType": 
"org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", 
"deprecated": false, "autowired": false, "secret": false, "description": "To 
let the consumer use a custom ExceptionHandler. Notice if the option 
bridgeErrorHandler is enabled then this option is not in use. By def [...]
     "exchangePattern": { "index": 7, "kind": "parameter", "displayName": 
"Exchange Pattern", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "enum", "javaType": 
"org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut" ], 
"deprecated": false, "autowired": false, "secret": false, "description": "Sets 
the exchange pattern when the consumer creates an exchange." },
     "defaultValue": { "index": 8, "kind": "parameter", "displayName": "Default 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific default 
value for some producer operations" },
-    "key": { "index": 9, "kind": "parameter", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific key for 
producer operations" },
+    "key": { "index": 9, "kind": "parameter", "displayName": "Key", "group": 
"producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific key for 
producer operations. When set, it takes precedence over the CamelInfinispanKe 
[...]
     "oldValue": { "index": 10, "kind": "parameter", "displayName": "Old 
Value", "group": "producer", "label": "producer", "required": false, "type": 
"object", "javaType": "java.lang.Object", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific old value 
for some producer operations" },
     "operation": { "index": 11, "kind": "parameter", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.infinispan.InfinispanOperation", "enum": [ "PUT", 
"PUTASYNC", "PUTALL", "PUTALLASYNC", "PUTIFABSENT", "PUTIFABSENTASYNC", "GET", 
"GETORDEFAULT", "CONTAINSKEY", "CONTAINSVALUE", "REMOVE", "REMOVEASYNC", 
"REPLACE", "REPLACEASYNC", "SIZE", "CLEAR", "CLEARASYNC", "QUERY", "STATS", 
"COMPUTE", "COMP [...]
     "value": { "index": 12, "kind": "parameter", "displayName": "Value", 
"group": "producer", "label": "producer", "required": false, "type": "object", 
"javaType": "java.lang.Object", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.infinispan.remote.InfinispanRemoteConfiguration", 
"configurationField": "configuration", "description": "Set a specific value for 
producer operations" },
diff --git 
a/components/camel-infinispan/camel-infinispan/src/main/docs/infinispan-component.adoc
 
b/components/camel-infinispan/camel-infinispan/src/main/docs/infinispan-component.adoc
index a6a5b9645c52..829f22845288 100644
--- 
a/components/camel-infinispan/camel-infinispan/src/main/docs/infinispan-component.adoc
+++ 
b/components/camel-infinispan/camel-infinispan/src/main/docs/infinispan-component.adoc
@@ -200,6 +200,25 @@ The resulting value is returned in the exchange *body*.
 Write methods like put(key, value) and remove(key) do not return the previous 
value by default.
 ====
 
+=== Key and cache name headers
+
+The `key` option of the endpoint takes precedence over the 
`CamelInfinispanKey` header. When the endpoint does not set
+`key`, the producer uses the `CamelInfinispanKey` header.
+
+The `CamelInfinispanCacheName` header takes precedence over the cache name of 
the endpoint.
+
+An `infinispan` consumer sets `CamelInfinispanKey` and 
`CamelInfinispanCacheName` to the key and the cache of the event.
+When a route sends those events to an `infinispan` producer, the producer 
works on the cache of the event, and on the key
+of the event unless the endpoint sets `key`. To use the cache and the key 
configured on the producer endpoint, remove
+the headers first:
+
+[source,java]
+----
+from("infinispan:source")
+    .removeHeaders("CamelInfinispan*")
+    .to("infinispan:target?operation=PUT&key=myKey&value=myValue");
+----
+
 == Examples
 
 * Put a key/value into a named cache:
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index c1d636040256..cb4dc32a61e2 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -2241,6 +2241,20 @@ and the delay between two connection attempts stayed 10 
seconds. It now sets tha
 delay, and a value of 0 or less is rejected. To set the request timeout, use 
the `requestTimeout` option instead
 (for example `camel.component.milo-client.requestTimeout`, or 
`getConfiguration().setRequestTimeout(...)` in Java).
 
+=== camel-infinispan - the key option of the producer takes precedence over 
the key header
+
+The `infinispan` and `infinispan-embedded` producers now use the `key` option 
of the endpoint when it is set, and use the
+`CamelInfinispanKey` header only when the endpoint does not set `key`. 
Previously the header took precedence over the
+option, so a route that sent the events of an Infinispan consumer, which set 
`CamelInfinispanKey` to the key of the event,
+to a producer with a fixed `key` worked on the key of the event.
+
+Routes that set `key` on the endpoint and override it per message with the 
`CamelInfinispanKey` header must remove `key`
+from the endpoint.
+
+The `CamelInfinispanCacheName` header still takes precedence over the cache of 
the endpoint, so a route that sends the
+events of an Infinispan consumer to a producer must still remove the 
`CamelInfinispan*` headers first, see _Key and cache
+name headers_ in the component docs.
+
 === camel-protobuf - a bytes field in a Map
 
 When a protobuf message is converted to a `Map` (for example 
`getBody(Map.class)` after unmarshalling), the value of
diff --git 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/InfinispanComponentBuilderFactory.java
 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/InfinispanComponentBuilderFactory.java
index a876ef1b8b2f..d153a473c8eb 100644
--- 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/InfinispanComponentBuilderFactory.java
+++ 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/InfinispanComponentBuilderFactory.java
@@ -178,7 +178,8 @@ public interface InfinispanComponentBuilderFactory {
         }
     
         /**
-         * Set a specific key for producer operations.
+         * Set a specific key for producer operations. When set, it takes
+         * precedence over the CamelInfinispanKey header.
          * 
          * The option is a: &lt;code&gt;java.lang.Object&lt;/code&gt; type.
          * 
diff --git 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/InfinispanEmbeddedComponentBuilderFactory.java
 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/InfinispanEmbeddedComponentBuilderFactory.java
index 51039f0b8728..7ca53573a997 100644
--- 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/InfinispanEmbeddedComponentBuilderFactory.java
+++ 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/InfinispanEmbeddedComponentBuilderFactory.java
@@ -199,7 +199,8 @@ public interface InfinispanEmbeddedComponentBuilderFactory {
         }
     
         /**
-         * Set a specific key for producer operations.
+         * Set a specific key for producer operations. When set, it takes
+         * precedence over the CamelInfinispanKey header.
          * 
          * The option is a: &lt;code&gt;java.lang.Object&lt;/code&gt; type.
          * 
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfinispanEmbeddedEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfinispanEmbeddedEndpointBuilderFactory.java
index c2380faa2ac9..25d9022d1caf 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfinispanEmbeddedEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfinispanEmbeddedEndpointBuilderFactory.java
@@ -526,7 +526,8 @@ public interface InfinispanEmbeddedEndpointBuilderFactory {
             return this;
         }
         /**
-         * Set a specific key for producer operations.
+         * Set a specific key for producer operations. When set, it takes
+         * precedence over the CamelInfinispanKey header.
          * 
          * The option is a: <code>java.lang.Object</code> type.
          * 
@@ -540,7 +541,8 @@ public interface InfinispanEmbeddedEndpointBuilderFactory {
             return this;
         }
         /**
-         * Set a specific key for producer operations.
+         * Set a specific key for producer operations. When set, it takes
+         * precedence over the CamelInfinispanKey header.
          * 
          * The option will be converted to a <code>java.lang.Object</code> 
type.
          * 
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfinispanRemoteEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfinispanRemoteEndpointBuilderFactory.java
index 74729d024de2..0369b8a69eb4 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfinispanRemoteEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/InfinispanRemoteEndpointBuilderFactory.java
@@ -626,7 +626,8 @@ public interface InfinispanRemoteEndpointBuilderFactory {
             return this;
         }
         /**
-         * Set a specific key for producer operations.
+         * Set a specific key for producer operations. When set, it takes
+         * precedence over the CamelInfinispanKey header.
          * 
          * The option is a: <code>java.lang.Object</code> type.
          * 
@@ -640,7 +641,8 @@ public interface InfinispanRemoteEndpointBuilderFactory {
             return this;
         }
         /**
-         * Set a specific key for producer operations.
+         * Set a specific key for producer operations. When set, it takes
+         * precedence over the CamelInfinispanKey header.
          * 
          * The option will be converted to a <code>java.lang.Object</code> 
type.
          * 

Reply via email to