davsclaus opened a new pull request, #28309:
URL: https://github.com/apache/camel/pull/28309
Stacked on #28306. This group covers seven more of the most used components
of the catalog body types (CAMEL-24961): spring-redis, couchbase, fhir, solr,
ssh, slack and telegram. fhir is the first API component with body types.
**What the catalog says now**
| Component | Consumer | Producer input | Producer output |
|---|---|---|---|
| spring-redis | `unknown`: the message as the serializer reads it | `any`:
the arguments come from headers | `unchanged` for SET, the default, and the
result of 39 other commands (a Boolean, a Long, text, a Map, a Set or a List);
not known for the rest |
| couchbase | the `GetResult` of the SDK; the row as JSON text with
fullDocument=false | text, a Map, a List or a POJO, stored as JSON | `true` for
CCB_PUT; not known for another operation |
| fhir | the result of the method, a HAPI FHIR object | `any`: only used
with inBody | the result of the method: a HAPI FHIR object, or text or a List
for transaction |
| solr | | `any`; text or a List for DELETE | the response of Solr as a
`map` |
| ssh | the output as a `stream` | `text`, `bytes`, `stream` or `file`: the
command | the output as a `stream` |
| slack | a `com.slack.api.model.Message` | text, bytes, a stream, a file or
a Message | `unchanged` |
| telegram | an `IncomingMessage` or another update object; no body for
other updates | text, bytes with a media type header, a stream, a file, a model
message, or no body | the `MessageResult`, or `unchanged` with no body |
**Checked at runtime.** Routes run with `camel run` logged the class of the
body after each step:
- spring-redis, solr and fhir against `camel infra run redis`, `solr` and
`fhir`;
- couchbase against `camel infra run couchbase`, with the arm64 image of
Couchbase 8.0.3;
- ssh against an embedded Apache MINA SSHD server in a bean;
- slack and telegram against fake APIs served by platform-http routes in a
second `camel run`.
What the runs showed:
- **spring-redis:**
- the body is never read;
- after a command the body is its result only when the result is not null,
so SET and PUBLISH keep the body, and so does GET of a missing key;
- the subscriber gets the Java object the publisher serialized;
- a message published by redis-cli cannot be deserialized and is dropped
with a WARN.
- **couchbase:**
- a Map, a List or a POJO is stored as JSON, and text as a JSON string;
- bytes, a stream and no body fail;
- the consumer gives the `GetResult`, or the row as JSON text with
fullDocument=false.
- **fhir:**
- the producer passes the body to the inBody parameter as it is, so a byte
array or a stream fails with "argument type mismatch";
- the result is the HAPI FHIR object of the method, text for transaction
with stringBundle, and a List with withResources.
- **solr:**
- every operation gives the response as a `SimpleOrderedMap`, which is a
Map;
- INSERT stores Maps, SolrInputDocuments, @Field beans, JSON arrays, XML
and .csv or .json files.
- **ssh:**
- the body is the command, read as text;
- the output is a stream, with the exit value and the error output in
headers;
- an exit value that is not 0 does not fail the exchange.
- **slack:**
- text, bytes, a stream and a file are sent as text, and a Map as its
toString();
- the body is unchanged after both the token mode and the webhook mode.
- **telegram:**
- text, a stream and a file are sent as a text message;
- a byte array needs CamelTelegramMediaType;
- the result is a `MessageResult`;
- no body sends nothing.
**Bugs found** (to be filed, one JIRA per component):
- spring-redis:
- a command the producer does not implement, or an unknown one, does
nothing and raises no error;
- GET of a missing key keeps the body as it was;
- KEYS finds nothing with the default serializer, and ECHO without a value
fails with a NullPointerException;
- a message another client published is dropped with a WARN.
- couchbase:
- without the CamelCouchbaseId header the document id is the Camel
endpoint id, and the key option is never read;
- an unknown operation does nothing;
- without the collection option the generated SQL++ query fails every poll
on Couchbase 8;
- JSON text is stored as a JSON string;
- the operation option gets its values as an enum.
- solr:
- the catalog says deleteByQuery defaults to true, the code to false;
- with camel-solr on the classpath a conversion of any String or POJO to a
Map gives an empty Map;
- no body searches for, or deletes, the text "java.lang.Object@...";
- an INSERT of a body that is not a document reports success and stores
nothing.
- ssh: the shell channel without a shellPrompt fails with a
NullPointerException.
- slack:
- the webhook mode writes camelCase keys such as iconEmoji, where Slack
expects icon_emoji;
- it also changes the channel and the username of the Message body.
- telegram:
- a byte array with the media type TEXT is sent as a document;
- a stream or a file cannot be sent as media;
- the echo of a message without text sends the toString() of the
IncomingMessage;
- an answer with ok=false is not an error.
- camel-support:
- API components do not convert the body to the type of the inBody
parameter, so a byte array or a stream fails with "argument type mismatch";
- a producer that picks its operation by a header does nothing for an
unknown operation.
**Docs fixed:**
- **spring-redis:** the result types of 12 commands, and that a command
without a result, or with a null result, keeps the body.
- **couchbase:** what the consumer body is, and a new section on the
producer: the operations, the id header, how the body is stored and the body
after the call.
- **fhir:** the inBody option takes the body as it is, and the body after a
call is the result of the method.
- **solr:**
- a Map and a String query in the table;
- the deleteByQuery option and header;
- the response as the body.
- **ssh:** the body after the call is the output as a stream.
- **slack:** the bodies the producer sends, the token mode, and the Message
of the consumer.
- **telegram:**
- what a byte array sends;
- the body after a call;
- the update objects the consumer gives;
- sendLocation.
**Measured.**
- The validator over the 1204 human-written and 1209 model-written route
files gives the same reports as with #28306.
- Body types now cover 95.9% of the endpoint uses in the human-written
routes (94.8% with #28306), and 116 of the 413 component JSONs have them.
**Tests**
- `TextBodyFlowTest.testTheBodyOfMoreComponents`:
- reported: a Map sent to ssh, a field read after the ssh consumer, after
spring-redis PING, and after a couchbase consumer with fullDocument=false;
- not reported: a field read after spring-redis SET (the body is kept) and
GET (not known), after solr, and a Map sent to slack.
- These pass:
- the 290 tests of camel-yaml-dsl-validator;
- the 265 validator and catalog doc tests of camel-jbang-core;
- the builds of camel-yaml-dsl-maven-plugin and
camel-yaml-dsl-deserializers.
- The answers of camel_catalog_doc stay under 18 000 characters:
spring-redis, the largest, is 15 165.
_Claude Code on behalf of davsclaus_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]