You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Peter Thygesen <pe...@gmail.com> on 2009/05/21 17:09:35 UTC

Hot to write a Simple FTP producer with errorhandling

I writing a simple route that uploads files put in a folder.



Configuration: running camel on ApacheMQ 5.2.0



(camel part of activemq.xml) nothing fancy..

<camelContext id="cision-file-channel" xmlns="
http://activemq.apache.org/camel/schema/spring">

  <route>

      <from uri="file://files-to-upload?consumer.delay=60000<file:///\\files-to-upload?consumer.delay=60000>
"/>

      <to uri="ftp://camel@localhost?password=camel"/>

  </route>

</camelContext>



This works “fine” when the FTP Server is running. When FTP ser is down, it
retries, then dump the filen on deadletterchannel e.a. the log file. Not
very useful.



1)  How do I make sure it is not dumped in the log file.. pretty much any
other place would be better. E.g. another folder. Most of all I would like
it to stay in the upload folder until connection has been reestablished.

2)  There is .camel folder in the upload folder. This folder contains the
files that have been processed. Who and when is this folder cleanup and how
large will it grow?



Hope you can help out a newbie like me



BTW

I fould a posting where you discuss threadsafety and ftp producer
http://www.nabble.com/Threadsafety-of-Camel-FTP-td23615932.html

Here you talk about the possibility of making a new uri option for
concurrent producer. Was this very interesting idea entered in jira?



Thx Peter

Re: Hot to write a Simple FTP producer with errorhandling

Posted by harinair <ha...@hotmail.com>.
Sorry - I use the Sprint context based definition... see this:
http://www.nabble.com/Simple-FTP-producer-with-errorhandling-td23655162.html

Hari Gangadharan
Architect, Globalstar/SPOT
http://www.harinair.com



Peter Thygesen-2 wrote:
> 
> I writing a simple route that uploads files put in a folder.
> 
> 
> 
> Configuration: running camel on ApacheMQ 5.2.0
> 
> 
> 
> (camel part of activemq.xml) nothing fancy..
> 
> <camelContext id="cision-file-channel" xmlns="
> http://activemq.apache.org/camel/schema/spring">
> 
>   <route>
> 
>       <from
> uri="file://files-to-upload?consumer.delay=60000<file:///\\files-to-upload?consumer.delay=60000>
> "/>
> 
>       <to uri="ftp://camel@localhost?password=camel"/>
> 
>   </route>
> 
> </camelContext>
> 
> 
> 
> This works “fine” when the FTP Server is running. When FTP ser is down, it
> retries, then dump the filen on deadletterchannel e.a. the log file. Not
> very useful.
> 
> 
> 
> 1)  How do I make sure it is not dumped in the log file.. pretty much any
> other place would be better. E.g. another folder. Most of all I would like
> it to stay in the upload folder until connection has been reestablished.
> 
> 2)  There is .camel folder in the upload folder. This folder contains the
> files that have been processed. Who and when is this folder cleanup and
> how
> large will it grow?
> 
> 
> 
> Hope you can help out a newbie like me
> 
> 
> 
> BTW
> 
> I fould a posting where you discuss threadsafety and ftp producer
> http://www.nabble.com/Threadsafety-of-Camel-FTP-td23615932.html
> 
> Here you talk about the possibility of making a new uri option for
> concurrent producer. Was this very interesting idea entered in jira?
> 
> 
> 
> Thx Peter
> 
> 

-- 
View this message in context: http://www.nabble.com/Hot-to-write-a-Simple-FTP-producer-with-errorhandling-tp23654861p23662278.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Hot to write a Simple FTP producer with errorhandling

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, May 22, 2009 at 12:49 AM, Peter Thygesen
<pe...@gmail.com> wrote:
> Thx
> I had already tried with try catch.. but with out luck.. the documentation
> on camel.apache.org is to be honest.. a little confusing and messed up. When
> looking at the examples it is not always clear enough which version they
> apply to.
Hi

Yeah we hear you. I really do wish that Apache didnt use Confluence
for wiki documentation for its projects.
I would have loved an offline wiki that we have in the SVN with the
source code as well.

Then we could publish documentation for each release that wouldn't intermix.

