camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: File Component Changes In Camel 2.0-M2
Date Thu, 16 Jul 2009 08:20:12 GMT
On Thu, Jul 16, 2009 at 10:16 AM, Carlo Camerino<carloc@sxchange.com.ph> wrote:
> hi,
>
> i've also noticed this behavior change, when I encounter an error for an
> example ina  certgain part of the code and encounter an exception. The file
> still remains in the directory and the file will bde processed all over
> again.
>
> Does delete=true still work in this scenario?
No Camel will only delete the file if it was processed OK.

You do not want to "loose messages". If there is an error or the likes
use Camel error handling to handle
it in case you can and then the file can be deleted.
http://camel.apache.org/error-handling-in-camel.html



>
> Thanks
>
> On Thu, Jul 16, 2009 at 3:59 PM, Carlo Camerino <carloc@sxchange.com.ph>wrote:
>
>> i removed the annotations but still didn't work.
>>
>> it finally worked when I added a routebuilderref.
>>
>> thanks for the help!!!
>>
>>
>> On Thu, Jul 16, 2009 at 3:52 PM, Claus Ibsen <claus.ibsen@gmail.com>wrote:
>>
>>> Hi
>>>
>>> If you are using some annotations in your route classes then Spring
>>> might not be able to IoC them properly and just ignore these files.
>>> Has been improved in later code, eg 2.0m3 or SNAPSHOT.
>>>
>>> So try not having annotations in them.
>>>
>>> And you can also use a <routeBuilderRef> to refer to the route class
>>> directly without the classpath scanner.
>>>
>>>
>>> On Thu, Jul 16, 2009 at 9:49 AM, Carlo Camerino<carloc@sxchange.com.ph>
>>> wrote:
>>> > are my routes being picked up properly?
>>> >
>>> > here is the output of debug log in camel.
>>> >
>>> > INFO  - DefaultCamelContext        - JMX enabled. Using
>>> > InstrumentationLifecycleStrategy.
>>> > INFO  - CamelContextFactoryBean    - JMXAgent disabled
>>> > DEBUG - CamelContextFactoryBean    - Found JAXB created routes: []
>>> > DEBUG - ltPackageScanClassResolver - Searching for implementations of
>>> > org.apache.camel.Routes in packages: [com.ccti.carnelian.ufm.routes]
>>> > DEBUG - ltPackageScanClassResolver - Loading from directory:
>>> >
>>> C:\PROJECTS\CHINABANK\cbc-carnelian\carnelian-parent\carnelian-ufm\target\classes\com\ccti\carnelian\ufm\routes
>>> > DEBUG - ltPackageScanClassResolver - Found: [class
>>> > com.ccti.carnelian.ufm.routes.FileRouteBuilder, class
>>> > com.ccti.carnelian.ufm.routes.QueueRouteBuilder]
>>> > Hibernate: update TBL_USER set IS_LOGIN=0
>>> > DEBUG - SpringCamelContext         - Publishing spring-event:
>>> >
>>> org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.web.context.support.XmlWebApplicationContext@1b17d49
>>> :
>>> > display name [Root WebApplicationContext]; startup date [Thu Jul 16
>>> 15:46:19
>>> > SGT 2009]; root of context hierarchy]
>>> > DEBUG - SpringCamelContext         - Starting the CamelContext now that
>>> the
>>> > ApplicationContext has started
>>> > INFO  - DefaultCamelContext        - Apache Camel 2.0-M2
>>> > (CamelContext:camelContext) is starting
>>> > DEBUG - DefaultProducerServicePool - Starting service pool:
>>> > org.apache.camel.impl.DefaultProducerServicePool@14c0761
>>> > DEBUG - DefaultCamelContext        - StreamCaching is enabled
>>> > DEBUG - DefaultComponent           - Creating endpoint
>>> > uri=[spring-event:default], path=[default], parameters=[{}]
>>> > DEBUG - DefaultCamelContext        - spring-event:default converted
to
>>> > endpoint: Endpoint[spring-event:default] by component:
>>> > org.apache.camel.component.event.EventComponent@1ca32f7
>>> > DEBUG - DefaultProducerServicePool - Stopping service pool:
>>> > org.apache.camel.impl.DefaultProducerServicePool@14c0761
>>> > INFO  - DefaultCamelContext        - Apache Camel 2.0-M2
>>> > (CamelContext:camelContext) started
>>> >
>>> > i'll paste trace log also
>>> >
>>> > On Thu, Jul 16, 2009 at 3:47 PM, Claus Ibsen <claus.ibsen@gmail.com>
>>> wrote:
>>> >
>>> >> Hi
>>> >>
>>> >> Is there any files to pickup? And Camel will also not read the file
if
>>> >> it cannot get a read lock on the file.
>>> >> Maybe the file is locked if you got it open in another program. So
>>> >> safe to drop in a file that you copy from somewhere else.
>>> >>
>>> >> And some user had trouble with MS Office files being locked on Windows.
>>> >>
>>> >> You can also skip this locking by setting readLock=none
>>> >>
>>> >> And enable TRACE logging at org.apache.camel.component.file to see what
>>> it
>>> >> says.
>>> >>
>>> >>
>>> >>
>>> >> On Thu, Jul 16, 2009 at 9:32 AM, Carlo Camerino<carloc@sxchange.com.ph
>>> >
>>> >> wrote:
>>> >> > hmm there's no camel locks in there.
>>> >> > i deleted the directoyr, recreated it still doesn't work.
>>> >> >
>>> >> > here's my files
>>> >> >
>>> >> > package com.ccti.carnelian.ufm.routes;
>>> >> >
>>> >> > import java.io.File;
>>> >> >
>>> >> > import org.apache.camel.Exchange;
>>> >> > import org.apache.camel.Processor;
>>> >> > import org.apache.camel.builder.RouteBuilder;
>>> >> > import org.apache.camel.impl.DefaultMessage;
>>> >> > import org.apache.commons.io.FileUtils;
>>> >> > import org.slf4j.Logger;
>>> >> > import org.slf4j.LoggerFactory;
>>> >> >
>>> >> > import com.ccti.base.camel.model.FileModel;
>>> >> > import com.ccti.base.camel.processors.FileWaitProcessor;
>>> >> > import com.ccti.base.dao.syspar.SysParDao;
>>> >> >
>>> >> > public class FileRouteBuilder extends RouteBuilder {
>>> >> >    private static final Logger logger =
>>> >> > LoggerFactory.getLogger(FileRouteBuilder.class);
>>> >> >    private SysParDao sysParDao;
>>> >> >
>>> >> >    @Override
>>> >> >    public void configure() throws Exception {
>>> >> >            from("file:" + "c:/ufm/upload/" ).process(new
>>> >> > FileWaitProcessor()).process(new Processor() {
>>> >> >
>>> >> >                public void process(Exchange exchange) throws
>>> Exception {
>>> >> >                    try {
>>> >> >                        FileModel fileModel = new FileModel();
>>> >> >                        logExchangeDetails(exchange);
>>> >> >                        // kailangan ko ipa write ito
sa isang
>>> directory
>>> >> >                        logger.debug("Making A copy
Of File In
>>> Processed
>>> >> > Directory.");
>>> >> >                        String processedDirectory =
>>> >> > sysParDao.findValueByCd("USR082");
>>> >> >                        String inputDirectory =
>>> >> > sysParDao.findValueByCd("USR081");
>>> >> >                        FileUtils.copyFile(new File(inputDirectory
+
>>> >> > exchange.getIn().getHeader("org.apache.camel.file.name")), new
>>> >> > File(processedDirectory + exchange.getIn().getHeader("
>>> >> > org.apache.camel.file.name") + "-USED"));
>>> >> >                        DefaultMessage defaultMessage
= new
>>> >> > DefaultMessage();
>>> >> >                        fileModel.setFileName(processedDirectory
+
>>> >> > exchange.getIn().getHeader("org.apache.camel.file.name").toString()
>>> +
>>> >> > "-USED");
>>> >> >
>>> >>  fileModel.setCoverName(exchange.getIn().getHeader("
>>> >> > org.apache.camel.file.name").toString());
>>> >> >                        defaultMessage.setBody(fileModel);
>>> >> >                        exchange.setOut(defaultMessage);
>>> >> >                        logger.debug("Successfuly Copied
File.");
>>> >> >                    }
>>> >> >                    catch (Exception e) {
>>> >> >                        logger.error(e.getMessage());
>>> >> >                        e.printStackTrace();
>>> >> >                    }
>>> >> >                }
>>> >> >
>>> >> >                private void logExchangeDetails(Exchange
exchange) {
>>> >> >                    if(logger.isDebugEnabled()) {
>>> >> >                        logger.debug(exchange.getIn()
+ "");
>>> >> >
>>> >>  logger.debug(exchange.getIn().getClass().getName());
>>> >> >                        logger.debug(exchange.getIn().getHeader("
>>> >> > org.apache.camel.file.name").toString());
>>> >> >                        logger.debug(exchange.getOut()
+ "");
>>> >> >                    }
>>> >> >                }
>>> >> >
>>> >> >            }).to("direct:processingQueue");
>>> >> >
>>> >> >    }
>>> >> >
>>> >> >    public SysParDao getSysParDao() {
>>> >> >        return sysParDao;
>>> >> >    }
>>> >> >
>>> >> >    public void setSysParDao(SysParDao sysParDao) {
>>> >> >        this.sysParDao = sysParDao;
>>> >> >    }
>>> >> > }
>>> >> >
>>> >> > <?xml version = "1.0" encoding = "UTF-8"?>
>>> >> > <beans xmlns="http://www.springframework.org/schema/beans"
>>> >> >    xmlns:amq="http://activemq.apache.org/schema/core"
>>> >> >    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> >> >    xmlns:jms="http://www.springframework.org/schema/jms"
>>> >> >    xmlns:tx="http://www.springframework.org/schema/tx"
>>> >> >    xmlns:camel="http://camel.apache.org/schema/spring"
>>> >> >    xsi:schemaLocation="http://www.springframework.org/schema/beans
>>> >> > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>>> >> >  http://activemq.apache.org/schema/core
>>> >> > http://activemq.apache.org/schema/core/activemq-core.xsd
>>> >> >  http://www.springframework.org/schema/jms
>>> >> > http://www.springframework.org/schema/jms/spring-jms-2.5.xsd
>>> >> >  http://www.springframework.org/schema/tx
>>> >> > http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
>>> >> >  http://camel.apache.org/schema/spring
>>> >> > http://camel.apache.org/schema/spring/camel-spring.xsd
>>> >> >  ">
>>> >> >
>>> >> >    <camel:camelContext id="camelContext">
>>> >> >        <camel:package>com.ccti.carnelian.ufm.routes</camel:package>
>>> >> >        <camel:jmxAgent id = "agent" disabled="true"/>
>>> >> >    </camel:camelContext>
>>> >> >
>>> >> > I will be insvesitigating also. maybe it's just a simple mistake
or
>>> >> > something
>>> >> >
>>> >> > On Thu, Jul 16, 2009 at 2:33 PM, Claus Ibsen <claus.ibsen@gmail.com>
>>> >> wrote:
>>> >> >
>>> >> >> On Thu, Jul 16, 2009 at 8:29 AM, Carlo Camerino<
>>> carloc@sxchange.com.ph>
>>> >> >> wrote:
>>> >> >> > it doesn't even enter the filewaitprocessor
>>> >> >>
>>> >> >> Could you take a look into the c:/ufm/upload folder. There
could be
>>> >> >> some .camelLock file lurking that blocks it.
>>> >> >> eg you can try removing this folder all together and create
a new
>>> empty
>>> >> >> one.
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> >
>>> >> >> > On Thu, Jul 16, 2009 at 2:26 PM, Carlo Camerino <
>>> >> carloc@sxchange.com.ph
>>> >> >> >wrote:
>>> >> >> >
>>> >> >> >> Hi,
>>> >> >> >>
>>> >> >> >> Here is my route.
>>> >> >> >>
>>> >> >> >> public void configure() throws Exception {
>>> >> >> >>             from("file://" + "c:/ufm/upload/"
+
>>> >> >> "?delete=true").process(new
>>> >> >> >> FileWaitProcessor()).process(new Processor() {
>>> >> >> >>
>>> >> >> >>                 public void process(Exchange
exchange) throws
>>> >> Exception
>>> >> >> {
>>> >> >> >>                     try {
>>> >> >> >>                         FileModel fileModel
= new FileModel();
>>> >> >> >>                         logExchangeDetails(exchange);
>>> >> >> >>                         // kailangan ko
ipa write ito sa isang
>>> >> directory
>>> >> >> >>                         logger.debug("Making
A copy Of File In
>>> >> Processed
>>> >> >> >> Directory.");
>>> >> >> >>                         String processedDirectory
=
>>> >> >> >> sysParDao.findValueByCd("USR082");
>>> >> >> >>                         String inputDirectory
=
>>> >> >> >> sysParDao.findValueByCd("USR081");
>>> >> >> >>                         FileUtils.copyFile(new
>>> File(inputDirectory +
>>> >> >> >> exchange.getIn().getHeader("org.apache.camel.file.name")),
new
>>> >> >> >> File(processedDirectory + exchange.getIn().getHeader("
>>> >> >> >> org.apache.camel.file.name") + "-USED"));
>>> >> >> >>                         DefaultMessage
defaultMessage = new
>>> >> >> >> DefaultMessage();
>>> >> >> >>                         fileModel.setFileName(processedDirectory
>>> +
>>> >> >> >> exchange.getIn().getHeader("org.apache.camel.file.name
>>> ").toString()
>>> >> +
>>> >> >> >> "-USED");
>>> >> >> >>
>>> >> >> fileModel.setCoverName(exchange.getIn().getHeader("
>>> >> >> >> org.apache.camel.file.name").toString());
>>> >> >> >>                         defaultMessage.setBody(fileModel);
>>> >> >> >>                         exchange.setOut(defaultMessage);
>>> >> >> >>                         logger.debug("Successfuly
Copied File.");
>>> >> >> >>                     }
>>> >> >> >>                     catch (Exception e)
{
>>> >> >> >>                         logger.error(e.getMessage());
>>> >> >> >>                         e.printStackTrace();
>>> >> >> >>                     }
>>> >> >> >>                 }
>>> >> >> >>
>>> >> >> >>                 private void logExchangeDetails(Exchange
>>> exchange) {
>>> >> >> >>                     if(logger.isDebugEnabled())
{
>>> >> >> >>                         logger.debug(exchange.getIn()
+ "");
>>> >> >> >>
>>> >> >> >> logger.debug(exchange.getIn().getClass().getName());
>>> >> >> >>                         logger.debug(exchange.getIn().getHeader("
>>> >> >> >> org.apache.camel.file.name").toString());
>>> >> >> >>                         logger.debug(exchange.getOut()
+ "");
>>> >> >> >>                     }
>>> >> >> >>                 }
>>> >> >> >>
>>> >> >> >>             }).to("direct:processingQueue");
>>> >> >> >>
>>> >> >> >> Thanks In Advance
>>> >> >> >>
>>> >> >> >>
>>> >> >> >> On Thu, Jul 16, 2009 at 1:02 PM, Claus Ibsen <
>>> claus.ibsen@gmail.com
>>> >> >> >wrote:
>>> >> >> >>
>>> >> >> >>> Hi
>>> >> >> >>>
>>> >> >> >>> On Thu, Jul 16, 2009 at 6:29 AM, Carlo Camerino<
>>> >> >> carlo.camerino@gmail.com>
>>> >> >> >>> wrote:
>>> >> >> >>> > hi,
>>> >> >> >>> >
>>> >> >> >>> > i'm currently using file component in camel
2.0-M2. I'm
>>> finding
>>> >> out
>>> >> >> that
>>> >> >> >>> > it's not working properly already unlike
in camel 1.6 below.
>>> >> >> >>> > is there any changes that I need to be implemented?
>>> >> >> >>> >
>>> >> >> >>> > The same route that I used for Camel 1.5
is not working for
>>> camel
>>> >> >> 2.0-M2
>>> >> >> >>>
>>> >> >> >>> Camel 2 have a rewritten file component so some
options in 1.5
>>> is eg
>>> >> >> >>> not the same in 2.0.
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>> >
>>> >> >> >>> > It's not getting properly from the directory
that I set it to
>>> get
>>> >> >> from.
>>> >> >> >>> > Do I need to change anything?
>>> >> >> >>>
>>> >> >> >>> First you need to post what the problem is. Writing
that X does
>>> not
>>> >> >> >>> work is not gonna help to much without
>>> >> >> >>> being more specific.
>>> >> >> >>>
>>> >> >> >>> And also posting your route will help.
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>> >
>>> >> >> >>> > Should I use file2 instead?
>>> >> >> >>> >
>>> >> >> >>>
>>> >> >> >>> No there is no file2 as such. Its just the camel
documentation
>>> being
>>> >> >> >>> divided into the old and the new (file2).
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>> > Carlo
>>> >> >> >>> >
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>> --
>>> >> >> >>> Claus Ibsen
>>> >> >> >>> Apache Camel Committer
>>> >> >> >>>
>>> >> >> >>> Open Source Integration: http://fusesource.com
>>> >> >> >>> Blog: http://davsclaus.blogspot.com/
>>> >> >> >>> Twitter: http://twitter.com/davsclaus
>>> >> >> >>>
>>> >> >> >>
>>> >> >> >>
>>> >> >> >
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> --
>>> >> >> Claus Ibsen
>>> >> >> Apache Camel Committer
>>> >> >>
>>> >> >> Open Source Integration: http://fusesource.com
>>> >> >> Blog: http://davsclaus.blogspot.com/
>>> >> >> Twitter: http://twitter.com/davsclaus
>>> >> >>
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Claus Ibsen
>>> >> Apache Camel Committer
>>> >>
>>> >> Open Source Integration: http://fusesource.com
>>> >> Blog: http://davsclaus.blogspot.com/
>>> >> Twitter: http://twitter.com/davsclaus
>>> >>
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>



-- 
Claus Ibsen
Apache Camel Committer

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

Mime
View raw message