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

davsclaus pushed a commit to branch CAMEL-27725-avro-rpc
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 8591fefbf8d06ae6e3696e977013ce4f68d068d2
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 27 21:11:21 2026 +0100

    CAMEL-27725: camel-avro-rpc - consumers sharing a server must match, 
protocolLocation is read, uriAuthority deprecated
    
    - Consumers on the same host and port share the Avro server of the first
      consumer. A consumer with another transport, protocol or
      reflectionProtocol now fails to start with a clear message, instead of
      being served with the wrong protocol or responder.
    - A consumer that fails to register no longer unregisters the consumer that
      holds its message name (or the default consumer) when it is stopped, and
      unregister no longer fails with a NullPointerException for an unknown
      listener. register and unregister are synchronized, so two consumers that
      start at the same time cannot create two servers.
    - protocolLocation loads the protocol from an Avro protocol file in JSON
      (.avpr), when neither protocol nor protocolClassName is set.
    - uriAuthority is deprecated: it never had an effect. The listeners are
      keyed by the host and port of the endpoint.
    - singleParameter has the consumer label, and the doc page says that the
      exchange pattern of a consumer follows the called message.
    - AvroNettyConsumerTest had two avro:http consumers on the netty port, which
      only worked because they joined the netty server; they are netty now.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../org/apache/camel/catalog/components/avro.json  |  14 +-
 .../apache/camel/catalog/docs/avro-component.adoc  |  25 +++-
 .../org/apache/camel/component/avro/avro.json      |  14 +-
 .../src/main/docs/avro-component.adoc              |  25 +++-
 .../apache/camel/component/avro/AvroComponent.java |  14 +-
 .../camel/component/avro/AvroConfiguration.java    |  27 +++-
 .../apache/camel/component/avro/AvroConsumer.java  |  17 ++-
 .../apache/camel/component/avro/AvroEndpoint.java  |  12 +-
 .../apache/camel/component/avro/AvroListener.java  |  50 ++++++-
 .../avro/AvroConsumerSharedServerTest.java         | 129 ++++++++++++++++
 .../component/avro/AvroNettyConsumerTest.java      |   4 +-
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    |  12 ++
 .../component/dsl/AvroComponentBuilderFactory.java |  63 ++++----
 .../endpoint/dsl/AvroEndpointBuilderFactory.java   | 163 +++++++--------------
 14 files changed, 390 insertions(+), 179 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/avro.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/avro.json
