简体   繁体   中英

How to transfer messages, each at a specific time?

I have about 10K messages in a CSV file. Each message has an associated timestamp for it. When the time is reached, I want the message delivered to an MQ. The timestamps are not uniformly spread. Is this possible with Apache Camel?

As far as I know Apache Camel by default has no consumer endpoint components that you could configure to trigger with specific messages at specified times.

There is however a timer component that you can setup to trigger for example once a second. Then in the route you could use a processor to check if a list contains any messages that should be send at the given time and send them to the MQ.

You could also trigger route from java code using a ProducerTemplate that you can create using the CamelContext.

The list could be populated using your csv file and ordered by timestamp so you could use it like a stack and only check the first few entries instead of going through all 10K every second.

The real problem here would be persistence ie to figure out which of the messages listed on the csv have already been sent if the application closes before all 10K messages have been sent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM