java - message queue processing critical time problem
phpcn_u1582
phpcn_u1582 2017-05-17 10:08:07
0
2
565

Now receive messages from the message queue and then write them to the file. Write one every hour, which is a batch write. But there is a problem. Every time a new file is written, there is some data at the beginning that should belong to the previous hour, and the message body has time. How to ensure that all messages are strictly written to your own files. What I think of now is to divide the buffers written in batches by hour, Map<hour,buffer>, one buffer corresponds to one hour, and the file name is generated based on the hour field corresponding to the buffer, so as to ensure that the data in each buffer belongs to itself. document. Is there any other better way?

phpcn_u1582
phpcn_u1582

reply all(2)
黄舟

The file is generated on the hour, and each message has its own timestamp, matching writing

我想大声告诉你

I feel like your problem may be caused by the following reasons:

  1. producer sent the message repeatedly

  2. mq repeatedly sent a message to consumer

  3. The consumer did not inform mq that it had consumed the message one hour ago, so mq sent another message the next hour

Reference:

  1. duplicated-messages-on-activemq

  2. avoiding-duplicated-messages-on-jms-activemq

  3. duplicate-detection

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!