Claus Ibsen created CAMEL-27699:
-----------------------------------
Summary: camel-consul: unknown apiEndpoint becomes kv, session
datacenter, event delay, headers
Key: CAMEL-27699
URL: https://issues.apache.org/jira/browse/CAMEL-27699
Project: Camel
Issue Type: Bug
Components: camel-consul
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-consul for CAMEL-23832
(commit
https://github.com/apache/camel/commit/dd17773927055222617087794e09fe6ea9f8bf32).
These are separate problems of the component; the descriptions commit only
documents the current behavior.
h4. 1. An unknown apiEndpoint silently becomes a kv endpoint
{{ConsulComponent.createEndpoint()}} has a {{default}} branch that creates a kv
producer and consumer for any value it does not know. A typo such as
{{consul:kvv}} or {{consul:events}} gives a working kv endpoint, and the user
sees reads and writes on the key/value store instead of an error.
Proposed change: fail with an {{IllegalArgumentException}} that lists the
supported APIs.
h4. 2. The session actions ignore the datacenter option
{{ConsulSessionProducer}} (CREATE, DESTROY, INFO, LIST, RENEW) reads the
datacenter only from the {{CamelConsulDatacenter}} header. The catalog, health
and coordinates actions fall back to the {{datacenter}} option when the header
is not set, so {{consul:session?datacenter=dc2}} still acts on the datacenter
of the agent.
Proposed change: use {{message.getHeader(CONSUL_DATACENTER,
getConfiguration().getDatacenter(), String.class)}} in the session actions.
h4. 3. GET_VALUE and GET_VALUES with valueAsString ignore the
CamelConsulOptions header
{{ConsulKeyValueProducer.getValue()}} and {{getValues()}} call
{{getValueAsString(key)}} / {{getValuesAsString(key)}} when {{valueAsString}}
is true, without the {{QueryOptions}} of the {{CamelConsulOptions}} header that
the other branch passes. Options such as a datacenter or a consistency mode are
lost when the value is read as text.
Proposed change: read the value with the query options and decode it, or use an
overload of the client that takes the options.
h4. 4. The event consumer waits blockSeconds before every query
{{ConsulEventConsumer.EventWatcher.watch()}} schedules each {{listEvents}} call
with a delay of {{blockSeconds}}, on top of the blocking wait of the query
itself. The first query starts only {{blockSeconds}} after the consumer
started, and every round adds that delay before a new event can be returned.
Proposed change: run the next query at once after an answer and keep the delay
only after a failure, as {{ConsulKeyValueConsumer}} does.
h4. 5. The error for a consumer without key names the header
The {{AbstractConsulConsumer}} constructor checks the key with
{{ObjectHelper.notNull(configuration.getKey(), ConsulConstants.CONSUL_KEY)}},
so a kv or event consumer without the {{key}} option fails with "CamelConsulKey
must be specified". The consumer does not read that header; the user must set
the {{key}} option.
Proposed change: name the {{key}} option in the message.
h4. 6. The tags option does nothing
{{ConsulClientConfiguration}} has a {{tags}} option, but {{getTags()}} and
{{getTagAsSet()}} have no callers. Setting it has no effect.
Proposed change: deprecate the option (with an upgrade guide entry), or remove
it.
h4. 7. The header CamelConsulSessionFilter holds the service filter
The constant {{ConsulConstants.CONSUL_SERVICE_FILTER}} has the value
{{CamelConsulSessionFilter}}, and {{ConsulEventConsumer}} sets it to
{{Event.getServiceFilter()}}. The header name says session, the content is the
service filter of the event.
Proposed change: add a {{CamelConsulServiceFilter}} header and deprecate the
old name (with an upgrade guide entry), following design/headers.adoc.
h4. 8. The CamelConsulOptions header has no javaType and no label
Only the producer reads {{CamelConsulOptions}} (a {{PutOptions}},
{{QueryOptions}} or {{EventOptions}} depending on the action), but its
{{@Metadata}} has no {{label = "producer"}} and no {{javaType}}.
Proposed change: add {{label = "producer"}} and {{javaType = "Object"}} (or the
common option type).
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)