I need to implement a custom PollingConsumerPollStrategy
implementation on a route inside a RouteBuilder
. The examples I found use spring to create a bean, but i am not using Spring in my project.
How do i add MyPollStrategy
to registry and use it as pollStrategy=#myPoll ?
public class MyFtpServiceBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
// Want to add to below route &pollStrategy=#myPoll
from("sftp://tmpserver.example.com:22//tmp/testfolder?password=xxxxxx&username=tmpuser")
.routeId("testRoute")
.to("file:C:/tmp/testfolder")
}
private class MyPollStrategy implements PollingConsumerPollStrategy {
public boolean begin(Consumer consumer, Endpoint endpoint) {
return true;
}
public void commit(Consumer consumer, Endpoint endpoint, int polledMessages) {
if (polledMessages > maxPolls) {
maxPolls = polledMessages;
}
latch.countDown();
}
public boolean rollback(Consumer consumer, Endpoint endpoint, int retryCounter, Exception cause) throws Exception {
return false;
}
}
}