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

   Part of #3170: `aws-sqs-source` can read the attributes of a message.
   
   Today it asks SQS for no attributes, so the message attributes that the 
sender sets and the system attributes of SQS, such as `SentTimestamp`, are 
never read, and the `CamelAwsSqsMessageAttributes` and `CamelAwsSqsAttributes` 
headers are always empty.
   
   ### The options
   
   | Option | Endpoint parameter | What it does |
   |---|---|---|
   | `messageAttributeNames` | `messageAttributeNames: 
"{{?messageAttributeNames}}"` | The message attributes to read: `All`, a 
comma-separated list of names, or a prefix such as `trace.*` |
   | `attributeNames` | `attributeNames: "{{?attributeNames}}"` | The system 
attributes to read: `All`, or a comma-separated list such as 
`SentTimestamp,ApproximateReceiveCount` |
   
   Both are optional strings and deliberately have no `default`: when they are 
not set, the optional placeholders drop the parameters, so the endpoint URI is 
exactly today's.
   
   What the user gets, read from the aws2-sqs consumer and checked by running 
it:
   
   - Each attribute that is read becomes a header of the same name. A String 
attribute is text, a Number attribute is text (or a number when its type has a 
label such as `Number.int`), and a Binary attribute is an AWS SDK `SdkBytes`. 
System attributes are text; the timestamps are milliseconds since 1970.
   - A message attribute whose name starts with `Camel` does not become a 
header (the default header filter of aws2-sqs). It is still in the 
`CamelAwsSqsMessageAttributes` Map, from name to an AWS SDK 
`MessageAttributeValue`.
   - The keys of the `CamelAwsSqsAttributes` Map are AWS SDK 
`MessageSystemAttributeName` values, not text, so 
`${header.CamelAwsSqsAttributes[SentTimestamp]}` finds nothing. The description 
says to read one attribute from its own header.
   - An unknown system attribute name is ignored, with a warning in the log.
   
   The `Output:` paragraph, the two option descriptions, the descriptions of 
the two dataTypes headers (which said "The Kamelet asks for none, so it is 
empty") and the partial page are updated. The partial page has a new section, 
"Reading the attributes of a message", with a table of the header values and an 
example. The other SQS Kamelets (`aws-sqs-sink`, `aws-sqs-batch-sink`, 
`aws-sqs-fifo-sink`) are sinks, so they do not have this gap.
   
   ### Verification
   
   Tested with Camel JBang 4.24.0-SNAPSHOT against the `floci/floci` AWS 
stand-in, as the SQS itests use. Each message carried the message attributes 
`customer` (String `acme`), `priority` (Number `5`), `retries` (Number.int 
`3`), `blob` (Binary `hello`), `trace.id` (String `t-1`) and `CamelHttpUri` 
(String `http://evil`).
   
   | Case | Headers |
   |---|---|
   | Options unset, Kamelet from `main` and from this PR | Both: no attribute 
headers, `CamelAwsSqsAttributes={}`, `CamelAwsSqsMessageAttributes={}`; the 
`aws2-sqs` endpoint URIs are identical |
   | `messageAttributeNames: All` | `customer=acme`, `priority=5` (String), 
`retries=3` (Integer), `blob` (`SdkBytes`), `trace.id=t-1`; no `CamelHttpUri` 
header, but it is in the `CamelAwsSqsMessageAttributes` Map |
   | `messageAttributeNames: .*` | The same as `All` |
   | `messageAttributeNames: customer,priority` | Only `customer` and 
`priority` |
   | `messageAttributeNames: trace.*` | Only `trace.id` |
   | `messageAttributeNames: missing` | No attribute headers, empty Map |
   | `attributeNames: SentTimestamp,ApproximateReceiveCount` | `SentTimestamp` 
and `ApproximateReceiveCount` headers, as text, and in `CamelAwsSqsAttributes` |
   | `attributeNames: All` | `SenderId`, `SentTimestamp`, 
`ApproximateReceiveCount`, `ApproximateFirstReceiveTimestamp` |
   | `attributeNames: Bogus` | Warning `Unsupported attribute name 'Bogus' use 
one of [...]`; no attributes; the message is received |
   | Both set to `All` | All of the above together |
   
   `./mvnw clean verify -DskipTests` and `./mvnw clean verify` passed. 
`KameletsCatalogTest` counts the options of `aws-sqs-source`, so it now expects 
23 and checks the two new ones.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 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]

Reply via email to