C
C#2y ago
Gebz

❔ [Design Problem] Duplication and Concurrency

I have a design issue i need to fix with my application that im building using MailKit and MimeMessage: I created an idle client that will be connecting to an Imap server, upon a new connect it gets all messages received in the inbox, and pushes them to a queue, there's a separate worker thread dequeuing the messages and processing them (parsing them and pushing them to a database). There's a scenario where new messages in the inbox are enqueued to the processing queue, but are not processed in time, then the idle client disconnects. With the current implementation it will try to reconnect, and if the connection is established, it will get all messages and throw them in the queue again resulting in duplicate Messages. I'm not the most experienced software designer and I was hoping someone more seasoned could offer some design advice, maybe my whole design isn't optimal. Link to the repo: https://github.com/alyashraf97/Biohazard
2 Replies
d1ag0n
d1ag0n2y ago
https://stackoverflow.com/a/36849294 Maybe consider a [concurrent]dictionary and use some header from the message as a key.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server