5 Replies Latest reply on Dec 22, 2012 5:00 AM by piratew

    Camel Mail binding

    splatch

      I just submited pull requests for camel-mail binding. It's based on camel-mail component.

       

      Example configuration for mail receiver/poller. It's based on ScheduledBatchPollConsumer.

       

              <sca:service name="camelTest" promote="SimpleCamelService">
                  <camel:binding.mail secure="true">
                      <camel:host>localhost</camel:host>
                      <camel:port>233</camel:port>
                      <camel:username>camel</camel:username>
                      <camel:password>rider</camel:password>
                      <camel:connectionTimeout>300</camel:connectionTimeout>
                      <camel:consume accountType="pop3">
                          <camel:folderName>Mail/Inbox</camel:folderName>
                          <camel:fetchSize>10</camel:fetchSize>
                          <camel:unseen>false</camel:unseen>
                          <camel:delete>true</camel:delete>
                          <camel:copyTo>SEEN</camel:copyTo>
                          <camel:disconnect>true</camel:disconnect>
                      </camel:consume>
                  </camel:binding.mail>
              </sca:service>
      
      

       

      Example configuration for sender/producer.

       

              <sca:reference name="mail" multiplicity="0..1" promote="mailTest">
                  <camel:binding.mail secure="true">
                      <camel:host>localhost</camel:host>
                      <camel:port>233</camel:port>
                      <camel:username>camel</camel:username>
                      <camel:password>rider</camel:password>
                      <camel:connectionTimeout>300</camel:connectionTimeout>
                      <camel:produce>
                          <camel:subject>Desert ride</camel:subject>
                          <camel:from>rider@camel</camel:from>
                          <camel:to>camel@rider</camel:to>
                          <camel:CC>mule@rider</camel:CC>
                          <camel:BCC>rider@mule</camel:BCC>
                          <camel:replyTo>camel@camel</camel:replyTo>
                      </camel:produce>
                  </camel:binding.mail>
              </sca:reference>
      
      

       

      Detailed description of parameters can be found in camel documentation. What's really important - that protocol used by binding is determined using parent element. If parent element is reference then component will use SMTP (or smtps if secure flag is set for binding.mail). If parent element is service then pop3/imap protocol is used. Only one mandatory field in all cases is hostname.

        • 1. Re: Camel Mail binding
          piratew

          Hi,

           

          I'm trying to use the quickstart demo in a way that it uses my gmail account. I've deployed it in jboss as7 with switchyard component. It seems that the poller is not started as no connection is made to imap.gmail.com. Unfortunately I don't see any errors so I'm kind of stuck getting this to work. Any ideas what could be wrong?

           

           

          This is my config:

           

          {code}

          <?xml version="1.0" encoding="UTF-8"?>

          <switchyard xmlns="urn:switchyard-config:switchyard:1.0"

              xmlns:mail="urn:switchyard-component-camel-mail:config:1.0"

              xmlns:selector="urn:switchyard-component-common-selector:config:1.0"

              xmlns:bean="urn:switchyard-component-bean:config:1.0">

           

              <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" name="camel-mail-binding"

                  targetNamespace="urn:switchyard-quickstart:camel-mail-binding:0.1.0">

           

                  <service name="PrintService" promote="PrintService">

                      <mail:binding.mail secure="true">

                          <mail:host>imap.gmail.com</mail:host>

                          <mail:username>test@gmail.com</mail:username>

                          <mail:password>test</mail:password>

                          <mail:consume accountType="imap">

                              <mail:folderName>inbox</mail:folderName>

                              <mail:initialDelay>0</mail:initialDelay>

                              <mail:delay>100</mail:delay>

                              <mail:copyTo>after-processing</mail:copyTo>

                              <mail:disconnect>true</mail:disconnect>

                          </mail:consume>

                      </mail:binding.mail>

                  </service>

           

                  <reference multiplicity="1..1" name="OutgoingPrintService" promote="OutgoingPrintService">

                      <mail:binding.mail secure="true">

                          <mail:host>smtp.gmail.com</mail:host>

                          <mail:username>test@gmail.com</mail:username>

                          <mail:produce>

                              <mail:subject>Forwarded message</mail:subject>

                              <mail:from>test@localhost</mail:from>

                              <mail:to>test@gmail.com</mail:to>

                          </mail:produce>

                      </mail:binding.mail>

                  </reference>

              </composite>

           

          </switchyard>

          {code}

          • 2. Re: Camel Mail binding
            splatch

            Hey Michael,

            Last weeks we had lots of changes in namespaces. The namespace of mail binding (urn:switchyard-component-camel-mail:config:1.0) you have is proper only for current SNAPSHOT of SwitchYard. Which version do you run?

             

            Best regards,

            Lukasz

            • 3. Re: Camel Mail binding
              piratew

              Hi Lukasz,

               

              thanks for the quick reply! I'm using 0.7.0-SNAPSHOT. However I do have the quickstart deployed in as7 with switchyard-as7-0.6 as module. Could this cause the problem?

               

              regards

               

              Michael

              • 4. Re: Camel Mail binding
                splatch

                Michael,

                Previous release of SwitchYard do not contain mail binding. So you need SwitchYard 0.7-SNAPSHOT to run it. We expect release soon, so you will not need to depend on snapshots. It's worth to note that you can test your binding configuration with unit tests, which will start or report issues when something is wrong.

                • 5. Re: Camel Mail binding
                  piratew

                  Hi Lukasz,

                   

                  thanks a lot for making this clear. I've downloaded the switchyard as7 0.7 from ci.jboss.org and deployed it to that version. All went well and soon my gmail account was being used by the app. Nice to see it working without too much hassle (once I use the correct versions )

                   

                  Still got some annoying xml validation errors in the switchyard.xml, complaining about mail:binding.mail and also suddenly that the delay and initialdelay config was not correct. Don't know what's causing these problems, probably jbdev6?

                   

                  anyway, thanks a lot for your help

                   

                  regards,

                   

                  Michael