Repository navigation
chore: the S3 sink can upload in parts and refuse to replace a file, the S3 event source can use long polling, the SES sink takes its recipients as options (#3170) - #3231
Merged
Conversation
…the S3 event source can use long polling, the SES sink takes its recipients as options (apache#3170) aws-s3-sink: - multiPartUpload and partSize: a file of partSize bytes or more is uploaded as an S3 multipart upload, so files over the 5 GB limit of one upload can be stored. - conditionalWritesEnabled: the upload of a key that exists already fails with PreconditionFailed (412) instead of replacing the file. aws-s3-event-based-source: maxMessagesPerPoll, waitTimeSeconds (long polling) and visibilityTimeout on its SQS consumer. aws-ses-sink: to, cc, bcc, subject, replyToAddresses, returnPath and configurationSet as options, and overrideEndpoint and uriEndpointOverride to reach a local stand-in of AWS. The to, subject and reply-to-addresses headers take precedence over the options; with the to option set, the to header is no longer required. The fallback of the subject to the exchange ID is skipped when the subject option is set. The subject and the addresses go into the URI inside RAW(), so that a +, a % or an & is kept as written. All new options are optional and have no default: with them unset, the endpoint URIs are the same as before. The descriptions and the doc partials have examples of the new options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #3170:
aws-s3-sinkcan upload large files in parts and refuse to replace an existing file,aws-s3-event-based-sourcecan use long polling and set how many events it receives and for how long they stay hidden, andaws-ses-sinktakes its recipients, subject, Cc, Bcc, return path and configuration set as options and can connect to a local stand-in of AWS.The problem
aws-s3-sinkuploaded every file in one request. S3 takes at most 5 GB in one upload, so larger files could not be stored. A file with an existing key was always replaced.aws-s3-event-based-sourceasked SQS for events every 500 ms with requests that return at once, even on an empty queue, and had no say in the visibility timeout: an event that takes longer to process than the timeout of the queue (30 s by default), such as fetching a large file withgetObject, was received a second time.aws-ses-sinktook the recipients, the subject and the reply-to addresses only from headers, so every message needed atoheader. It had no Cc, Bcc, return path or configuration set, and could not be pointed at a local stand-in of AWS.The options
aws-s3-sink: appended to the end of theaws2-s3URI, after the proxy options.multiPartUpload&multiPartUpload={{?multiPartUpload}}partSizebytes or more is uploaded as an S3 multipart upload, one request per part. Smaller files still go in one request.partSize&partSize={{?partSize}}multiPartUpload.conditionalWritesEnabled&conditionalWritesEnabled={{?conditionalWritesEnabled}}If-None-Match: *: the upload of an existing key fails withPreconditionFailed(412), and the file is not changed. Also on the completion of a multipart upload.aws-s3-event-based-source: added to the parameters of theaws2-sqsconsumer.maxMessagesPerPollmaxMessagesPerPoll: "{{?maxMessagesPerPoll}}"waitTimeSecondswaitTimeSeconds: "{{?waitTimeSeconds}}"visibilityTimeoutvisibilityTimeout: "{{?visibilityTimeout}}"aws-ses-sink: appended to the end of theaws2-sesURI, after the proxy options.to&to=RAW({{?to}})toheader takes precedence; with the option set, the header is no longer required.cc&cc=RAW({{?cc}})bcc&bcc=RAW({{?bcc}})subject&subject=RAW({{?subject}})subjectheader takes precedence.replyToAddresses&replyToAddresses=RAW({{?replyToAddresses}})reply-to-addressesheader takes precedence.returnPath&returnPath=RAW({{?returnPath}})configurationSet&configurationSet={{?configurationSet}}^[A-Za-z0-9_-]+$.overrideEndpoint&overrideEndpoint={{?overrideEndpoint}}uriEndpointOverrideinstead of SES.uriEndpointOverride&uriEndpointOverride={{?uriEndpointOverride}}http://localhost:4566.default, as in chore: mail-sink can use STARTTLS (#3170) #3174. When they are unset, the optional placeholders drop them, and the endpoint URIs of the three Kamelets are byte-identical tomain's.conditionalWritesEnabledexists at 4.24.0-SNAPSHOT (AWS2S3Configuration). The component sendsIf-None-Match: *onPutObjectand onCompleteMultipartUpload.main, a message without asubjectheader got the exchange ID as its subject, in a header that would have hidden asubjectoption. That fallback is now skipped, with apreconditionchoice on${propertiesExist:!subject}(asaws-s3-sinkdoes forkeyName), when thesubjectoption is set. Without the option, the subject is still a generated ID.RAW()in SES: the subject is free text, and addresses can hold a+. WithoutRAW(), the subjectOrder (#42) & more + 100% donemade the route fail at start (URLDecoder: Illegal hex characters in escape (%) pattern), and a+in an address would turn into a space. With it, both are kept as written. The address options have a pattern for plain, comma-separated addresses (^[^ ,@]+@[^ ,@]+( *, *[^ ,@]+@[^ ,@]+)*$;returnPatha single address), so a;as separator is caught; a display name such asJane <jane@example.com>is not allowed in the options.to,subjectorreply-to-addressesheader takes precedence over the option, as the component does for its own headers.cc,bcc,returnPathandconfigurationSethave no Kamelet header.trustAllCertificatesof SES (it turns off TLS checks). Kamelet headers for Cc and Bcc.aws-s3-sink: "Good to know" says thatconditionalWritesEnabledstops the replacement of a file, and points tomultiPartUploadfor files over 5 GB.aws-s3-event-based-source: "Good to know" says that an event that fails is received again when its visibility timeout ends.aws-ses-sink: the summary, "Input" and "Good to know" say thattocan be an option, that the headers take precedence, thatreturnPathmust be verified and a missing configuration set fails every email, and how to reach a local stand-in. The header descriptions say the same.aws-s3-sinkhas an "Example with Multipart Uploads and Conditional Writes",aws-s3-event-based-sourcean "Example with Long Polling and a Longer Visibility Timeout", andaws-ses-sinkan "Example with Fixed Recipients and a Configuration Set" and an "Example with a Local Stand-in of AWS". Its "Headers" section says which header is required and that the headers take precedence.waitTimeSeconds; that bounces go toreturnPath; and what a configuration set publishes (delivery, bounce, open and click events to CloudWatch, SNS or Firehose).Verification
Tested with Camel JBang 4.24.0-SNAPSHOT against
floci/floci2.5.0 as S3, SQS and SES, with its HTTP access log turned on (QUARKUS_HTTP_ACCESS_LOG_ENABLED=true) as the request log. Floci keeps the emails it was given at/_aws/ses, checks thatfromand the return path are verified, and checks that a configuration set exists. The upload body was a 12 MiB (12,582,912 bytes) random file;partSizewas 5 MiB (5242880). Endpoint URIs were read withcamel get endpoint --json.Unset options
mainvs this branchaws2-s3,aws2-sesandaws2-sqsendpoint URIs identicalaws-s3-sinkmultiPartUpload+partSize: 5242880, 12 MiB file bodyPOST ?uploads,PUT ?partNumber=1,2,3,POST ?uploadId(200).head-object: 12,582,912 bytes, ETag"96eb…-3"(3 parts); the downloaded file has the MD5 of the sourcebyte[]body"96eb…-3"multiPartUpload,partSizeunset, 12 MiBPUT(under the default 25 MB); MD5 matchesmultiPartUpload+partSize: 5242880, 10-byte bodyPUTpartSize: 5242880withoutmultiPartUpload, 12 MiBPUTmultiPartUpload+partSize: 1048576, 12 MiBYour proposed upload is smaller than the minimum allowed size), followed byDELETE ?uploadId(abort);list-multipart-uploadsis emptyconditionalWritesEnabled, new keyPUT200, storedconditionalWritesEnabled, the same key againPUT412; the message fails withAt least one of the pre-conditions you specified did not hold (Service: S3, Status Code: 412)PUT200)conditionalWritesEnabled+multiPartUpload, existing keyDELETE ?uploadId(abort); the message failsconditionalWritesEnabled+keyName, two messagesPUT200, secondPUT412; the file keeps the body of the first messageaws-s3-event-based-sourcemaxMessagesPerPoll: 2,delay: 4000, 6 events on the queuedelay: 4000waitTimeSeconds: 10,delay: 100, empty queue for 34 s, one event sent after 18 svisibilityTimeout: 3, a route that fails every eventaws-ses-sink(withoverrideEndpointanduriEndpointOverridepointing at Floci)to: "user+tag@example.com, second@example.com", twocc, abcc,subject: "Order (#42) & more + 100% done",replyToAddresses,returnPath,configurationSet: cs1(existing)+), Cc, Bcc, Reply-To, subject and return pathconfigurationSet: does-not-existConfiguration set <does-not-exist> does not exist(400)to,subject,replyToAddressestogether withto,subject,reply-to-addressesheaderstoandsubject: "Nightly job (done)", no headerstoheader onlymaintoheader nor thetooptionAt least one destination address is requiredRAW()(first attempt)URLDecoder: Illegal hex characters in escape (%) pattern./mvnw clean verify -DskipTestsand then./mvnw clean verifypassed from the root. Before building, the library copies of the three Kamelets were refreshed with./mvnw -pl library/camel-kamelets resources:copy-resources@copy-resource-one. The build regeneratedkamelets-index.json.Claude Code on behalf of Claus Ibsen
🤖 Generated with Claude Code