For what is worth it. There are the manualts that is snapshot of the
wiki when the release was done.
So you can look at the Camel 1.5.0 manual (pdf and html) and you
wouldnt then get bugged with all the new 2.0 updates in the wiki.

But you found the camel community and we are here to help.

You can also find us at IRC
http://camel.apache.org/irc-room.html

>
> here is how i did in case some other newbie would like to know. (valid for
> Camel 1.5.0)
>
>  <camelContext id="file-pump" xmlns="
> http://activemq.apache.org/camel/schema/spring">
>    <route>
>      <from uri="file://files-to-upload?consumer.delay=60000"/>
>      <try>
>        <to uri="ftp://camel@localhost?password=camel"/>
>        <catch>
>          <exception>java.lang.Exception</exception>
>          <to uri="file://todo"/>
>        </catch>
>      </try>
> </route>
> </camelContext>
>
>
> cheers,
> Peter
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Hot to write a Simple FTP producer with errorhandling

Posted by Peter Thygesen <pe...@gmail.com>.
Thx
I had already tried with try catch.. but with out luck.. the documentation
on camel.apache.org is to be honest.. a little confusing and messed up. When
looking at the examples it is not always clear enough which version they
apply to.

here is how i did in case some other newbie would like to know. (valid for
Camel 1.5.0)

  <camelContext id="file-pump" xmlns="
http://activemq.apache.org/camel/schema/spring">
    <route>
      <from uri="file://files-to-upload?consumer.delay=60000"/>
      <try>
        <to uri="ftp://camel@localhost?password=camel"/>
        <catch>
          <exception>java.lang.Exception</exception>
          <to uri="file://todo"/>
        </catch>
      </try>
</route>
</camelContext>


cheers,
Peter

Re: Hot to write a Simple FTP producer with errorhandling

Posted by Ashwin Karpe <as...@progress.com>.
Hi,

Please check out the thread below to get resolution to your problem.

http://www.nabble.com/Error-Handling-td23493625.html
http://www.nabble.com/Error-Handling-td23493625.html 

In this thread Claus has put forth the challenges and workarounds to address
this issue.

Cheers,

Ashwin...

Peter Thygesen-2 wrote:
> 
> I writing a simple route that uploads files put in a folder.
> 
> 
> 
> Configuration: running camel on ApacheMQ 5.2.0
> 
> 
> 
> (camel part of activemq.xml) nothing fancy..
> 
> <camelContext id="cision-file-channel" xmlns="
> http://activemq.apache.org/camel/schema/spring">
> 
>   <route>
> 
>       <from
> uri="file://files-to-upload?consumer.delay=60000<file:///\\files-to-upload?consumer.delay=60000>
> "/>
> 
>       <to uri="ftp://camel@localhost?password=camel"/>
> 
>   </route>
> 
> </camelContext>
> 
> 
> 
> This works “fine” when the FTP Server is running. When FTP ser is down, it
> retries, then dump the filen on deadletterchannel e.a. the log file. Not
> very useful.
> 
> 
> 
> 1)  How do I make sure it is not dumped in the log file.. pretty much any
> other place would be better. E.g. another folder. Most of all I would like
> it to stay in the upload folder until connection has been reestablished.
> 
> 2)  There is .camel folder in the upload folder. This folder contains the
> files that have been processed. Who and when is this folder cleanup and
> how
> large will it grow?
> 
> 
> 
> Hope you can help out a newbie like me
> 
> 
> 
> BTW
> 
> I fould a posting where you discuss threadsafety and ftp producer
> http://www.nabble.com/Threadsafety-of-Camel-FTP-td23615932.html
> 
> Here you talk about the possibility of making a new uri option for
> concurrent producer. Was this very interesting idea entered in jira?
> 
> 
> 
> Thx Peter
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://www.nabble.com/Hot-to-write-a-Simple-FTP-producer-with-errorhandling-tp23654861p23656861.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Hot to write a Simple FTP producer with errorhandling

Posted by Ashwin Karpe <as...@progress.com>.
Hi,

Please check out the thread below to get resolution to your problem.

http://www.nabble.com/Error-Handling-td23493625.html
http://www.nabble.com/Error-Handling-td23493625.html 

