vendredi 22 mai 2015

How do I trigger a subscription error to test recovery on exchange web service

My application uses the EWS API with a Streaming Subscription and everything is working fine and thats a problem for me as i havn't been able to exercise my recovery code for the OnSubscriptionError event.

Here is the code i use to subscribe for streaming notifications

private void SetStreamingNotifications(List<FolderId> folder_ids)
{
    streaming_subscriptions_connection = new StreamingSubscriptionConnection(exchange_service, 30);

    streaming_subscriptions_connection.OnDisconnect += OnDisconnect;
    streaming_subscriptions_connection.OnSubscriptionError += OnSubscriptionError;
    streaming_subscriptions_connection.OnNotificationEvent += OnNotificationEvent;

    foreach (var folder_id in folder_ids)
    {
        StreamingSubscription sub = exchange_service.SubscribeToStreamingNotifications(
            new[] { folder_id },
            EventType.Created,
            EventType.Modified,
            EventType.Deleted,
            EventType.Moved,
            EventType.Copied
        );

        streaming_subscriptions_connection.AddSubscription(sub);
    }

    streaming_subscriptions_connection.Open();
}

private void OnSubscriptionError(object sender, SubscriptionErrorEventArgs args)
{
    /* What exceptions can i expect to find in "args.Exception" */
    /* Can the streaming subscription be recovered or do i need to create a new one? */
}

So my question is how can i trigger a subscription error so i can ensure my code can recover where possible and log / alert when not possible?

If i need to setup and break an exchange server to force subscription errors so be it, but i would prefer not to have to.

Aucun commentaire:

Enregistrer un commentaire