/// <summary> /// Applies the stored ReceiverMessageHandler and ReceiverMessageHandlerOptions to all receivers in /// <see cref="PrivateServiceBusReceivers"/> and <see cref="PublicServiceBusReceivers"/>. /// </summary> protected override void ApplyReceiverMessageHandler() { foreach (SubscriptionClient serviceBusReceiver in PrivateServiceBusReceivers.Values) { serviceBusReceiver .OnMessage ( message => { BusHelper.SetWasPrivateBusUsed(true); ReceiverMessageHandler(message); }, ReceiverMessageHandlerOptions ); } foreach (SubscriptionClient serviceBusReceiver in PublicServiceBusReceivers.Values) { serviceBusReceiver .OnMessage ( message => { BusHelper.SetWasPrivateBusUsed(false); ReceiverMessageHandler(message); }, ReceiverMessageHandlerOptions ); } }
/// <summary> /// Applies the stored ReceiverMessageHandler and ReceiverMessageHandlerOptions to all receivers in /// <see cref="PrivateServiceBusReceivers"/> and <see cref="PublicServiceBusReceivers"/>. /// </summary> protected override void ApplyReceiverMessageHandler() { foreach (IMessageReceiver serviceBusReceiver in PrivateServiceBusReceivers.Values) { #if NET452 serviceBusReceiver .OnMessage ( message => { BusHelper.SetWasPrivateBusUsed(true); ReceiverMessageHandler(message); }, ReceiverMessageHandlerOptions ); #endif #if NETSTANDARD2_0 serviceBusReceiver .RegisterMessageHandler ( (message, cancellationToken) => { return(Task.Factory.StartNewSafely(() => { BusHelper.SetWasPrivateBusUsed(true); ReceiverMessageHandler(serviceBusReceiver, message); })); }, ReceiverMessageHandlerOptions ); #endif } foreach (IMessageReceiver serviceBusReceiver in PublicServiceBusReceivers.Values) { #if NET452 serviceBusReceiver .OnMessage ( message => { BusHelper.SetWasPrivateBusUsed(false); ReceiverMessageHandler(message); }, ReceiverMessageHandlerOptions ); #endif #if NETSTANDARD2_0 serviceBusReceiver .RegisterMessageHandler ( (message, cancellationToken) => { return(Task.Factory.StartNewSafely(() => { BusHelper.SetWasPrivateBusUsed(false); ReceiverMessageHandler(serviceBusReceiver, message); })); }, ReceiverMessageHandlerOptions ); #endif } }