java - EWS API 中的 OnEvent API 在接收收件箱中的每封电子邮件时侦听两次
问题描述
我正在创建一个新的 API,它将使用 onEvent 通知方法读取电子邮件,我会将邮件发送到另一封电子邮件。在将邮件发送到另一封邮件时,它会被发送两次。
我试图通过将 id 存储在哈希映射中并在第二次在通知方法与 id 匹配时被触发时检查 id 来过滤掉重复项,我不会发送邮件。但这不能正常工作。
我的流媒体通知:
StreamingSubscription subscription = exchangeService.subscribeToStreamingNotification(folder,EventType.NewMail);
StreamingSubscriptionConnection conn = new StreamingSubscriptionConnection(exchangeService,30); conn.addSubscription(subscription );
conn.addNotificationEvent(new StreamingsubscriptionConnection.INotificationEventDelegate())
{ @override
public void notificationEventDelegate(object sender, NotificationEventArgs args){
StreamingSubscription subscription = args.getSubscription();
for(NotificationEvent event : args.getEvents()){
if(event instanceof FolderEvent){
FolderEvent folderEvent = (FolderEvent) event;
} else if (event instanceof ItemEvent){
ItemEvent itemEvent = (ItemEvent) event; } else{ logger.error("Unsupported event" + event.getClass)
}
else{
logger.error("Unsupported event" + event.getClass)
}
解决方案
推荐阅读
- xcode - agvtool 报告“找不到 Foo.xcodeproj/../NO”
- python - 试图将具有不同“花色/颜色”的卡片相互比较
- python - Flask/MongoDB - 当我刷新或与我的网站交互时数据消失
- excel - 用 VBA 插值
- c# - 为操作系统 Cosmos C# 创建安装程序
- arrays - 是否有一个 C 函数,给定具有不同数据类型的结构数组,可以使用任何一种数据类型对数组进行排序
- asp.net-mvc - 如何在 mvc 中为日期设置初始值?
- powerbi - 根据过滤器选择更改矩阵的列名
- ios - Airplay 不能与 Swift 的 AVRoutePicker 一起使用,但可以与 Objective C 一起使用
- r - 使用完整的 NA 填充组,使其长度与最大组相同