我们通过以下方法订阅 MS Exchange 2016 的流式通知: service.subscribeToStreamingNotificationsOnAllFolders(EventType.Copied,EventType.Created, EventType.Deleted, EventType.Modified, EventType.Moved, EventType.NewMail); switch (itemEvent.getEventType()) { case Deleted: delete(mailbox, itemEvent.getItemId()); break; case Moved: try { delete(mailbox, itemIdNoChangeKey(itemEvent.getOldItemId())); } finally { create(mailbox, Item.bind(service, itemIdNoChangeKey(itemEvent.getItemId()))); } break; case Modified: update(mailbox, Item.bind(service, itemIdNoChangeKey(itemEvent.getItemId()), itemProp())); break; case Copied: case Created: create(mailbox, Item.bind(service, itemIdNoChangeKey(itemEvent.getItemId()), itemProp())); break; }有时上面的调用会成功,但更常见的是,Items.bind() 会失败,并显示以下内容:“访问被拒绝。检查凭据并重试。该过程无法获取正确的属性。,errorCode='ErrorAccessDenied'”或者“在商店中找不到指定的对象。,进程无法获取正确的属性。,errorCode='ErrorItemNotFound'”尽管事实是这样凭据有效,可以成功用于调用 service.findFolders(WellKnownFolderName.MsgFolderRoot,folderView);我们正在使用 Exchange 模拟。已为所有邮箱分配模拟权限。设置锚邮箱:service.getHttpHeaders().put("X-AnchorMailbox",mailbox);设置 X-PreferServerAffinity:service.getHttpHeaders().put("X-PreferServerAffinity", "true");谁能告诉我们为什么我们会收到 ErrorAccessDenied 和 ErrorItemNotFound 错误?是否与 Exchange 系统相关邮件或文件夹的处理有关?我们如何处理这些项目,或者如果不能,如何跳过它们而不会对 Exchange 服务器造成不必要的负载?
1 回答
临摹微笑
TA贡献1982条经验 获得超2个赞
就我而言,我的代码模拟了错误的邮箱。事实证明,我需要维护一张地图,如下所示:
private Map<StreamingSubscription, String> reverseSubscriptions = Collections.synchronizedMap(new HashMap<>());
然后在 notificationEventDelegate(..) 方法中...
称呼
String mailbox = reverseSubscriptions.get(args.getSubscription());
处理项目事件时...
private void processItemEvent(ExchangeService service, String mailbox, ItemEvent itemEvent) throws Exception {
synchronized(service) {
service.setImpersonatedUserId(impersonateAccount(mailbox));
service.getHttpHeaders().put("X-AnchorMailbox", mailbox);
service.getHttpHeaders().put("X-PreferServerAffinity", "true");
try {
...
} catch (Exception ie) {
...
}
}
}
}
添加回答
举报
0/150
提交
取消