You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by SoaMattH <ma...@netpacket.com.au> on 2009/08/03 03:32:27 UTC

Trying to put a file in a dead letter folder

I have the following camel context.
Every thing works fine for an XML file that is parsed correctly
However if an Exception occures it ends up in the processed folder
rather than in the dead letter folder?

Is there somthing I need to do to stop the processing amd leave the file in
the 
dead letter folder ?? I would tend to think I am just missing a config?

  <!-- =====================================================================
-->
  <!-- Camel Context.                                                       
-->
  <!-- =====================================================================
-->
  <camel:camelContext id="camel">

    <camel:package>
      au.gov.qld.emergency.integration.oms
    </camel:package>
    
    <!-- ===================================================================
-->
    <!-- Default JMX connector url:                                                                                     
-->
    <!--  "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel"                                          
-->
    <!-- ===================================================================
-->
    <camel:jmxAgent id="agent" createConnector="true"/>    
        
    <!-- ===================================================================
-->
    <!-- Enpoints and processes                                                                                         
-->
    <!-- ===================================================================
-->     
    <camel:endpoint  id="incidentFileEndpoint"
uri="file://#{omsws.incident.file.landingzone}/"/>
    
    <camel:dataFormats>
      <camel:jaxb id="incidentJaxb" 
                  prettyPrint="true" 
                  contextPath="com.myco.incident" />
    </camel:dataFormats>
    
    <camel:route>
      <camel:from uri="incidentFileEndpoint"></camel:from>  
      <camel:doTry>
          <camel:unmarshal ref="incidentJaxb" />
          <camel:to uri="bean:incidentReciverFile?method=processIncident" />
        <camel:doCatch>
          <camel:exception>java.lang.Exception</camel:exception>
          <camel:to uri="file://#{omsws.incident.file.deadletter}/"/>   
        </camel:doCatch>
      </camel:doTry>   
    </camel:route>   
  </camel:camelContext>


Thanks Matt
-- 
View this message in context: http://www.nabble.com/Trying-to-put-a-file-in-a-dead-letter-folder-tp24783883p24783883.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Trying to put a file in a dead letter folder

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I think you need to use <from ref="incidentFileEndpoint"/> to indicate
a REFERENCE to an endpoint instead of using uri.


On Mon, Aug 3, 2009 at 3:32 AM, SoaMattH<ma...@netpacket.com.au> wrote:
>
> I have the following camel context.
> Every thing works fine for an XML file that is parsed correctly
> However if an Exception occures it ends up in the processed folder
> rather than in the dead letter folder?
>
> Is there somthing I need to do to stop the processing amd leave the file in
> the
> dead letter folder ?? I would tend to think I am just missing a config?
>
>  <!-- =====================================================================
> -->
>  <!-- Camel Context.
> -->
>  <!-- =====================================================================
> -->
>  <camel:camelContext id="camel">
>
>    <camel:package>
>      au.gov.qld.emergency.integration.oms
>    </camel:package>
>
>    <!-- ===================================================================
> -->
>    <!-- Default JMX connector url:
> -->
>    <!--  "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel"
> -->
>    <!-- ===================================================================
> -->
>    <camel:jmxAgent id="agent" createConnector="true"/>
>
>    <!-- ===================================================================
> -->
>    <!-- Enpoints and processes
> -->
>    <!-- ===================================================================
> -->
>    <camel:endpoint  id="incidentFileEndpoint"
> uri="file://#{omsws.incident.file.landingzone}/"/>
>
>    <camel:dataFormats>
>      <camel:jaxb id="incidentJaxb"
>                  prettyPrint="true"
>                  contextPath="com.myco.incident" />
>    </camel:dataFormats>
>
>    <camel:route>
>      <camel:from uri="incidentFileEndpoint"></camel:from>
>      <camel:doTry>
>          <camel:unmarshal ref="incidentJaxb" />
>          <camel:to uri="bean:incidentReciverFile?method=processIncident" />
>        <camel:doCatch>
>          <camel:exception>java.lang.Exception</camel:exception>
>          <camel:to uri="file://#{omsws.incident.file.deadletter}/"/>
>        </camel:doCatch>
>      </camel:doTry>
>    </camel:route>
>  </camel:camelContext>
>
>
> Thanks Matt
> --
> View this message in context: http://www.nabble.com/Trying-to-put-a-file-in-a-dead-letter-folder-tp24783883p24783883.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

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

Re: Trying to put a file in a dead letter folder

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 3, 2009 at 2:19 PM, SoaMattH<ma...@netpacket.com.au> wrote:
>
>
> Your right it should be:
> <camel:from ref="incidentFileEndpoint"></camel:from>
>
> I have changed it from ure to ref,
> However when I test a poorly formed XML file the unmarshal
> throws an exception but the file ends up in the .camel/
> processed directory rather than the deadletter/ directory?

Yes that is because you use doTry .. doCatch that works just as try ..
catch in regular Java. So you handle the exception locally in the
doCatch block.
So even if you route the message to your own deal letter destination
in the doCatch block Camel will afterwards think the file was
processed with success and move the file to .camel sub folder as its
done OK.


You should just remove all the doTry .. doCatch and then rely on the
Dead Letter Channel to move failed files to a dead letter destination
instead.

