Question

I'm a bit new to camel, so please forgive me if this is a stupid question!

In Camel, I have a list of competing consumers against a queue, queue-1. I'd like each consumer to wait 1 hour between attempts to read the queue, but once an hour has passed, each consumer should continuously poll until it receives a message. Once it receives a message, it should process it, and then wait an hour before attempting another read, and so on.

Here's the route I have set up:

from("aws-sqs://queue-1?accessKey=ABC&secretKey=XYZ&maxMessagesPerPoll=1")
    .unmarshal().base64()
    .unmarshal().serialization()
    .throttle(1)
    .timePeriodMillis(TimeUnit.HOUR.toMillis(1))
    .bean(new ProcessorBean())
    .marshal().serialization()
    .marshal().base64()
    .to("aws-sqs://queue-2?accessKey=ABC&secretKey=XYZ");      

It is my understanding that routes execute synchronously (with the exception of specific components designed to work asynchronously). Based on that understanding, I believe this route satisfies those requirements.

Will this do what I want? Why or why not?

Était-ce utile?

La solution

Your route will consumes a message in the queue and then wait for one hour.

If you want to wait an hour and then read a message, look at ScheduledPollConsumer Options (Doc) Some options allow to use scheduler like Quartz2 or Spring based scheduler.

Use the log component if you want to be sure: .to("log:com.mycompany.order?level=DEBUG").

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top