电子邮件监控同步 [英] Email Monitor Synchronization

查看:277
本文介绍了电子邮件监控同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个C#程序,使用POP3监控专用的Gmail帐户,用于专门的命令电子邮件,并作出适当的反应。

I'm writing a C# program that monitors a dedicated Gmail account using POP3 for specialized command emails and reacts appropriately.

为了最大可靠性,我将运行此程序在全国各地的几台电脑上。
我目前有一个竞争条件,其中程序的两个实例可以读取相同的消息,其中一个删除它,导致消息被处理两次。

For maximum reliability, I will run this program on several computers throughout the country. I currently have a race condition where two instances of the program can read the same message before one of them deletes it, causing the message to be processed twice.

如何确保每个命令的处理完全一次?

How can I make sure that each command is processed exactly once?

Gmail的POP3访问仅用于服务每个消息一次(使RETR和DELE成为单个原子操作)但是我不能再重现这种行为。

Gmail's POP3 access used to only serve each message once (making RETR and DELE a single atomic operation), but I can no longer reproduce this behavior.

计算机之间通信的唯一方法是SQL Server和HTTP服务器(我控制的)。

The only method of communication between the computers is a SQL Server and an HTTP server (which I control).

推荐答案

我想到的一个选择是使用POP3的UIDL命令,并在SQL Server中有一个UIDL的唯一列,已经被处理了。

One option I've thought of is to use POP3's UIDL command, and have a table in SQL Server with a unique column of UIDLs that were already processed.

然后,在下载每个消息之前,守护进程会将UIDL插入到表中,如果有错误,请跳过该消息。 (我假设SQL Server的INSERT命令是一个原子操作)。

Then, before downloading each message, the daemon would INSERT the UIDL into the table, and, if it got an error, skip the message. (I'm assuming that SQL Server's INSERT command is an atomic operation).

这篇关于电子邮件监控同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