ammachado opened a new pull request, #26920:
URL: https://github.com/apache/camel/pull/26920

   # Description
   
   [CAMEL-24955](https://issues.apache.org/jira/browse/CAMEL-24955): a route 
that sends to an endpoint no route consumes can be caught from the source, but 
today it only shows up when the application starts, or never.
   
   ```yaml
   - route:
       id: tick
       from:
         uri: timer:tick
         steps:
           - to:
               uri: direct:lookup      # and no route consumes direct:lookup
   ```
   
   With `direct:` the route fails to start (*No consumers available on 
endpoint*). With `seda:` nothing fails: the messages are queued and never read. 
`camel validate source` now reports it:
   
   ```
   route tick: sends to direct:lookup, and no route consumes it - not in this 
file, nor in the other route files of the directory: the route fails to start 
with No consumers available on endpoint; add a route with from: direct:lookup, 
or correct the name
   ```
   
   **How**
   
   - `EndpointConsumers` (validator module) builds on `RouteGraph` from 
CAMEL-24844 (#26800). It finds the `direct:`/`seda:` endpoints a file's routes 
send to (`to`, `toD`, `enrich`, `pollEnrich`, `wireTap`, at any depth) and 
consume. It recognizes both spellings: `direct:lookup`, and `uri: direct` with 
`parameters: {name: lookup}`.
   - `EndpointConsumerChecks` (camel-jbang-core) reads the route files next to 
the file being validated: YAML, Java (`from("...")`) and XML (`<from 
uri="...">`). `SourceValidator` runs the check alongside the other 
directory-aware checks (`validateYamlBeanRefs`, `validateResourceRefs`), once 
the file passes the schema.
   
   **Reports only when certain.** It says nothing:
   - without a directory (`camel validate yaml` passes none);
   - for an endpoint only known at runtime (`{{...}}`, `${...}`);
   - when a consumer cannot be read: a Java `from(CONSTANT)` or 
`from(direct("x"))`, or a placeholder in a `from` uri, since it could be the 
missing endpoint;
   - for other components (`vm:`/`direct-vm:` reach other contexts; `kafka:` 
and the like are external).
   
   The file being validated is read from its content, not from disk, so an 
editor buffer newer than the file is judged correctly.
   
   **Left out on purpose.** The ticket's reverse direction (a `direct:` route 
nothing calls) is not here. Its callers are often invisible to a source scan: 
an OpenAPI rest binding to `direct:<operationId>`, a `ProducerTemplate`, `camel 
cmd send`. A rest verb's `to: direct:x` is not checked either, only routes; it 
would be a small follow-up.
   
   **Docs.** One paragraph in `camel-jbang-devtools.adoc` for `camel validate 
source`. No upgrade-guide entry, consistent with the earlier validator checks 
(CAMEL-24698, CAMEL-24843, CAMEL-24844, CAMEL-24852).
   
   **Tests.** 8 in the validator module (missing consumer, another file 
consumes it, no directory, the same file in both spellings, the seda wording, 
external and dynamic endpoints, a placeholder consumer, `consumed()`), and 7 in 
camel-jbang-core through `SourceValidator.validate` with a `@TempDir` (YAML, 
Java and XML siblings, a non-literal Java `from`, the buffer-vs-disk case, no 
directory). Validator module 159 green, camel-jbang-core 1250 green, 
camel-jbang-plugin-tui and camel-jbang-plugin-validate green.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
   
     Not from the root: `mvn install` was run on the two touched modules 
(`camel-yaml-dsl-validator`, `camel-jbang-core`), which format the code; the 
working tree was clean afterwards.
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code) on behalf of 
Adriano Machado (@ammachado)
   
   _This was generated by an AI agent and may contain inaccuracies. Please 
verify before relying on it._


-- 
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]

Reply via email to