lopushen opened a new pull request, #309:
URL: https://github.com/apache/camel-karaf/pull/309

   Fixes https://github.com/apache/camel-karaf/issues/308
   
   Motivation
   During testing using an OSGI blueprint, it turned out that the 
camel-aws2-ses is missing bundles to successfully execute the route.
   
   Modifications:
   Add the missing bundles with appropriate SPI provide/consume statements
   
   To run localstack (AWS emulator):
   `docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 
localstack/localstack`
   In the emulator run
   `aws configure --profile localstack`
   and enter in the prompt:
   ```
   test
   test
   us-east-1
   json
   ```
   to get
   ```
   AWS Access Key ID [None]: test
   AWS Secret Access Key [None]: test
   Default region name [None]: us-east-1
   Default output format [None]: json
   ```
   And verify the sender's email in localstack console
   `aws --endpoint-url=http://localhost:4566 ses verify-email-identity 
--email-address sen...@example.com --region us-east-1 --profile localstack`
   
   Deploy the following blueprint (the endpoint is producer-only, so only one 
route):
   ```
   <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
              
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";
              xsi:schemaLocation="
                http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
                http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                http://camel.apache.org/schema/blueprint 
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd";>
   
       <bean id="ses2Configuration" 
class="org.apache.camel.component.aws2.ses.Ses2Configuration">
           <property name="accessKey" value="test"/>
           <property name="secretKey" value="test"/>
           <property name="region" value="us-east-1"/>
           <property name="overrideEndpoint" value="true"/>
           <property name="uriEndpointOverride" value="http://localhost:4566"/>
       </bean>
   
       <bean id="aws2-ses" 
class="org.apache.camel.component.aws2.ses.Ses2Component">
           <property name="configuration" ref="ses2Configuration"/>
       </bean>
       <camelContext id="camel" 
xmlns="http://camel.apache.org/schema/blueprint";>
           <route id="sendEmailRoute">
               <from uri="timer:sendEmailTimer?period=5000"/> 
                 <setHeader name="CamelAwsSesFrom">
                   <constant>sen...@example.com</constant>
               </setHeader>
               <setHeader name="CamelAwsSesTo">
                   <constant>recipi...@example.com</constant>
               </setHeader>
               <setHeader name="CamelAwsSesSubject">
                   <constant>Test Email</constant>
               </setHeader>
               <setBody>
                   <constant>Hello, this is a test email sent from Apache Camel 
using AWS SES!</constant>
               </setBody>
               <to uri="aws2-ses://default"/>
               <log message="Sent email: ${body}"/>
           </route>
       </camelContext>
   </blueprint>
   ```
   Observe the following output:
   ```
   01:32:04.093 INFO [Camel (camel-4) thread #7 - timer://sendEmailTimer] Sent 
email: Hello, this is a test email sent from Apache Camel using AWS SES!
   01:32:09.090 INFO [Camel (camel-4) thread #7 - timer://sendEmailTimer] Sent 
email: Hello, this is a test email sent from Apache Camel using AWS SES!
   01:32:14.136 INFO [Camel (camel-4) thread #7 - timer://sendEmailTimer] Sent 
email: Hello, this is a test email sent from Apache Camel using AWS SES!
   ```
   And the following output in localstack:
   ```
   2024-05-30T22:32:34.111  INFO --- [et.reactor-0] localstack.request.aws     
: AWS ses.SendEmail => 200
   2024-05-30T22:32:39.103  INFO --- [et.reactor-1] localstack.request.aws     
: AWS ses.SendEmail => 200
   2024-05-30T22:32:44.117  INFO --- [et.reactor-1] localstack.request.aws     
: AWS ses.SendEmail => 200
   ```
   
   The features and bundles were added to awssdk feature as these dependencies 
are common with other aws features, e.g. camel-aws2-sns and camel-aws2-sqs


-- 
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: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to