public void SendNotification() { EmailNotificationHandler.Tracer.TraceDebug <string>((long)this.GetHashCode(), "EmailNotificationHandler.SendNotification: Processing notifications for Group {0}.", this.groupMailbox.ExternalDirectoryObjectId); IExtensibleLogger logger = MailboxAssociationDiagnosticsFrameFactory.Default.CreateLogger(this.groupMailbox.ExchangeGuid, this.groupMailbox.OrganizationId); IMailboxAssociationPerformanceTracker performanceTracker = MailboxAssociationDiagnosticsFrameFactory.Default.CreatePerformanceTracker(null); using (MailboxAssociationDiagnosticsFrameFactory.Default.CreateDiagnosticsFrame("EmailNotificationHandler", "SendNotification", logger, performanceTracker)) { GroupMailboxAccessLayerHelper.ExecuteOperationWithRetry(logger, "EmailNotificationHandler.SendNotification", delegate { using (MailboxSession session = MailboxSession.OpenAsTransport(this.exchangePrincipal, this.clientInfoString)) { EmailNotificationHandler.Tracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "EmailNotificationHandler.SendNotification: Created transport session for mailbox {0}. Group {1}.", session.MailboxGuid, this.groupMailbox.ExternalDirectoryObjectId); StoreObjectId draftsFolderId = session.GetDefaultFolderId(DefaultFolderType.Drafts); while (!this.pendingRecipients.IsEmpty) { IMailboxLocator recipient; while (this.pendingRecipients.TryDequeue(out recipient)) { performanceTracker.IncrementAssociationsRead(); GroupMailboxAccessLayerHelper.ExecuteOperationWithRetry(logger, "EmailNotificationHandler.ComposeAndDeliverMessage", delegate { this.ComposeAndDeliverMessage(session, draftsFolderId, recipient, performanceTracker, logger); }, (Exception e) => !(e is StoragePermanentException) && GrayException.IsGrayException(e)); } } } }, new Predicate <Exception>(GrayException.IsGrayException)); } EmailNotificationHandler.Tracer.TraceDebug((long)this.GetHashCode(), "EmailNotificationHandler.SendNotification: Task completed."); }
public void ReplicateQueuedAssociations() { QueuedInProcessAssociationReplicator.Tracer.TraceDebug((long)this.GetHashCode(), "MailboxTaskProcessor.ReplicateQueuedAssociations: Processing associations."); ADUser mailboxAdUser = this.mailbox.FindAdUser(); IDiagnosticsFrameFactory <IExtensibleLogger, IMailboxAssociationPerformanceTracker> diagnosticsFrameFactory = this.diagnosticsFrameFactoryCreator(); IMailboxAssociationPerformanceTracker performanceTracker = diagnosticsFrameFactory.CreatePerformanceTracker(null); IExtensibleLogger logger = diagnosticsFrameFactory.CreateLogger(mailboxAdUser.ExchangeGuid, mailboxAdUser.OrganizationId); IAssociationReplicator replicator = this.immediateReplicatorCreator(logger, performanceTracker); using (MailboxAssociationDiagnosticsFrameFactory.Default.CreateDiagnosticsFrame("QueuedInProcessAssociationReplicator", "ReplicateAssociations", logger, performanceTracker)) { bool inProcessReplicationSucceeded = true; GroupMailboxAccessLayerHelper.ExecuteOperationWithRetry(logger, "QueuedInProcessAssociationReplicator.ReplicateAssociations", delegate { IStoreBuilder storeBuilder = this.storeBuilderCreator(logger, this.clientInfoString); using (IAssociationStore associationStore = storeBuilder.Create(this.mailbox, performanceTracker)) { QueuedInProcessAssociationReplicator.Tracer.TraceDebug <string>((long)this.GetHashCode(), "QueuedInProcessAssociationReplicator.ReplicateAssociationsImplementation: Created store provider. Mailbox={0}.", mailboxAdUser.ExternalDirectoryObjectId); UserAssociationAdaptor masterAdaptor = new UserAssociationAdaptor(associationStore, this.adSession, this.mailbox); while (this.pendingAssociations.Count > 0) { MailboxAssociation association = this.pendingAssociations.Dequeue(); inProcessReplicationSucceeded &= this.ReplicateSingleAssociation(replicator, masterAdaptor, association); } if (!inProcessReplicationSucceeded) { IReplicationAssistantInvoker replicationAssistantInvoker = this.replicationAssistantInvokerCreator(logger, this.replicationServerFqdn); replicationAssistantInvoker.Invoke("QueuedInProcessAssociationReplicatorRpcReplication", masterAdaptor, new MailboxAssociation[0]); } } }, new Predicate <Exception>(GrayException.IsGrayException)); } QueuedInProcessAssociationReplicator.Tracer.TraceDebug((long)this.GetHashCode(), "MailboxTaskProcessor.SendNotificationImplementation: Task completed."); }