Skip to content

Subscriber Initialise Error Handling Impovement #35

@srpeirce

Description

@srpeirce

If you have code such as:

await subscriber.Initialise(new[] {Assembly.GetExecutingAssembly()}))
await subscriber.ListenForMessages(tokenSource);

And the subscription can't be found, the subscriber will continue to run:

info: Pat.Subscriber.SubscriptionBuilder[0]
      Building subscription 1 on service bus mailmachinegun-ns.servicebus.windows.net/...
crit: Pat.Subscriber.SubscriptionBuilder[0]
      Unable to find servicebus topic 'patAbc123' subscriber will terminate.
info: Pat.Subscriber.AzureServiceBusMessageReceiverFactory[0]
      Adding on subscription client 1 to list of source subscriptions
info: Pat.Subscriber.Subscriber[0]
      Listening for messages...
warn: Pat.Subscriber.BatchProcessing.DefaultBatchProcessingBehaviour[0]
      MessagingCommunicationException was thrown, subscriber will retry to get messages from service bus soon.

The current recommended is:

if (await subscriber.Initialise(new[] {Assembly.GetExecutingAssembly()}))
{
    await subscriber.ListenForMessages(tokenSource);
}

I think that subscriber.Initialise should not return a bool and should throw the Exception if it cannot initialise.
At the moment there are some occasions where it returns false and some where an Exception will be thrown which is confusing, and also leads to ability to make mistakes.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions