コード例 #1
0
        public async Task<AsyncClosable> StartAsync(
            EndpointConfiguration.ReadOnly configuration, 
            Func<TransportMessage, Task> onMessage)
        {
            MessageReceiver client =
                await this.factory
                    .CreateMessageReceiverAsync(configuration.DestinationQueue(), ReceiveMode.PeekLock)
                    .ConfigureAwait(false);

            OnMessageOptions options = configuration.Options();
            options.ExceptionReceived += (sender, args) => HandleExceptionReceived(configuration.DestinationQueue(), args);

            configuration.Configure(client).OnMessageAsync(brokeredMessage => onMessage(new TransportMessage(brokeredMessage)), options);

            return new AsyncClosable(client.CloseAsync);
        }