Dam, too early to say I´m done... :(

Requirerment changed, and now I have a new issue. I needed to change the
polling interval from delay property to a quartz job like this:

<bean class="org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy"
id="startPolicy">
        <property name="routeStartTime" value="* 0 1 * * ?"/>
</bean>

<bean id="customPollStrategy"
class="my.package.CustomPollingConsumerPollStrategy"/>

<camel:route autoStartup="false" routePolicyRef="startPolicy">
        <from uri="file:/my/dir?pollStrategy=#customPollStrategy"/>
<camel:route/>

The problem I am facing now is that my quartz job is ignored after the first
execution, and the execution interval is changed to the default of the file
endpoint.

Here is my poll strategy class:

public class CustomPollingConsumerPollStrategy implements
PollingConsumerPollStrategy{

        @Override
        public boolean begin(Consumer consumer, Endpoint endpoint) {
                return true;
        }

        @Override
        public void commit(Consumer consumer, Endpoint endpoint, int
filesProcessed) {
                if(filesProcessed == 0){
                        throw new RuntimeException("The file was not received 
in the expected
date and time");
                }
        }

        @Override
        public boolean rollback(Consumer consumer, Endpoint consumerEndopint, 
int
retryCounter,   Exception exception) throws Exception {
                Map<String, Object> headers = new HashMap<String, Object>();
                headers.put("customHeader", "customHeader");
                
                CamelContext context = new DefaultCamelContext();
                ProducerTemplate template = context.createProducerTemplate();
                template.sendBodyAndHeaders("vm:failure", 
exception.getMessage(),
headers);
                return false;
        }
}

What am I missing now?

Thanks again,
Bruno.

--
View this message in context: 
http://camel.465427.n5.nabble.com/File2-endpoint-issue-tp5644759p5650374.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to