davsclaus opened a new pull request, #3338:
URL: https://github.com/apache/camel-kamelets/pull/3338

   ## What
   
   A new source Kamelet, `aws-eventbridge-source`, the pair of 
`aws-eventbridge-sink`. It receives the events that an EventBridge rule 
matches, one message per event, with the consumer of the Camel 
`aws2-eventbridge` component (Camel 4.19+). EventBridge has no pull API, so the 
component adds an SQS queue to the rule as a target and polls that queue.
   
   - The **rule must exist** on the event bus. The Kamelet does not create it, 
and its event pattern decides which events arrive. If the rule does not exist, 
the Kamelet fails to start (`ResourceNotFoundException: Rule not found`) and 
deletes the queue it had created.
   - **Without `queueURL`** it creates a queue 
`camel-eventbridge-<rule>-<random>` with a policy that lets EventBridge send to 
it. When it stops, it removes the queue from the rule and deletes it. Each 
replica therefore gets its own queue and every event, and the events sent while 
it is stopped are lost.
   - **With `queueURL`** it adds your queue to the rule and leaves the target 
there when it stops. The queue collects the events while the Kamelet is 
stopped, and the replicas share the events.
   
   ### Options
   
   `eventbusNameOrArn`, `ruleName` and `region` are required.
   
   - Optional: `queueURL`, the credentials (`accessKey`/`secretKey`, 
`useDefaultCredentialsProvider`, `useProfileCredentialsProvider` + 
`profileCredentialsName`, `useSessionCredentials` + `sessionToken`), 
`uriEndpointOverride` + `overrideEndpoint` (used for both EventBridge and SQS), 
`delay`, `greedy`, `maxMessagesPerPoll` (1–10, default 10), `waitTimeSeconds` 
(0–20, default 20), `visibilityTimeout` (default 30), and 
`proxyHost`/`proxyPort`/`proxyProtocol`.
   - Not exposed:
     - `autoCreateQueue`: false without `queueURL` is only an error.
     - `deleteQueueOnShutdown`: false keeps an auto-created queue that is no 
longer a target of the rule and is never reused.
     - `trustAllCertificates`: an insecure default we do not ship.
     - The scheduler internals.
   - `ruleName` has a `pattern` (the EventBridge rule-name characters). The 
secrets are `format: password` + credentials x-descriptor.
   
   ### Output
   
   The body is the **whole EventBridge event**, not only its `detail`, as JSON 
text (a `String`): `id`, `detail-type`, `source`, `account`, `time`, `region`, 
`resources`, and `detail`, which holds what the sender put in it. There is no 
`Content-Type` header. The headers are `CamelAwsEventbridgeMessageId` (the ID 
of the SQS message) and `CamelAwsEventbridgeReceiptHandle`.
   
   `spec.dataTypes` declares only the out headers. There is no `default`, 
because a source `out` default runs after the steps that follow the Kamelet 
(#3117).
   
   ### How it relates to aws-s3-event-based-source
   
   Both receive EventBridge events through SQS. `aws-s3-event-based-source` 
reads a queue that you made the target of a rule yourself. It is specific to 
S3: it sets `aws-s3-event-id`, which is the same in each copy of an event, and 
it can fetch the files. `aws-eventbridge-source` sets up the queue and the 
target itself, for any rule. The description says this.
   
   ## Tests
   
   `aws/eventbridge/aws-eventbridge-source.citrus.it.yaml` (in 
`AwsIT#awsEventBridge`) runs against Floci:
   
   1. A Groovy step creates the event bus `orders` and the rule 
`orders-shipped`, whose pattern is source `com.example.shop` and detail-type 
`Order Shipped`.
   2. The integration runs the new source, which passes each event on to the 
Citrus HTTP server.
   3. `aws-eventbridge-sink` first puts an `Order Cancelled` event on the bus, 
which the rule does not match, and 2 s later an `Order Shipped` event.
   4. The test checks the first request that arrives:
      - The body is a `String` with no Content-Type.
      - The SQS message ID and the receipt handle are set.
      - JSON paths `id`, `detail-type`, `source`, `resources[0]`, and 
`detail.orderId` = `A-1`.
   
   A mutation run confirmed that the test catches a delivered non-matching 
event: with a rule that also matches `Order Cancelled`, the test fails.
   
   I also checked these with `camel run` against Floci; they are not in the 
Citrus test, to keep it lean:
   
   - A missing rule makes the Kamelet fail to start.
   - Two Kamelets on the same `queueURL` share the events, while one without 
`queueURL` gets every event.
   - With `queueURL`, the queue collects the events while the Kamelet is 
stopped.
   - A failing event is received again after each `visibilityTimeout`.
   - With the default `waitTimeSeconds` of 20, stopping waits for the SQS 
request that is still running.
   
   Local results:
   
   - `./mvnw -o clean install -DskipITs`: BUILD SUCCESS. The AWS namespace 
count in `KameletsCatalogTest` goes from 31 to 32.
   - `./mvnw -o verify -pl tests/camel-kamelets-itest -Dit.test=AwsIT`: 41 
tests, 40 pass. Both eventbridge tests pass. The one failure is 
`aws-s3-ceph-event-based-source-get-object-test`, which this PR does not touch: 
the Citrus send to the Redpanda container (`ceph-events` topic) timed out after 
5000 ms. It also failed when re-run alone (`AwsIT#awsS3`), so it looks 
environmental or pre-existing locally; CI will tell.
   
   Fixes #3334.
   
   ## Upgrade note
   
   - New Kamelet `aws-eventbridge-source`: it receives the events that an 
existing Amazon EventBridge rule matches, through an SQS queue that it adds to 
the rule as a target. Without `queueURL`, it creates the queue when it starts 
and deletes it when it stops.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
   


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