Exemple #1
0
        public async Task <IReceivingRawEndpoint> Start()
        {
            var receiver = CreateReceiver();

            if (receiver != null)
            {
                await InitializeReceiver(receiver).ConfigureAwait(false);
            }

            var runningInstance = new RunningRawEndpointInstance(settings, receiver, transportInfrastructure, dispatcher, SubscriptionManager, localAddress);

            // set the started endpoint on CriticalError to pass the endpoint to the critical error action
            criticalError.SetEndpoint(runningInstance);

            if (receiver != null)
            {
                StartReceiver(receiver);
            }
            return(runningInstance);
        }
Exemple #2
0
        public async Task <IReceivingRawEndpoint> Start()
        {
            if (startHasBeenCalled)
            {
                throw new InvalidOperationException("Multiple calls to Start is not supported.");
            }

            startHasBeenCalled = true;

            var receiver = CreateReceiver();

            if (receiver != null)
            {
                await InitializeReceiver(receiver).ConfigureAwait(false);
            }

            var runningInstance = new RunningRawEndpointInstance(settings, receiver, transportInfrastructure, dispatcher, SubscriptionManager, localAddress);

            // set the started endpoint on CriticalError to pass the endpoint to the critical error action
            criticalError.SetEndpoint(runningInstance);

            try
            {
                if (receiver != null)
                {
                    StartReceiver(receiver);
                }

                return(runningInstance);
            }
            catch
            {
                await runningInstance.Stop();

                throw;
            }
        }