In this thread Claus has put forth the challenges and workarounds to address
this issue.

Cheers,

Ashwin...

Peter Thygesen-2 wrote:
> 
> I writing a simple route that uploads files put in a folder.
> 
> 
> 
> Configuration: running camel on ApacheMQ 5.2.0
> 
> 
> 
> (camel part of activemq.xml) nothing fancy..
> 
> <camelContext id="cision-file-channel" xmlns="
> http://activemq.apache.org/camel/schema/spring">
> 
>   <route>
> 
>       <from
> uri="file://files-to-upload?consumer.delay=60000<file:///\\files-to-upload?consumer.delay=60000>
> "/>
> 
>       <to uri="ftp://camel@localhost?password=camel"/>
> 
>   </route>
> 
> </camelContext>
> 
> 
> 
> This works “fine” when the FTP Server is running. When FTP ser is down, it
> retries, then dump the filen on deadletterchannel e.a. the log file. Not
> very useful.
> 
> 
> 
> 1)  How do I make sure it is not dumped in the log file.. pretty much any
> other place would be better. E.g. another folder. Most of all I would like
> it to stay in the upload folder until connection has been reestablished.
> 
> 2)  There is .camel folder in the upload folder. This folder contains the
> files that have been processed. Who and when is this folder cleanup and
> how
> large will it grow?
> 
> 
> 
> Hope you can help out a newbie like me
> 
> 
> 
> BTW
> 
> I fould a posting where you discuss threadsafety and ftp producer
> http://www.nabble.com/Threadsafety-of-Camel-FTP-td23615932.html
> 
> Here you talk about the possibility of making a new uri option for
> concurrent producer. Was this very interesting idea entered in jira?
> 
> 
> 
> Thx Peter
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://www.nabble.com/Hot-to-write-a-Simple-FTP-producer-with-errorhandling-tp23654861p23656862.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Hot to write a Simple FTP producer with errorhandling

Posted by Peter Thygesen <pe...@gmail.com>.
Thank you. great. I had seen that i could use errorhandler but couldn't get
to work. Glad you showed me. thx.

There was a little typo in the route and a missing camelContext, but I was
able to fix it ;)



2009/5/22 harinair <ha...@hotmail.com>

>
> Peter:
>
> Try this - I do something like this:
>
>     <bean id="errorHandler"
> class="org.apache.camel.builder.DeadLetterChannelBuilder">
>        <property name="defaultDeadLetterEndpointUri"
> value="file:whereEverYouWant" />
>        <property name="redeliveryPolicy" ref="redeliveryPolicy" />
>    </bean>
>
>    <bean id="redeliveryPolicy"
> class="org.apache.camel.processor.RedeliveryPolicy">
>        <property name="initialRedeliveryDelay" value="300" />
>        <property name="maximumRedeliveryDelay" value="8000" />
>        <property name="backOffMultiplier" value="2" />
>        <property name="maximumRedeliveries" value="5" />
>        <property name="useExponentialBackOff" value="true" />
>    </bean>
>
>   <route errorHandlerRef="errorHandler">
>       <from
>
> uri="file://files-to-upload?consumer.delay=60000<file:///\\files-to-upload?consumer.delay=60000"/>
>        <to uri="ftp://camel@localhost?password=camel"/>
>   </route>
>
>
> Regards,
> Hari Gangadharan
> Architect, Globalstar / SPOT
> http://www.harinair.com
>
>
>
> Peter Thygesen-2 wrote:
> >
> > I writing a simple route that uploads files put in a folder.
> >
> >
> >
> > Configuration: running camel on ApacheMQ 5.2.0
> >
> >
> >
> > (camel part of activemq.xml) nothing fancy..
> >
> > <camelContext id="cision-file-channel" xmlns="
> > http://activemq.apache.org/camel/schema/spring">
> >
> >   <route>
> >
> >       <from
> >
> uri="file://files-to-upload?consumer.delay=60000<file:///\\files-to-upload?consumer.delay=60000>
> > "/>
> >
> >       <to uri="ftp://camel@localhost?password=camel"/>
> >
> >   </route>
> >
> > </camelContext>
> >
> >
> >
> > This works “fine” when the FTP Server is running. When FTP ser is down,
> it
> > retries, then dump the filen on deadletterchannel e.a. the log file. Not
> > very useful.
> >
> >
> >
> > 1)  How do I make sure it is not dumped in the log file.. pretty much any
> > other place would be better. E.g. another folder. Most of all I would
> like
> > it to stay in the upload folder until connection has been reestablished.
> >
> > 2)  There is .camel folder in the upload folder. This folder contains the
> > files that have been processed. Who and when is this folder cleanup and
> > how
> > large will it grow?
> >
> >
> >
> > Hope you can help out a newbie like me
> >
> >
> >
> > BTW
> >
> > I fould a posting where you discuss threadsafety and ftp producer
> > http://www.nabble.com/Threadsafety-of-Camel-FTP-td23615932.html
> >
> > Here you talk about the possibility of making a new uri option for
> > concurrent producer. Was this very interesting idea entered in jira?
> >
> >
> >
> > Thx Peter
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Hot-to-write-a-Simple-FTP-producer-with-errorhandling-tp23654861p23661794.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: Hot to write a Simple FTP producer with errorhandling

