我正在创建一个新的API,它将使用onEvent通知方法读取电子邮件,然后将邮件发送到另一封电子邮件。在将邮件发送到另一封邮件时,它发送了两次。
我试图通过将ID存储在哈希映射中并在ID匹配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)
}