index ad53845f1d74..d4635c50449f 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/avro.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/avro.json
@@ -26,11 +26,11 @@
   "componentProperties": {
     "protocol": { "index": 0, "kind": "property", "displayName": "Protocol", 
"group": "common", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The Avro protocol (org.apache.avro.Protocol) 
that defines the messages, such as the PROTOCOL field of a class generate [...]
     "protocolClassName": { "index": 1, "kind": "property", "displayName": 
"Protocol Class Name", "group": "common", "label": "", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The fully qualified name of the class that 
defines the protocol. For a class generated by the Avro compile [...]
-    "protocolLocation": { "index": 2, "kind": "property", "displayName": 
"Protocol Location", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Not used: the component does not read this 
option. Use protocol or protocolClassName instead." },
+    "protocolLocation": { "index": 2, "kind": "property", "displayName": 
"Protocol Location", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The location of an Avro protocol file in JSON 
(.avpr), such as classpath:my-protocol.avpr or file:\/path\/my- [...]
     "reflectionProtocol": { "index": 3, "kind": "property", "displayName": 
"Reflection Protocol", "group": "common", "label": "", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Whether the protocol is a reflect protocol, 
built by Avro reflection from a Java interface [...]
-    "singleParameter": { "index": 4, "kind": "property", "displayName": 
"Single Parameter", "group": "common", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Whether the consumer sets the message body to 
the one parameter of the called message, instead o [...]
-    "uriAuthority": { "index": 5, "kind": "property", "displayName": "Uri 
Authority", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The authority (host and port) of the endpoint 
URI, which the component sets from the URI. Consumers with the same aut [...]
-    "bridgeErrorHandler": { "index": 6, "kind": "property", "displayName": 
"Bridge Error Handler", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Allows for bridging the consumer to the Camel routing Error Handler, which 
mean any exceptions (if possible) occurred while the Camel consumer is trying 
to pickup incoming messages, or the like [...]
+    "uriAuthority": { "index": 4, "kind": "property", "displayName": "Uri 
Authority", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": true, 
"deprecationNote": "Not used; the host and port of the endpoint URI are used 
instead", "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Deprecated: not used. The compo [...]
+    "bridgeErrorHandler": { "index": 5, "kind": "property", "displayName": 
"Bridge Error Handler", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Allows for bridging the consumer to the Camel routing Error Handler, which 
mean any exceptions (if possible) occurred while the Camel consumer is trying 
to pickup incoming messages, or the like [...]
+    "singleParameter": { "index": 6, "kind": "property", "displayName": 
"Single Parameter", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, 
"configurationClass": "org.apache.camel.component.avro.AvroConfiguration", 
"configurationField": "configuration", "description": "Whether the consumer 
sets the message body to the one parameter of the called message, [...]
     "lazyStartProducer": { "index": 7, "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 [...]
     "autowiredEnabled": { "index": 8, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
     "configuration": { "index": 9, "kind": "property", "displayName": 
"Configuration", "group": "advanced", "label": "advanced", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.component.avro.AvroConfiguration", "deprecated": false, 
"autowired": false, "secret": false, "description": "A shared configuration 
that every endpoint copies as its starting point. The options of the endpoint 
URI override its values." },
@@ -52,10 +52,10 @@
     "messageName": { "index": 3, "kind": "path", "displayName": "Message 
Name", "group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The name of the protocol message to call or 
serve. The producer calls it unless the CamelAvroMessageName header is set. A c 
[...]
     "protocol": { "index": 4, "kind": "parameter", "displayName": "Protocol", 
"group": "common", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The Avro protocol (org.apache.avro.Protocol) 
that defines the messages, such as the PROTOCOL field of a class generat [...]
     "protocolClassName": { "index": 5, "kind": "parameter", "displayName": 
"Protocol Class Name", "group": "common", "label": "", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The fully qualified name of the class that 
defines the protocol. For a class generated by the Avro compil [...]
-    "protocolLocation": { "index": 6, "kind": "parameter", "displayName": 
"Protocol Location", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Not used: the component does not read this 
option. Use protocol or protocolClassName instead." },
+    "protocolLocation": { "index": 6, "kind": "parameter", "displayName": 
"Protocol Location", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The location of an Avro protocol file in JSON 
(.avpr), such as classpath:my-protocol.avpr or file:\/path\/my [...]
     "reflectionProtocol": { "index": 7, "kind": "parameter", "displayName": 
"Reflection Protocol", "group": "common", "label": "", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Whether the protocol is a reflect protocol, 
built by Avro reflection from a Java interfac [...]
-    "singleParameter": { "index": 8, "kind": "parameter", "displayName": 
"Single Parameter", "group": "common", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Whether the consumer sets the message body to 
the one parameter of the called message, instead  [...]
-    "uriAuthority": { "index": 9, "kind": "parameter", "displayName": "Uri 
Authority", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The authority (host and port) of the endpoint 
URI, which the component sets from the URI. Consumers with the same au [...]
+    "uriAuthority": { "index": 8, "kind": "parameter", "displayName": "Uri 
Authority", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": true, 
"deprecationNote": "Not used; the host and port of the endpoint URI are used 
instead", "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Deprecated: not used. The comp [...]
+    "singleParameter": { "index": 9, "kind": "parameter", "displayName": 
"Single Parameter", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, 
"configurationClass": "org.apache.camel.component.avro.AvroConfiguration", 
"configurationField": "configuration", "description": "Whether the consumer 
sets the message body to the one parameter of the called message [...]
     "bridgeErrorHandler": { "index": 10, "kind": "parameter", "displayName": 
"Bridge Error Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Allows for bridging the consumer to the 
Camel routing Error Handler, which mean any exceptions (if possible) occurred 
while the Camel consumer is trying to pickup incoming [...]
     "exceptionHandler": { "index": 11, "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 de [...]
     "exchangePattern": { "index": 12, "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." },
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-component.adoc
index c186f9b588b4..270d8586bf35 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/avro-component.adoc
@@ -131,6 +131,13 @@ same socket. Dispatching to the correct route will be done 
by the avro
 component automatically. Route with no messageName specified (if any)
 will be used as default.
 
+The consumers on the same host and port share one Avro server, which the first 
consumer that starts creates with its
+transport, protocol and `reflectionProtocol`. A consumer on the same host and 
port with another transport, another
+protocol or another `reflectionProtocol` value fails to start; use another 
port for it.
+
+The exchange pattern of a consumer follows the called message: `InOnly` for a 
message with a `null` response, else
+`InOut`. The `exchangePattern` option has no effect on the consumer.
+
 When using camel producers for avro ipc, the "in" message body needs to
 contain the parameters of the operation specified in the avro protocol.
 The response will be added in the body of the "out" message.
@@ -145,10 +152,26 @@ got only one parameter, *since 2.12* you can use 
`singleParameter` URI
 option to receive it directly in the "in" message body without array
 wrapping.
 
+=== The protocol
+
+The endpoint needs the Avro protocol, from one of these options, in this order:
+
+* `protocol`: an `org.apache.avro.Protocol` instance, such as the `PROTOCOL` 
field of a class that the Avro compiler
+  generated.
+* `protocolClassName`: the class of the protocol. For a class generated by the 
Avro compiler its `PROTOCOL` field is
+  used; for any other class or interface, Avro reflection builds the protocol, 
and `reflectionProtocol` is turned on.
+* `protocolLocation`: an Avro protocol file in JSON (`.avpr`), such as 
`classpath:key-value.avpr`. Records of the
+  protocol use the classes that the Avro compiler generated when they are on 
the classpath. An Avro IDL file
+  (`.avdl`) is not supported: convert it to `.avpr` with the Avro tools first.
+
+----
+avro:netty:localhost:9000/get?protocolLocation=classpath:key-value.avpr
+----
+
 === Trusted packages apply to the whole JVM
 
 Avro validates the classes it loads for a schema, and only loads classes from 
trusted packages. Camel adds the
-packages of the `protocol` or `protocolClassName` option, and the packages of 
the `serializablePackages` option, to
+packages of the `protocol`, `protocolClassName` or `protocolLocation` option, 
and the packages of the `serializablePackages` option, to
 these trusted packages.
 
 Avro has one class validator for the whole JVM. So a package trusted by one 
endpoint is trusted for all Avro class
diff --git 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/generated/resources/META-INF/org/apache/camel/component/avro/avro.json
 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/generated/resources/META-INF/org/apache/camel/component/avro/avro.json
index ad53845f1d74..d4635c50449f 100644
--- 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/generated/resources/META-INF/org/apache/camel/component/avro/avro.json
+++ 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/generated/resources/META-INF/org/apache/camel/component/avro/avro.json
@@ -26,11 +26,11 @@
   "componentProperties": {
     "protocol": { "index": 0, "kind": "property", "displayName": "Protocol", 
"group": "common", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The Avro protocol (org.apache.avro.Protocol) 
that defines the messages, such as the PROTOCOL field of a class generate [...]
     "protocolClassName": { "index": 1, "kind": "property", "displayName": 
"Protocol Class Name", "group": "common", "label": "", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The fully qualified name of the class that 
defines the protocol. For a class generated by the Avro compile [...]
-    "protocolLocation": { "index": 2, "kind": "property", "displayName": 
"Protocol Location", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Not used: the component does not read this 
option. Use protocol or protocolClassName instead." },
+    "protocolLocation": { "index": 2, "kind": "property", "displayName": 
"Protocol Location", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The location of an Avro protocol file in JSON 
(.avpr), such as classpath:my-protocol.avpr or file:\/path\/my- [...]
     "reflectionProtocol": { "index": 3, "kind": "property", "displayName": 
"Reflection Protocol", "group": "common", "label": "", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Whether the protocol is a reflect protocol, 
built by Avro reflection from a Java interface [...]
-    "singleParameter": { "index": 4, "kind": "property", "displayName": 
"Single Parameter", "group": "common", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Whether the consumer sets the message body to 
the one parameter of the called message, instead o [...]
-    "uriAuthority": { "index": 5, "kind": "property", "displayName": "Uri 
Authority", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The authority (host and port) of the endpoint 
URI, which the component sets from the URI. Consumers with the same aut [...]
-    "bridgeErrorHandler": { "index": 6, "kind": "property", "displayName": 
"Bridge Error Handler", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Allows for bridging the consumer to the Camel routing Error Handler, which 
mean any exceptions (if possible) occurred while the Camel consumer is trying 
to pickup incoming messages, or the like [...]
+    "uriAuthority": { "index": 4, "kind": "property", "displayName": "Uri 
Authority", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": true, 
"deprecationNote": "Not used; the host and port of the endpoint URI are used 
instead", "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Deprecated: not used. The compo [...]
+    "bridgeErrorHandler": { "index": 5, "kind": "property", "displayName": 
"Bridge Error Handler", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, "description": 
"Allows for bridging the consumer to the Camel routing Error Handler, which 
mean any exceptions (if possible) occurred while the Camel consumer is trying 
to pickup incoming messages, or the like [...]
+    "singleParameter": { "index": 6, "kind": "property", "displayName": 
"Single Parameter", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, 
"configurationClass": "org.apache.camel.component.avro.AvroConfiguration", 
"configurationField": "configuration", "description": "Whether the consumer 
sets the message body to the one parameter of the called message, [...]
     "lazyStartProducer": { "index": 7, "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 [...]
     "autowiredEnabled": { "index": 8, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
     "configuration": { "index": 9, "kind": "property", "displayName": 
"Configuration", "group": "advanced", "label": "advanced", "required": false, 
"type": "object", "javaType": 
"org.apache.camel.component.avro.AvroConfiguration", "deprecated": false, 
"autowired": false, "secret": false, "description": "A shared configuration 
that every endpoint copies as its starting point. The options of the endpoint 
URI override its values." },
@@ -52,10 +52,10 @@
     "messageName": { "index": 3, "kind": "path", "displayName": "Message 
Name", "group": "common", "label": "", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The name of the protocol message to call or 
serve. The producer calls it unless the CamelAvroMessageName header is set. A c 
[...]
     "protocol": { "index": 4, "kind": "parameter", "displayName": "Protocol", 
"group": "common", "label": "", "required": false, "type": "object", 
"javaType": "org.apache.avro.Protocol", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The Avro protocol (org.apache.avro.Protocol) 
that defines the messages, such as the PROTOCOL field of a class generat [...]
     "protocolClassName": { "index": 5, "kind": "parameter", "displayName": 
"Protocol Class Name", "group": "common", "label": "", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The fully qualified name of the class that 
defines the protocol. For a class generated by the Avro compil [...]
-    "protocolLocation": { "index": 6, "kind": "parameter", "displayName": 
"Protocol Location", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Not used: the component does not read this 
option. Use protocol or protocolClassName instead." },
+    "protocolLocation": { "index": 6, "kind": "parameter", "displayName": 
"Protocol Location", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The location of an Avro protocol file in JSON 
(.avpr), such as classpath:my-protocol.avpr or file:\/path\/my [...]
     "reflectionProtocol": { "index": 7, "kind": "parameter", "displayName": 
"Reflection Protocol", "group": "common", "label": "", "required": false, 
"type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 
false, "secret": false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Whether the protocol is a reflect protocol, 
built by Avro reflection from a Java interfac [...]
-    "singleParameter": { "index": 8, "kind": "parameter", "displayName": 
"Single Parameter", "group": "common", "label": "", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Whether the consumer sets the message body to 
the one parameter of the called message, instead  [...]
-    "uriAuthority": { "index": 9, "kind": "parameter", "displayName": "Uri 
Authority", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "The authority (host and port) of the endpoint 
URI, which the component sets from the URI. Consumers with the same au [...]
+    "uriAuthority": { "index": 8, "kind": "parameter", "displayName": "Uri 
Authority", "group": "common", "label": "", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": true, 
"deprecationNote": "Not used; the host and port of the endpoint URI are used 
instead", "autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.avro.AvroConfiguration", "configurationField": 
"configuration", "description": "Deprecated: not used. The comp [...]
+    "singleParameter": { "index": 9, "kind": "parameter", "displayName": 
"Single Parameter", "group": "consumer", "label": "consumer", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": false, 
"configurationClass": "org.apache.camel.component.avro.AvroConfiguration", 
"configurationField": "configuration", "description": "Whether the consumer 
sets the message body to the one parameter of the called message [...]
     "bridgeErrorHandler": { "index": 10, "kind": "parameter", "displayName": 
"Bridge Error Handler", "group": "consumer (advanced)", "label": 
"consumer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Allows for bridging the consumer to the 
Camel routing Error Handler, which mean any exceptions (if possible) occurred 
while the Camel consumer is trying to pickup incoming [...]
     "exceptionHandler": { "index": 11, "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 de [...]
     "exchangePattern": { "index": 12, "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." },
diff --git 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/docs/avro-component.adoc
 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/docs/avro-component.adoc
index c186f9b588b4..270d8586bf35 100644
--- 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/docs/avro-component.adoc
+++ 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/docs/avro-component.adoc
@@ -131,6 +131,13 @@ same socket. Dispatching to the correct route will be done 
by the avro
 component automatically. Route with no messageName specified (if any)
 will be used as default.
 
+The consumers on the same host and port share one Avro server, which the first 
consumer that starts creates with its
+transport, protocol and `reflectionProtocol`. A consumer on the same host and 
port with another transport, another
+protocol or another `reflectionProtocol` value fails to start; use another 
port for it.
+
+The exchange pattern of a consumer follows the called message: `InOnly` for a 
message with a `null` response, else
+`InOut`. The `exchangePattern` option has no effect on the consumer.
+
 When using camel producers for avro ipc, the "in" message body needs to
 contain the parameters of the operation specified in the avro protocol.
 The response will be added in the body of the "out" message.
@@ -145,10 +152,26 @@ got only one parameter, *since 2.12* you can use 
`singleParameter` URI
 option to receive it directly in the "in" message body without array
 wrapping.
 
+=== The protocol
+
+The endpoint needs the Avro protocol, from one of these options, in this order:
+
+* `protocol`: an `org.apache.avro.Protocol` instance, such as the `PROTOCOL` 
field of a class that the Avro compiler
+  generated.
+* `protocolClassName`: the class of the protocol. For a class generated by the 
Avro compiler its `PROTOCOL` field is
+  used; for any other class or interface, Avro reflection builds the protocol, 
and `reflectionProtocol` is turned on.
+* `protocolLocation`: an Avro protocol file in JSON (`.avpr`), such as 
`classpath:key-value.avpr`. Records of the
+  protocol use the classes that the Avro compiler generated when they are on 
the classpath. An Avro IDL file
+  (`.avdl`) is not supported: convert it to `.avpr` with the Avro tools first.
+
+----
+avro:netty:localhost:9000/get?protocolLocation=classpath:key-value.avpr
+----
+
 === Trusted packages apply to the whole JVM
 
 Avro validates the classes it loads for a schema, and only loads classes from 
trusted packages. Camel adds the
-packages of the `protocol` or `protocolClassName` option, and the packages of 
the `serializablePackages` option, to
+packages of the `protocol`, `protocolClassName` or `protocolLocation` option, 
and the packages of the `serializablePackages` option, to
 these trusted packages.
 
 Avro has one class validator for the whole JVM. So a package trusted by one 
endpoint is trusted for all Avro class
diff --git 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroComponent.java
 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroComponent.java
index b606d4c370d3..b946075f2924 100644
--- 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroComponent.java
+++ 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroComponent.java
@@ -89,16 +89,18 @@ public class AvroComponent extends DefaultComponent {
      * Registers new responder with uri as a key. Registers consumer in 
responder. In case if responder is already
      * registered by this uri, then register consumer.
      *
-     * @param  uri         URI of the endpoint without message name
+     * @param  uri         host and port of the endpoint
      * @param  messageName message name
      * @param  consumer    consumer that will be registered in providers` 
registry
      * @throws Exception
      */
-    public void register(String uri, String messageName, AvroConsumer 
consumer) throws Exception {
+    public synchronized void register(String uri, String messageName, 
AvroConsumer consumer) throws Exception {
         AvroListener listener = listenerRegistry.get(uri);
         if (listener == null) {
             listener = new AvroListener(consumer.getEndpoint());
             listenerRegistry.put(uri, listener);
+        } else {
+            listener.checkCompatible(consumer.getEndpoint());
         }
         listener.register(messageName, consumer);
     }
@@ -107,11 +109,13 @@ public class AvroComponent extends DefaultComponent {
      * Calls unregister of consumer by the appropriate message name. In case 
if all consumers are unregistered, then it
      * removes responder from the registry.
      *
-     * @param uri         URI of the endpoint without message name
+     * @param uri         host and port of the endpoint
      * @param messageName message name
+     * @param consumer    the consumer to unregister
      */
-    public void unregister(String uri, String messageName) {
-        if (listenerRegistry.get(uri).unregister(messageName)) {
+    public synchronized void unregister(String uri, String messageName, 
AvroConsumer consumer) {
+        AvroListener listener = listenerRegistry.get(uri);
+        if (listener != null && listener.unregister(messageName, consumer)) {
             listenerRegistry.remove(uri);
         }
     }
diff --git 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
index c83994860aed..5fcca08fa79c 100644
--- 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
+++ 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
@@ -45,7 +45,11 @@ public class AvroConfiguration implements Cloneable {
                            + " CamelAvroMessageName header is set. A consumer 
with a message name serves only that message; a"
                            + " consumer without one serves every message that 
no other consumer on the same host and port serves.")
     private String messageName;
-    @UriParam(description = "Not used: the component does not read this 
option. Use protocol or protocolClassName instead.")
+    @UriParam(description = "The location of an Avro protocol file in JSON 
(.avpr), such as classpath:my-protocol.avpr or"
+                            + " file:/path/my-protocol.avpr. Used when neither 
protocol nor protocolClassName is set. Records of"
+                            + " the protocol use the classes generated by the 
Avro compiler when they are on the classpath."
+                            + " Camel adds the packages of the protocol to the 
trusted packages of Avro, which apply to the whole"
+                            + " JVM: see serializablePackages.")
     private String protocolLocation;
     @UriParam(description = "The Avro protocol (org.apache.avro.Protocol) that 
defines the messages, such as the PROTOCOL field"
                             + " of a class generated by the Avro compiler. Set 
this option or protocolClassName: the endpoint"
@@ -58,16 +62,18 @@ public class AvroConfiguration implements Cloneable {
                             + " Camel adds the package of the class to the 
trusted packages of Avro, which apply to the whole"
                             + " JVM: see serializablePackages.")
     private String protocolClassName;
-    @UriParam(description = "The authority (host and port) of the endpoint 
URI, which the component sets from the URI."
-                            + " Consumers with the same authority share one 
Avro server, created with the protocol of the first"
-                            + " consumer that starts. A value set on the 
component is replaced by the authority of the endpoint URI.")
+    @UriParam(description = "Deprecated: not used. The component sets it to 
the host and port of the endpoint URI, and a"
+                            + " value set on the endpoint or the component has 
no effect.")
+    @Metadata(deprecationNote = "Not used; the host and port of the endpoint 
URI are used instead")
+    @Deprecated(since = "4.24")
     private String uriAuthority;
     @UriParam(description = "Whether the protocol is a reflect protocol, built 
by Avro reflection from a Java interface, rather"
                             + " than one from classes generated by the Avro 
compiler. When true, the consumer and producer use the"
                             + " Avro reflect responder and requestor. Set it 
together with protocol: with protocolClassName it is"
                             + " turned on for a class without a PROTOCOL 
field.")
     private boolean reflectionProtocol;
-    @UriParam(description = "Whether the consumer sets the message body to the 
one parameter of the called message, instead of"
+    @UriParam(label = "consumer",
+              description = "Whether the consumer sets the message body to the 
one parameter of the called message, instead of"
                             + " an Object array of all parameters. The 
endpoint fails to start if the message, or any message of"
                             + " the protocol when messageName is not set, does 
not have exactly one parameter.")
     private boolean singleParameter;
@@ -98,7 +104,14 @@ public class AvroConfiguration implements Cloneable {
             }
         }
 
-        setUriAuthority(uri.getAuthority());
+        this.uriAuthority = uri.getAuthority();
+    }
+
+    /**
+     * The key of the Avro server that the consumers of this host and port 
share.
+     */
+    String getListenerKey() {
+        return host + ":" + port;
     }
 
     public String getHost() {
@@ -161,10 +174,12 @@ public class AvroConfiguration implements Cloneable {
         this.messageName = messageName;
     }
 
+    @Deprecated(since = "4.24")
     public String getUriAuthority() {
         return uriAuthority;
     }
 
+    @Deprecated(since = "4.24")
     public void setUriAuthority(String uriAuthority) {
         this.uriAuthority = uriAuthority;
     }
diff --git 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
index 32a26611fa5f..3c4bd6b0c8d3 100644
--- 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
+++ 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
@@ -31,17 +31,26 @@ public class AvroConsumer extends DefaultConsumer {
         return (AvroEndpoint) super.getEndpoint();
     }
 
+    private volatile boolean registered;
+
     @Override
     protected void doStart() throws Exception {
         super.doStart();
-        ((AvroComponent) 
getEndpoint().getComponent()).register(getEndpoint().getConfiguration()
-                .getUriAuthority(), 
getEndpoint().getConfiguration().getMessageName(), this);
+        AvroConfiguration configuration = getEndpoint().getConfiguration();
+        ((AvroComponent) 
getEndpoint().getComponent()).register(configuration.getListenerKey(),
+                configuration.getMessageName(), this);
+        registered = true;
     }
 
     @Override
     protected void doStop() throws Exception {
-        ((AvroComponent) 
getEndpoint().getComponent()).unregister(getEndpoint().getConfiguration().getUriAuthority(),
-                getEndpoint().getConfiguration().getMessageName());
+        // a consumer that failed to register must not unregister the consumer 
that holds its message name
+        if (registered) {
+            registered = false;
+            AvroConfiguration configuration = getEndpoint().getConfiguration();
+            ((AvroComponent) 
getEndpoint().getComponent()).unregister(configuration.getListenerKey(),
+                    configuration.getMessageName(), this);
+        }
         super.doStop();
     }
 }
diff --git 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java
 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java
index 8d9128bf2c2d..9da5ee53f6fe 100644
--- 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java
+++ 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.avro;
 
+import java.io.InputStream;
 import java.lang.reflect.Field;
 import java.util.Collections;
 import java.util.Map;
@@ -34,6 +35,7 @@ import org.apache.camel.spi.BodyTypes;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultEndpoint;
+import org.apache.camel.support.ResourceHelper;
 
 /**
  * Call and expose Apache Avro RPC services over HTTP or Netty.
@@ -113,8 +115,16 @@ public abstract class AvroEndpoint extends DefaultEndpoint 
implements AsyncEndpo
             }
         }
 
+        if (config.getProtocol() == null && config.getProtocolLocation() != 
null) {
+            try (InputStream is = 
ResourceHelper.resolveMandatoryResourceAsInputStream(getCamelContext(),
+                    config.getProtocolLocation())) {
+                config.setProtocol(Protocol.parse(is));
+            }
+        }
+
         if (config.getProtocol() == null) {
-            throw new IllegalArgumentException("Avro configuration does not 
contain protocol");
+            throw new IllegalArgumentException(
+                    "Avro configuration does not contain protocol: set 
protocol, protocolClassName or protocolLocation");
         }
 
         configureClassSecurity(config);
diff --git 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroListener.java
 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroListener.java
index 24380e08d1d8..444fdbaeaa00 100644
--- 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroListener.java
+++ 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/main/java/org/apache/camel/component/avro/AvroListener.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.avro;
 
 import java.net.InetSocketAddress;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -50,9 +51,50 @@ public class AvroListener {
     private final ConcurrentMap<String, AvroConsumer> consumerRegistry = new 
ConcurrentHashMap<>();
     private AvroConsumer defaultConsumer;
     private final Server server;
+    private final AvroTransport transport;
+    private final Protocol protocol;
+    private final boolean reflectionProtocol;
+    private final String endpointUri;
 
     public AvroListener(AvroEndpoint endpoint) throws Exception {
-        server = initAndStartServer(endpoint.getConfiguration(), 
endpoint.getCamelContext());
+        AvroConfiguration configuration = endpoint.getConfiguration();
+        this.transport = configuration.getTransport();
+        this.protocol = configuration.getProtocol();
+        this.reflectionProtocol = configuration.isReflectionProtocol();
+        this.endpointUri = endpoint.getEndpointUri();
+        server = initAndStartServer(configuration, endpoint.getCamelContext());
+    }
+
+    /**
+     * Checks that a consumer of the endpoint can share the server of this 
listener: the server serves only the
+     * transport, protocol and responder type of the consumer that created it.
+     *
+     * @param  endpoint               the endpoint of the consumer that joins 
this listener
+     * @throws AvroComponentException when the transport, the protocol or 
reflectionProtocol differs
+     */
+    public void checkCompatible(AvroEndpoint endpoint) throws 
AvroComponentException {
+        AvroConfiguration configuration = endpoint.getConfiguration();
+        String reason = null;
+        if (transport != configuration.getTransport()) {
+            reason = "the transport " + configuration.getTransport() + " 
differs from " + transport;
+        } else if (reflectionProtocol != configuration.isReflectionProtocol()) 
{
+            reason = "reflectionProtocol=" + 
configuration.isReflectionProtocol() + " differs from reflectionProtocol="
+                     + reflectionProtocol;
+        } else if (!Objects.equals(protocol, configuration.getProtocol())) {
+            reason = "the protocol " + 
protocolName(configuration.getProtocol()) + " differs from "
+                     + protocolName(protocol);
+        }
+        if (reason != null) {
+            throw new AvroComponentException(
+                    "Consumer " + endpoint.getEndpointUri() + " cannot share 
the Avro server on " + configuration.getHost()
+                                             + ":" + configuration.getPort() + 
" with " + endpointUri + ": " + reason
+                                             + ". Consumers on the same host 
and port must use the same transport,"
+                                             + " protocol and 
reflectionProtocol.");
+        }
+    }
+
+    private static String protocolName(Protocol protocol) {
+        return protocol != null ? protocol.getNamespace() + "." + 
protocol.getName() : "null";
     }
 
     /**
@@ -123,12 +165,12 @@ public class AvroListener {
      * @return             true if all consumers are unregistered and 
defaultConsumer is absent or null. It means that
      *                     this responder can be unregistered.
      */
-    public boolean unregister(String messageName) {
+    public boolean unregister(String messageName, AvroConsumer consumer) {
         if (!StringUtils.isEmpty(messageName)) {
-            if (consumerRegistry.remove(messageName) == null) {
+            if (!consumerRegistry.remove(messageName, consumer)) {
                 LOGGER.warn("Consumer with message name {} was already 
unregistered.", messageName);
             }
-        } else {
+        } else if (defaultConsumer == consumer) {
             defaultConsumer = null;
         }
 
diff --git 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroConsumerSharedServerTest.java
 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroConsumerSharedServerTest.java
new file mode 100644
index 000000000000..7398a9778ae8
--- /dev/null
+++ 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroConsumerSharedServerTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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.avro;
+
+import org.apache.avro.Protocol;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.avro.generated.Key;
+import org.apache.camel.avro.generated.Value;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.ObjectHelper;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Consumers on the same host and port share one Avro server, which serves the 
transport, protocol and responder type of
+ * the first consumer. A consumer that does not match fails to start, and does 
not break the consumer that serves.
+ */
+public class AvroConsumerSharedServerTest extends AvroTestSupport {
+
+    private static final String KEY_VALUE = 
"protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol";
+
+    @BindToRegistry("otherProtocol")
+    private final Protocol otherProtocol = Protocol.parse(
+            "{\"namespace\": \"org.example.other\", \"protocol\": 
\"OtherProtocol\", \"types\": [],"
+                                                          + " \"messages\": 
{\"ping\": {\"request\": [], \"response\": \"string\"}}}");
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("avro:netty:localhost:" + avroPort + "?" + 
KEY_VALUE).routeId("default")
+                        .process(e -> 
e.getMessage().setBody(value("default")));
+
+                from("direct:get").to("avro:netty:localhost:" + avroPort + 
"/get?" + KEY_VALUE);
+
+                from("avro:netty:localhost:" + avroPortReflection + 
"/get?protocolLocation=file:src/test/avro/test.avpr")
+                        .process(e -> {
+                            Object[] params = 
e.getIn().getBody(Object[].class);
+                            e.getMessage().setBody(value("location-" + ((Key) 
params[0]).getKey()));
+                        });
+
+                from("direct:getLocation")
+                        .to("avro:netty:localhost:" + avroPortReflection
+                            + 
"/get?protocolLocation=file:src/test/avro/test.avpr");
+            }
+        };
+    }
+
+    // the Avro Netty server takes a few seconds to close, so each test method 
checks several cases
+
+    @Test
+    public void consumersThatCannotShareTheServerFailAndTheFirstStillServes() {
+        // the same host and port written as netty://, so Camel does not see 
the same endpoint URI
+        assertConsumerFailsToStart("avro:netty://localhost:" + avroPort + "?" 
+ KEY_VALUE,
+                "Default consumer already registered");
+        assertServes();
+
+        // a default consumer: when it fails, it must not unregister the 
default consumer of the netty server
+        assertConsumerFailsToStart("avro:http:localhost:" + avroPort + "?" + 
KEY_VALUE, "the transport http differs");
+        assertServes();
+
+        assertConsumerFailsToStart("avro:netty:localhost:" + avroPort + 
"/ping?protocol=#otherProtocol",
+                "the protocol org.example.other.OtherProtocol differs");
+        assertServes();
+
+        assertConsumerFailsToStart("avro:netty:localhost:" + avroPort + 
"/put?" + KEY_VALUE + "&reflectionProtocol=true",
+                "reflectionProtocol=true differs");
+        assertServes();
+    }
+
+    @Test
+    public void protocolLocation() {
+        Value value = template.requestBody("direct:getLocation", key("k1"), 
Value.class);
+        assertEquals("location-k1", value.getValue().toString());
+
+        Exception e = assertThrows(Exception.class, () -> 
context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:missing")
+                        .to("avro:netty:localhost:" + avroPort + 
"/get?protocolLocation=file:target/missing.avpr");
+            }
+        }));
+        assertTrue(e.getMessage().contains("missing.avpr"), e.getMessage());
+    }
+
+    private void assertServes() {
+        Value value = template.requestBody("direct:get", key("k1"), 
Value.class);
+        assertEquals("default", value.getValue().toString());
+    }
+
+    private void assertConsumerFailsToStart(String uri, String reason) {
+        Exception e = assertThrows(Exception.class, () -> 
context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from(uri).routeId("second").to("log:second");
+            }
+        }));
+        AvroComponentException cause = 
ObjectHelper.getException(AvroComponentException.class, e);
+        assertNotNull(cause, "AvroComponentException expected as cause of " + 
e);
+        assertTrue(cause.getMessage().contains(reason), cause.getMessage());
+    }
+
+    private static Key key(String key) {
+        return Key.newBuilder().setKey(key).build();
+    }
+
+    private static Value value(String value) {
+        return Value.newBuilder().setValue(value).build();
+    }
+}
diff --git 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroNettyConsumerTest.java
 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroNettyConsumerTest.java
index 6a083b1c8703..3dc4ae42e0e9 100644
--- 
a/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroNettyConsumerTest.java
+++ 
b/components/camel-avro-rpc/camel-avro-rpc-component/src/test/java/org/apache/camel/component/avro/AvroNettyConsumerTest.java
@@ -99,11 +99,11 @@ public class AvroNettyConsumerTest extends 
AvroConsumerTestSupport {
                              + 
"/setAge?protocolClassName=org.apache.camel.avro.test.TestReflection")
                                 .process(new 
ReflectionInOnlyProcessor(testReflection));
 
-                        from("avro:http:localhost:" + avroPortReflection
+                        from("avro:netty:localhost:" + avroPortReflection
                              + 
"/setTestPojo?protocolClassName=org.apache.camel.avro.test.TestReflection&singleParameter=true")
                                 .process(new 
ReflectionInOnlyProcessor(testReflection));
 
-                        from("avro:http:localhost:" + avroPortReflection
+                        from("avro:netty:localhost:" + avroPortReflection
                              + 
"/increaseAge?protocolClassName=org.apache.camel.avro.test.TestReflection&singleParameter=true")
                                 .process(new 
ReflectionInOutProcessor(testReflection));
 
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 17af91664876..44aff5091578 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
@@ -12664,6 +12664,18 @@ ignored without a message. An endpoint with 
`sslContextParameters`, or with `use
 global `SSLContextParameters`, now fails to start. Remove the option, and 
configure the trust store (and the key store
 for a client certificate) with the `javax.net.ssl.*` system properties of the 
JVM.
 
+=== camel-avro-rpc - consumers on the same host and port must match, 
protocolLocation is read, uriAuthority is deprecated
+
+The consumers on the same host and port share one Avro server, which the first 
consumer that starts creates with its
+transport, protocol and `reflectionProtocol`. Before, a later consumer with 
another transport, protocol or
+`reflectionProtocol` value was added to that server and then served with the 
wrong protocol or responder, or not at
+all. Such a consumer now fails to start; give it its own port.
+
+The `protocolLocation` option, which had no effect, now loads the protocol 
from an Avro protocol file in JSON
+(`.avpr`). It is used when neither `protocol` nor `protocolClassName` is set.
+
+The `uriAuthority` option is deprecated. It never had an effect, as the 
component always set it from the endpoint URI.
+
 === Kamelets - removed Kamelets
 
 The Kamelet catalog (camel-kamelets 4.24) removes Kamelets that could not work 
on Camel 4.23 or 4.24:
diff --git 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AvroComponentBuilderFactory.java
 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AvroComponentBuilderFactory.java
index f7e13ae39624..203ea5ec8709 100644
--- 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AvroComponentBuilderFactory.java
+++ 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AvroComponentBuilderFactory.java
@@ -92,8 +92,13 @@ public interface AvroComponentBuilderFactory {
         }
     
         /**
-         * Not used: the component does not read this option. Use protocol or
-         * protocolClassName instead.
+         * The location of an Avro protocol file in JSON (.avpr), such as
+         * classpath:my-protocol.avpr or file:/path/my-protocol.avpr. Used when
+         * neither protocol nor protocolClassName is set. Records of the
+         * protocol use the classes generated by the Avro compiler when they 
are
+         * on the classpath. Camel adds the packages of the protocol to the
+         * trusted packages of Avro, which apply to the whole JVM: see
+         * serializablePackages.
          * 
          * The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
          * 
@@ -129,33 +134,11 @@ public interface AvroComponentBuilderFactory {
             return this;
         }
     
-        
         /**
-         * Whether the consumer sets the message body to the one parameter of
-         * the called message, instead of an Object array of all parameters. 
The
-         * endpoint fails to start if the message, or any message of the
-         * protocol when messageName is not set, does not have exactly one
-         * parameter.
-         * 
-         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
-         * 
-         * Default: false
-         * Group: common
-         * 
-         * @param singleParameter the value to set
-         * @return the dsl builder
-         */
-        default AvroComponentBuilder singleParameter(boolean singleParameter) {
-            doSetProperty("singleParameter", singleParameter);
-            return this;
-        }
-    
-        /**
-         * The authority (host and port) of the endpoint URI, which the
-         * component sets from the URI. Consumers with the same authority share
-         * one Avro server, created with the protocol of the first consumer 
that
-         * starts. A value set on the component is replaced by the authority of
-         * the endpoint URI.
+         * Deprecated: not used. The component sets it to the host and port of
+         * the endpoint URI, and a value set on the endpoint or the component
+         * has no effect. Deprecation note: Not used; the host and port of the
+         * endpoint URI are used instead.
          * 
          * The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
          * 
@@ -164,6 +147,7 @@ public interface AvroComponentBuilderFactory {
          * @param uriAuthority the value to set
          * @return the dsl builder
          */
+        @Deprecated
         default AvroComponentBuilder uriAuthority(java.lang.String 
uriAuthority) {
             doSetProperty("uriAuthority", uriAuthority);
             return this;
@@ -198,6 +182,27 @@ public interface AvroComponentBuilderFactory {
         }
     
         
+        /**
+         * Whether the consumer sets the message body to the one parameter of
+         * the called message, instead of an Object array of all parameters. 
The
+         * endpoint fails to start if the message, or any message of the
+         * protocol when messageName is not set, does not have exactly one
+         * parameter.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: false
+         * Group: consumer
+         * 
+         * @param singleParameter the value to set
+         * @return the dsl builder
+         */
+        default AvroComponentBuilder singleParameter(boolean singleParameter) {
+            doSetProperty("singleParameter", singleParameter);
+            return this;
+        }
+    
+        
         /**
          * Whether the producer should be started lazy (on the first message).
          * By starting lazy you can use this to allow CamelContext and routes 
to
@@ -309,9 +314,9 @@ public interface AvroComponentBuilderFactory {
             case "protocolClassName": getOrCreateConfiguration((AvroComponent) 
component).setProtocolClassName((java.lang.String) value); return true;
             case "protocolLocation": getOrCreateConfiguration((AvroComponent) 
component).setProtocolLocation((java.lang.String) value); return true;
             case "reflectionProtocol": 
getOrCreateConfiguration((AvroComponent) 
component).setReflectionProtocol((boolean) value); return true;
-            case "singleParameter": getOrCreateConfiguration((AvroComponent) 
component).setSingleParameter((boolean) value); return true;
             case "uriAuthority": getOrCreateConfiguration((AvroComponent) 
component).setUriAuthority((java.lang.String) value); return true;
             case "bridgeErrorHandler": ((AvroComponent) 
component).setBridgeErrorHandler((boolean) value); return true;
+            case "singleParameter": getOrCreateConfiguration((AvroComponent) 
component).setSingleParameter((boolean) value); return true;
             case "lazyStartProducer": ((AvroComponent) 
component).setLazyStartProducer((boolean) value); return true;
             case "autowiredEnabled": ((AvroComponent) 
component).setAutowiredEnabled((boolean) value); return true;
             case "configuration": ((AvroComponent) 
component).setConfiguration((org.apache.camel.component.avro.AvroConfiguration) 
value); return true;
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AvroEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AvroEndpointBuilderFactory.java
index c1252c22f5a2..a4ac0f978def 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AvroEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/AvroEndpointBuilderFactory.java
@@ -102,8 +102,13 @@ public interface AvroEndpointBuilderFactory {
             return this;
         }
         /**
-         * Not used: the component does not read this option. Use protocol or
-         * protocolClassName instead.
+         * The location of an Avro protocol file in JSON (.avpr), such as
+         * classpath:my-protocol.avpr or file:/path/my-protocol.avpr. Used when
+         * neither protocol nor protocolClassName is set. Records of the
+         * protocol use the classes generated by the Avro compiler when they 
are
+         * on the classpath. Camel adds the packages of the protocol to the
+         * trusted packages of Avro, which apply to the whole JVM: see
+         * serializablePackages.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -156,6 +161,24 @@ public interface AvroEndpointBuilderFactory {
             doSetProperty("reflectionProtocol", reflectionProtocol);
             return this;
         }
+        /**
+         * Deprecated: not used. The component sets it to the host and port of
+         * the endpoint URI, and a value set on the endpoint or the component
+         * has no effect. Deprecation note: Not used; the host and port of the
+         * endpoint URI are used instead.
+         * 
+         * The option is a: <code>java.lang.String</code> type.
+         * 
+         * Group: common
+         * 
+         * @param uriAuthority the value to set
+         * @return the dsl builder
+         */
+        @Deprecated
+        default AvroEndpointConsumerBuilder uriAuthority(String uriAuthority) {
+            doSetProperty("uriAuthority", uriAuthority);
+            return this;
+        }
         /**
          * Whether the consumer sets the message body to the one parameter of
          * the called message, instead of an Object array of all parameters. 
The
@@ -166,7 +189,7 @@ public interface AvroEndpointBuilderFactory {
          * The option is a: <code>boolean</code> type.
          * 
          * Default: false
-         * Group: common
+         * Group: consumer
          * 
          * @param singleParameter the value to set
          * @return the dsl builder
@@ -185,7 +208,7 @@ public interface AvroEndpointBuilderFactory {
          * The option will be converted to a <code>boolean</code> type.
          * 
          * Default: false
-         * Group: common
+         * Group: consumer
          * 
          * @param singleParameter the value to set
          * @return the dsl builder
@@ -194,24 +217,6 @@ public interface AvroEndpointBuilderFactory {
             doSetProperty("singleParameter", singleParameter);
             return this;
         }
-        /**
-         * The authority (host and port) of the endpoint URI, which the
-         * component sets from the URI. Consumers with the same authority share
-         * one Avro server, created with the protocol of the first consumer 
that
-         * starts. A value set on the component is replaced by the authority of
-         * the endpoint URI.
-         * 
-         * The option is a: <code>java.lang.String</code> type.
-         * 
-         * Group: common
-         * 
-         * @param uriAuthority the value to set
-         * @return the dsl builder
-         */
-        default AvroEndpointConsumerBuilder uriAuthority(String uriAuthority) {
-            doSetProperty("uriAuthority", uriAuthority);
-            return this;
-        }
         /**
          * Comma-separated list of additional packages that contain trusted 
Avro
          * model classes. Avro 1.12+ validates classes resolved from schemas;
@@ -434,8 +439,13 @@ public interface AvroEndpointBuilderFactory {
             return this;
         }
         /**
-         * Not used: the component does not read this option. Use protocol or
-         * protocolClassName instead.
+         * The location of an Avro protocol file in JSON (.avpr), such as
+         * classpath:my-protocol.avpr or file:/path/my-protocol.avpr. Used when
+         * neither protocol nor protocolClassName is set. Records of the
+         * protocol use the classes generated by the Avro compiler when they 
are
+         * on the classpath. Camel adds the packages of the protocol to the
+         * trusted packages of Avro, which apply to the whole JVM: see
+         * serializablePackages.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -489,49 +499,10 @@ public interface AvroEndpointBuilderFactory {
             return this;
         }
         /**
-         * Whether the consumer sets the message body to the one parameter of
-         * the called message, instead of an Object array of all parameters. 
The
-         * endpoint fails to start if the message, or any message of the
-         * protocol when messageName is not set, does not have exactly one
-         * parameter.
-         * 
-         * The option is a: <code>boolean</code> type.
-         * 
-         * Default: false
-         * Group: common
-         * 
-         * @param singleParameter the value to set
-         * @return the dsl builder
-         */
-        default AvroEndpointProducerBuilder singleParameter(boolean 
singleParameter) {
-            doSetProperty("singleParameter", singleParameter);
-            return this;
-        }
-        /**
-         * Whether the consumer sets the message body to the one parameter of
-         * the called message, instead of an Object array of all parameters. 
The
-         * endpoint fails to start if the message, or any message of the
-         * protocol when messageName is not set, does not have exactly one
-         * parameter.
-         * 
-         * The option will be converted to a <code>boolean</code> type.
-         * 
-         * Default: false
-         * Group: common
-         * 
-         * @param singleParameter the value to set
-         * @return the dsl builder
-         */
-        default AvroEndpointProducerBuilder singleParameter(String 
singleParameter) {
-            doSetProperty("singleParameter", singleParameter);
-            return this;
-        }
-        /**
-         * The authority (host and port) of the endpoint URI, which the
-         * component sets from the URI. Consumers with the same authority share
-         * one Avro server, created with the protocol of the first consumer 
that
-         * starts. A value set on the component is replaced by the authority of
-         * the endpoint URI.
+         * Deprecated: not used. The component sets it to the host and port of
+         * the endpoint URI, and a value set on the endpoint or the component
+         * has no effect. Deprecation note: Not used; the host and port of the
+         * endpoint URI are used instead.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -540,6 +511,7 @@ public interface AvroEndpointBuilderFactory {
          * @param uriAuthority the value to set
          * @return the dsl builder
          */
+        @Deprecated
         default AvroEndpointProducerBuilder uriAuthority(String uriAuthority) {
             doSetProperty("uriAuthority", uriAuthority);
             return this;
@@ -695,8 +667,13 @@ public interface AvroEndpointBuilderFactory {
             return this;
         }
         /**
-         * Not used: the component does not read this option. Use protocol or
-         * protocolClassName instead.
+         * The location of an Avro protocol file in JSON (.avpr), such as
+         * classpath:my-protocol.avpr or file:/path/my-protocol.avpr. Used when
+         * neither protocol nor protocolClassName is set. Records of the
+         * protocol use the classes generated by the Avro compiler when they 
are
+         * on the classpath. Camel adds the packages of the protocol to the
+         * trusted packages of Avro, which apply to the whole JVM: see
+         * serializablePackages.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -750,49 +727,10 @@ public interface AvroEndpointBuilderFactory {
             return this;
         }
         /**
-         * Whether the consumer sets the message body to the one parameter of
-         * the called message, instead of an Object array of all parameters. 
The
-         * endpoint fails to start if the message, or any message of the
-         * protocol when messageName is not set, does not have exactly one
-         * parameter.
-         * 
-         * The option is a: <code>boolean</code> type.
-         * 
-         * Default: false
-         * Group: common
-         * 
-         * @param singleParameter the value to set
-         * @return the dsl builder
-         */
-        default AvroEndpointBuilder singleParameter(boolean singleParameter) {
-            doSetProperty("singleParameter", singleParameter);
-            return this;
-        }
-        /**
-         * Whether the consumer sets the message body to the one parameter of
-         * the called message, instead of an Object array of all parameters. 
The
-         * endpoint fails to start if the message, or any message of the
-         * protocol when messageName is not set, does not have exactly one
-         * parameter.
-         * 
-         * The option will be converted to a <code>boolean</code> type.
-         * 
-         * Default: false
-         * Group: common
-         * 
-         * @param singleParameter the value to set
-         * @return the dsl builder
-         */
-        default AvroEndpointBuilder singleParameter(String singleParameter) {
-            doSetProperty("singleParameter", singleParameter);
-            return this;
-        }
-        /**
-         * The authority (host and port) of the endpoint URI, which the
-         * component sets from the URI. Consumers with the same authority share
-         * one Avro server, created with the protocol of the first consumer 
that
-         * starts. A value set on the component is replaced by the authority of
-         * the endpoint URI.
+         * Deprecated: not used. The component sets it to the host and port of
+         * the endpoint URI, and a value set on the endpoint or the component
+         * has no effect. Deprecation note: Not used; the host and port of the
+         * endpoint URI are used instead.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -801,6 +739,7 @@ public interface AvroEndpointBuilderFactory {
          * @param uriAuthority the value to set
          * @return the dsl builder
          */
+        @Deprecated
         default AvroEndpointBuilder uriAuthority(String uriAuthority) {
             doSetProperty("uriAuthority", uriAuthority);
             return this;

Reply via email to