See more at:
http://camel.apache.org/error-handling-in-camel.html
http://camel.apache.org/dead-letter-channel.html

And this for how to configure it in spring XML that you use
http://camel.apache.org/error-handler.html





>
> Ny clues
>
>
>
>
> SoaMattH wrote:
>>
>>
>> I am Using Camel 2.0M3 in a spring Web application.
>>
>> I have the following camel context.
>> Every thing works fine for an XML file that is parsed correctly
>> However if an Exception occures it ends up in the processed folder
>> rather than in the dead letter folder?
>>
>> Is there somthing I need to do to stop the processing amd leave the file
>> in the
>> dead letter folder ?? I would tend to think I am just missing a config?
>>
>>   <!--
>> ===================================================================== -->
>>   <!-- Camel Context.
>> -->
>>   <!--
>> ===================================================================== -->
>>   <camel:camelContext id="camel">
>>
>>     <camel:package>
>>       au.gov.qld.emergency.integration.oms
>>     </camel:package>
>>
>>     <!--
>> =================================================================== -->
>>     <!-- Default JMX connector url:
>> -->
>>     <!--  "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel"
>> -->
>>     <!--
>> =================================================================== -->
>>     <camel:jmxAgent id="agent" createConnector="true"/>
>>
>>     <!--
>> =================================================================== -->
>>     <!-- Enpoints and processes
>> -->
>>     <!--
>> =================================================================== -->
>>     <camel:endpoint  id="incidentFileEndpoint"
>> uri="file://#{omsws.incident.file.landingzone}/"/>
>>
>>     <camel:dataFormats>
>>       <camel:jaxb id="incidentJaxb"
>>                   prettyPrint="true"
>>                   contextPath="com.myco.incident" />
>>     </camel:dataFormats>
>>
>>     <camel:route>
>>       <camel:from uri="incidentFileEndpoint"></camel:from>
>>       <camel:doTry>
>>           <camel:unmarshal ref="incidentJaxb" />
>>           <camel:to uri="bean:incidentReciverFile?method=processIncident"
>> />
>>         <camel:doCatch>
>>           <camel:exception>java.lang.Exception</camel:exception>
>>           <camel:to uri="file://#{omsws.incident.file.deadletter}/"/>
>>         </camel:doCatch>
>>       </camel:doTry>
>>     </camel:route>
>>   </camel:camelContext>
>>
>>
>> Thanks Matt
>>
>
> --
> View this message in context: http://www.nabble.com/Trying-to-put-a-file-in-a-dead-letter-folder-tp24783883p24789795.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

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

Re: Trying to put a file in a dead letter folder

Posted by SoaMattH <ma...@netpacket.com.au>.

Your right it should be:
<camel:from ref="incidentFileEndpoint"></camel:from>  

I have changed it from ure to ref,
However when I test a poorly formed XML file the unmarshal 
throws an exception but the file ends up in the .camel/ 
processed directory rather than the deadletter/ directory?

Ny clues




SoaMattH wrote:
> 
> 
> I am Using Camel 2.0M3 in a spring Web application.
> 
> I have the following camel context.
> Every thing works fine for an XML file that is parsed correctly
> However if an Exception occures it ends up in the processed folder
> rather than in the dead letter folder?
> 
> Is there somthing I need to do to stop the processing amd leave the file
> in the 
> dead letter folder ?? I would tend to think I am just missing a config?
> 
>   <!--
> ===================================================================== -->
>   <!-- Camel Context.                                                       
> -->
>   <!--
> ===================================================================== -->
>   <camel:camelContext id="camel">
> 
>     <camel:package>
>       au.gov.qld.emergency.integration.oms
>     </camel:package>
>     
>     <!--
> =================================================================== -->
>     <!-- Default JMX connector url:                                                                                     
> -->
>     <!--  "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel"                                          
> -->
>     <!--
> =================================================================== -->
>     <camel:jmxAgent id="agent" createConnector="true"/>    
>         
>     <!--
> =================================================================== -->
>     <!-- Enpoints and processes                                                                                         
> -->
>     <!--
> =================================================================== -->     
>     <camel:endpoint  id="incidentFileEndpoint"
> uri="file://#{omsws.incident.file.landingzone}/"/>
>     
>     <camel:dataFormats>
>       <camel:jaxb id="incidentJaxb" 
>                   prettyPrint="true" 
>                   contextPath="com.myco.incident" />
>     </camel:dataFormats>
>     
>     <camel:route>
>       <camel:from uri="incidentFileEndpoint"></camel:from>  
>       <camel:doTry>
>           <camel:unmarshal ref="incidentJaxb" />
>           <camel:to uri="bean:incidentReciverFile?method=processIncident"
> />
>         <camel:doCatch>
>           <camel:exception>java.lang.Exception</camel:exception>
>           <camel:to uri="file://#{omsws.incident.file.deadletter}/"/>   
>         </camel:doCatch>
>       </camel:doTry>   
>     </camel:route>   
>   </camel:camelContext>
> 
> 
> Thanks Matt
> 

-- 
View this message in context: http://www.nabble.com/Trying-to-put-a-file-in-a-dead-letter-folder-tp24783883p24789795.html
Sent from the Camel - Users mailing list archive at Nabble.com.