3 Replies Latest reply on Jan 18, 2013 3:31 AM by peaceman

    Problem consuming and transforming pop3 email messages

    peaceman

      Hi,

       

      i currently have a problem with fuse esb.

       

      i want to consume a email via pop3.

      My test setup works for this. I Can receive email from my gmail account via pop3.

       

      However when trying to enrich, transform or extend the Message-Body of the email i got this exception:

       

       

      19:46:43,080 | ERROR | op.gmail.com:995 | DefaultErrorHandler              | 147 - org.apache.camel.camel-core - 2.10.0.fuse-71-047 | Failed delivery for (MessageId: ID--PC-65526-1358444279203-18-1 on ExchangeId: ID-Marcel-PC-65526-1358444279203-18-2). Exhausted after delivery attempt: 1 caught: org.apache.camel.TypeConversionException: Error during type conversion from type: com.sun.mail.util.QPDecoderStream to the required type: byte[] with value com.sun.mail.util.QPDecoderStream@5a92ea0d due java.io.IOException: Stream closed

      org.apache.camel.TypeConversionException: Error during type conversion from type: com.sun.mail.util.QPDecoderStream to the required type: byte[] with value com.sun.mail.util.QPDecoderStream@5a92ea0d due java.io.IOException: Stream closed

           at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:126)

           at org.apache.camel.core.osgi.OsgiTypeConverter.convertTo(OsgiTypeConverter.java:102)

           at org.apache.camel.util.ExchangeHelper.convertToType(ExchangeHelper.java:199)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]

           at org.apache.camel.impl.StringDataFormat.unmarshal(StringDataFormat.java:54)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]

           at org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:57)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]

           at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]

           at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]

           at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]

           at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]

           at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)[147:org.apache.camel.camel-core:2.10.0.fuse-71-047]

           

      Caused by: org.apache.camel.RuntimeCamelException: java.io.IOException: Stream closed

           at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1271)

           at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:927)

           at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:47)

           at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:253)

           at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:111)

           ... 52 more

       

       

      blueprint.xml:

       

              <log logName="1" loggingLevel="INFO" message="mail received body: $"/>         <unmarshal>             <string/>         </unmarshal>         <log logName="2" message="body: $"/>

          </route>

      </camelContext>

       

      </blueprint>

       

       

      After reading the documentation (http://fusesource.com/docs/esb/4.4.1/camel_component_ref/_IDU_Mail.html)

      i expected an usable String-Object however i got some kind of Stream.

       

      Does anybody know how to properly handle incoming pop3 messages.

      Any help is appreciated.

       

      Regrads

      Marcel

       

      Edited by: mfried on Jan 17, 2013 7:18 PM

        • 1. Re: Problem consuming and transforming pop3 email messages
          peaceman

          ok thats strange:

           

          I changed to log endoint to print out the headers ($in.headers) instead of the body $ and the route starts working. May be logging the body directly after receiving the email causes the Stream to stay open. Working route: <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      xsi:schemaLocation="              http://www.osgi.org/xmlns/blueprint/v1.0.0 http://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">      <!-- connect to the local ActiveMQ broker -->      <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">           <property name="brokerURL" value="tcp://localhost:61616" />           <property name="userName" value="admin" />           <property name="password" value="admin" />      </bean>      <!--   StaticAggregationStrategy -->            <!-- The namespace for the camelContext element in Blueprint is 'http://camel.apache.org/schema/blueprint'.           Additionally, we can also define namespace prefixes we want to use them in           the XPath expressions in our CBR. While it is not required to assign id's           to the <camelContext/> and <route/> elements, it is a good idea to set those           for runtime management purposes (logging, JMX MBeans, ...) -->      <camelContext id="jms-example-context" xmlns="http://camel.apache.org/schema/blueprint" xmlns:order="http://fusesource.com/examples/order/v7">     <route id="file-to-jms-route">         <from uri="pop3s://pop.gmail.com:995?username=<my_account>&amp;password=<my_password>&amp;from=<my_second_account>&amp;connectionTimeout=3000&amp;consumer.delay=10000&amp;mapMailMessage=true&amp;fetchSize=1"/>         <log logName="1" loggingLevel="INFO" message="mail received header ${in.headers}"/>         <unmarshal>             <string/>         </unmarshal>         <log logName="2" message="body: $"/>

              </route>

          </camelContext>

           

          </blueprint>

           

           

          Log:

          0:29:56,001 | INFO  | op.gmail.com:995 | 1                                | 147 - org.apache.camel.camel-core - 2.10.0.fuse-71-047 | mail received header {Delivered-To=, X-Disclaimed=1, breadcrumbId=ID-Marcel-PC-65526-1358444279203-32-1, Content-Type=text/plain; charset=UTF-8, Received=[by 10.76.168.226 with SMTP id zz2csp44797oab;

                  Thu, 17 Jan 2013 11:29:48 -0800 (PST), from  (. )

                  by mx.google.com with ESMTP id w2si4451221eel.188.2013.01.17.11.29.47;

                  Thu, 17 Jan 2013 11:29:48 -0800 (PST), from unknown (HELO ogdominosrv1.marksys.de) ()

            by m with ESMTP; 17 Jan 2013 20:29:18 +0100], References=, Authentication-Results=mx.google.com;

                 spf=neutral (google.com: 80.146.178.252 is neither permitted nor denied by best guess record for domain of ) smtp.mail=, X-MIMETrack=Serialize by HTTP Server on //(Release 8.5.2FP1|November 29, 2010) at

          17.01.2013 20:27:24,

               Serialize complete at 17.01.2013 20:27:24,

               Serialize by Router on OGLN07/MARKANT(Release 8.5.2FP4|November 17, 2011) at

          17.01.2013 20:29:18, Date=Thu, 17 Jan 2013 20:27:24 +0100, Message-ID=

           

          Edited by: mfried on Jan 17, 2013 7:49 PM

          • 2. Re: Problem consuming and transforming pop3 email messages
            ffang

            Hi,

             

            It looks like a stream already consumed issue,  please add

            streamCache="true" to camelContext to see if it helps, you can get more details from[1]

             

            http://camel.apache.org/stream-caching.html

             

            Freeman

            • 3. Re: Problem consuming and transforming pop3 email messages
              peaceman

              Hi,

               

              yes adding the property

               

              streamCache="true"

               

              to the route solved the issue!

               

              Thanks & Regrads

              Marcel