Posted by harinair <ha...@hotmail.com>.
Peter:

Try this - I do something like this:

     <bean id="errorHandler"
class="org.apache.camel.builder.DeadLetterChannelBuilder">
        <property name="defaultDeadLetterEndpointUri"
value="file:whereEverYouWant" />
        <property name="redeliveryPolicy" ref="redeliveryPolicy" />
    </bean>
    
    <bean id="redeliveryPolicy"
class="org.apache.camel.processor.RedeliveryPolicy">
        <property name="initialRedeliveryDelay" value="300" />
        <property name="maximumRedeliveryDelay" value="8000" />
        <property name="backOffMultiplier" value="2" />
        <property name="maximumRedeliveries" value="5" />
        <property name="useExponentialBackOff" value="true" />
    </bean>

   <route errorHandlerRef="errorHandler">
       <from
uri="file://files-to-upload?consumer.delay=60000<file:///\\files-to-upload?consumer.delay=60000"/>
       <to uri="ftp://camel@localhost?password=camel"/>
   </route>


Regards,
Hari Gangadharan
Architect, Globalstar / SPOT
http://www.harinair.com



Peter Thygesen-2 wrote:
> 
> I writing a simple route that uploads files put in a folder.
> 
> 
> 
> Configuration: running camel on ApacheMQ 5.2.0
> 
> 
> 
> (camel part of activemq.xml) nothing fancy..
> 
> <camelContext id="cision-file-channel" xmlns="
> http://activemq.apache.org/camel/schema/spring">
> 
>   <route>
> 
>       <from
> uri="file://files-to-upload?consumer.delay=60000<file:///\\files-to-upload?consumer.delay=60000>
> "/>
> 
>       <to uri="ftp://camel@localhost?password=camel"/>
> 
>   </route>
> 
> </camelContext>
> 
> 
> 
> This works “fine” when the FTP Server is running. When FTP ser is down, it
> retries, then dump the filen on deadletterchannel e.a. the log file. Not
> very useful.
> 
> 
> 
> 1)  How do I make sure it is not dumped in the log file.. pretty much any
> other place would be better. E.g. another folder. Most of all I would like
> it to stay in the upload folder until connection has been reestablished.
> 
> 2)  There is .camel folder in the upload folder. This folder contains the
> files that have been processed. Who and when is this folder cleanup and
> how
> large will it grow?
> 
> 
> 
> Hope you can help out a newbie like me
> 
> 
> 
> BTW
> 
> I fould a posting where you discuss threadsafety and ftp producer
> http://www.nabble.com/Threadsafety-of-Camel-FTP-td23615932.html
> 
> Here you talk about the possibility of making a new uri option for
> concurrent producer. Was this very interesting idea entered in jira?
> 
> 
> 
> Thx Peter
> 
> 

-- 
View this message in context: http://www.nabble.com/Hot-to-write-a-Simple-FTP-producer-with-errorhandling-tp23654861p23661794.html
Sent from the Camel - Users mailing list archive at Nabble.com.