当前位置: 首页>>代码示例>>C#>>正文


C# IPipe.Send方法代码示例

本文整理汇总了C#中IPipe.Send方法的典型用法代码示例。如果您正苦于以下问题:C# IPipe.Send方法的具体用法?C# IPipe.Send怎么用?C# IPipe.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPipe的用法示例。


在下文中一共展示了IPipe.Send方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleMessage

 public void HandleMessage(object message, IPipe pipe)
 {
     Console.WriteLine("[SERVER] Message from client: {0}", message);
     pipe.Send("Thanks for sending '" + message + "'");
 }
开发者ID:ccidral,项目名称:courier,代码行数:5,代码来源:Program.cs

示例2: SendUsingExistingClient

        async Task SendUsingExistingClient(IPipe<ClientContext> clientPipe, ClientScope scope, CancellationToken cancellationToken)
        {
            try
            {
                using (var context = await scope.Attach(cancellationToken).ConfigureAwait(false))
                {
                    await clientPipe.Send(context).ConfigureAwait(false);
                }
            }
            catch (Exception exception)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The client usage threw an exception", exception);

                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.CreateFaulted(exception);

                throw;
            }
        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:21,代码来源:HttpClientCache.cs

示例3: Receiver

        async Task Receiver(CancellationToken stopTokenSource, IPipe<ConnectionContext> connectionPipe)
        {
            await Repeat.UntilCancelled(stopTokenSource, async () =>
            {
                if (_log.IsDebugEnabled)
                    _log.DebugFormat("Connecting receive transport: {0}", _host.Settings.GetInputAddress(_settings.QueueDescription));

                var context = new ServiceBusConnectionContext(_host, stopTokenSource);

                try
                {
                    await connectionPipe.Send(context).ConfigureAwait(false);
                }
                catch (TaskCanceledException)
                {
                }
                catch (Exception ex)
                {
                    if (_log.IsErrorEnabled)
                        _log.ErrorFormat("Azure Service Bus connection failed: {0}", ex.Message);

                    Uri inputAddress = context.GetQueueAddress(_settings.QueueDescription);

                    await _endpointObservers.Faulted(new Faulted(inputAddress, ex));
                }
            }).ConfigureAwait(false);
        }
开发者ID:lsfera,项目名称:MassTransit,代码行数:27,代码来源:ServiceBusReceiveTransport.cs

示例4: SendUsingExistingConnection

        static async Task SendUsingExistingConnection(IPipe<ConnectionContext> connectionPipe, CancellationToken cancellationToken, ConnectionScope scope)
        {
            try
            {
                using (SharedConnectionContext context = await scope.Attach(cancellationToken))
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Using existing connection: {0}", ((ConnectionContext)context).HostSettings.ToDebugString());

                    await connectionPipe.Send(context);
                }
            }
            catch (Exception ex)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The existing connection usage threw an exception", ex);

                throw;
            }
        }
开发者ID:nicklv,项目名称:MassTransit,代码行数:20,代码来源:RabbitMqConnectionCache.cs

示例5: SendUsingNewConnection

        async Task SendUsingNewConnection(IPipe<ConnectionContext> connectionPipe, ConnectionScope scope, CancellationToken cancellationToken)
        {
            try
            {
                if (_signal.CancellationToken.IsCancellationRequested)
                    throw new TaskCanceledException($"The connection is being disconnected: {_settings.ToDebugString()}");

                if (_log.IsDebugEnabled)
                    _log.DebugFormat("Connecting: {0}", _connectionFactory.ToDebugString());

                IConnection connection = _connectionFactory.CreateConnection();

                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Connected: {0} (address: {1}, local: {2}", _connectionFactory.ToDebugString(),
                        connection.RemoteEndPoint, connection.LocalEndPoint);
                }

                EventHandler<ShutdownEventArgs> connectionShutdown = null;
                connectionShutdown = (obj, reason) =>
                {
                    connection.ConnectionShutdown -= connectionShutdown;

                    Interlocked.CompareExchange(ref _scope, null, scope);

                    scope.Close();
                };

                connection.ConnectionShutdown += connectionShutdown;

                var connectionContext = new RabbitMqConnectionContext(connection, _settings, _signal.CancellationToken);

                connectionContext.GetOrAddPayload(() => _settings);

                scope.Connected(connectionContext);
            }
            catch (BrokerUnreachableException ex)
            {
                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.ConnectFaulted(ex);

                throw new RabbitMqConnectionException("Connect failed: " + _connectionFactory.ToDebugString(), ex);
            }

            try
            {
                using (SharedConnectionContext context = await scope.Attach(cancellationToken))
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Using new connection: {0}", ((ConnectionContext)context).HostSettings.ToDebugString());

                    await connectionPipe.Send(context);
                }
            }
            catch (Exception ex)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The connection usage threw an exception", ex);

                throw;
            }
        }
开发者ID:nicklv,项目名称:MassTransit,代码行数:63,代码来源:RabbitMqConnectionCache.cs

示例6: SendUsingExistingModel

        async Task SendUsingExistingModel(IPipe<ModelContext> modelPipe, ModelScope scope, CancellationToken cancellationToken)
        {
            try
            {
                using (var context = await scope.Attach(cancellationToken).ConfigureAwait(false))
                {
//                    if (_log.IsDebugEnabled)
//                        _log.DebugFormat("Using model: {0}", ((ModelContext)context).ConnectionContext.HostSettings.ToDebugString());

                    await modelPipe.Send(context).ConfigureAwait(false);
                }
            }
            catch (Exception exception)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The model usage threw an exception", exception);

                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.CreateFaulted(exception);

                throw;
            }
        }
开发者ID:phatboyg,项目名称:MassTransit,代码行数:24,代码来源:RabbitMqModelCache.cs

示例7: Receiver

        async void Receiver(IPipe<ConnectionContext> connectionPipe, TaskSupervisor supervisor)
        {
            try
            {
                await _connectionRetryPolicy.RetryUntilCancelled(async () =>
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Connecting receive transport: {0}", _host.Settings.GetInputAddress(_settings.QueueDescription));

                    var context = new ServiceBusConnectionContext(_host, supervisor.StoppedToken);

                    try
                    {
                        await connectionPipe.Send(context).ConfigureAwait(false);
                    }
                    catch (TaskCanceledException)
                    {
                    }
                    catch (Exception ex)
                    {
                        if (_log.IsErrorEnabled)
                            _log.ErrorFormat("Azure Service Bus connection failed: {0}", ex.Message);

                        var inputAddress = context.GetQueueAddress(_settings.QueueDescription);

                        await _endpointObservers.Faulted(new Faulted(inputAddress, ex)).ConfigureAwait(false);
                    }
                }, supervisor.StoppingToken).ConfigureAwait(false);
            }
            catch (TaskCanceledException)
            {
            }
        }
开发者ID:phatboyg,项目名称:MassTransit,代码行数:33,代码来源:ServiceBusReceiveTransport.cs

示例8: SendUsingNewModel

        async Task SendUsingNewModel(IPipe<ModelContext> modelPipe, ModelScope scope, CancellationToken cancellationToken)
        {
            IPipe<ConnectionContext> connectionPipe = Pipe.ExecuteAsync<ConnectionContext>(async connectionContext =>
            {
                IModel model = await connectionContext.CreateModel().ConfigureAwait(false);

                EventHandler<ShutdownEventArgs> modelShutdown = null;
                modelShutdown = (obj, reason) =>
                {
                    model.ModelShutdown -= modelShutdown;

                    Interlocked.CompareExchange(ref _scope, null, scope);

                    scope.Close();
                };

                model.ModelShutdown += modelShutdown;

                var modelContext = new RabbitMqModelContext(connectionContext, model, connectionContext.CancellationToken);

                scope.Connected(modelContext);

                try
                {
                    using (SharedModelContext context = await scope.Attach(cancellationToken).ConfigureAwait(false))
                    {
                        await modelPipe.Send(context).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    if (_log.IsDebugEnabled)
                        _log.Debug("The existing model usage threw an exception", ex);

                    Interlocked.CompareExchange(ref _scope, null, scope);

                    scope.Close();

                    throw;
                }
            });

            try
            {
                await _connectionCache.Send(connectionPipe, new CancellationToken()).ConfigureAwait(false);
            }
            catch (Exception exception)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The connection threw an exception", exception);

                Interlocked.CompareExchange(ref _scope, null, scope);

                throw;
            }
        }
开发者ID:kotvisbj,项目名称:MassTransit,代码行数:56,代码来源:RabbitMqModelCache.cs

示例9: SendUsingExistingConnection

        async Task SendUsingExistingConnection(IPipe<OwinHostContext> connectionPipe, OwinHostScope scope, CancellationToken cancellationToken)
        {
            try
            {
                using (var context = await scope.Attach(cancellationToken).ConfigureAwait(false))
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Using host: {0}", context.HostSettings.ToDebugString());

                    await connectionPipe.Send(context).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The host usage threw an exception", ex);

                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.ConnectFaulted(ex);

                throw;
            }
        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:24,代码来源:OwinHostCache.cs

示例10: SendUsingExistingModel

        async Task SendUsingExistingModel(IPipe<ModelContext> modelPipe, ModelScope existingScope, CancellationToken cancellationToken)
        {
            try
            {
                using (SharedModelContext context = await existingScope.Attach(cancellationToken).ConfigureAwait(false))
                {
                    await modelPipe.Send(context).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The existing model usage threw an exception", ex);

                Interlocked.CompareExchange(ref _scope, null, existingScope);

                existingScope.Close();

                throw;
            }
        }
开发者ID:kotvisbj,项目名称:MassTransit,代码行数:21,代码来源:RabbitMqModelCache.cs

示例11: SendUsingExistingModel

        static async Task SendUsingExistingModel(IPipe<ModelContext> modelPipe, ModelScope existingScope, CancellationToken cancellationToken)
        {
            try
            {
                using (SharedModelContext context = await existingScope.Attach(cancellationToken))
                {
                    await modelPipe.Send(context);
                }
            }
            catch (Exception ex)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The existing model usage threw an exception", ex);

                throw;
            }
        }
开发者ID:nicklv,项目名称:MassTransit,代码行数:17,代码来源:RabbitMqModelCache.cs

示例12: Receiver

        async void Receiver(IPipe<NamespaceContext> pipe, TaskSupervisor supervisor)
        {
            var inputAddress = _settings.GetInputAddress(_host.Settings.ServiceUri);

            try
            {
                await _host.RetryPolicy.RetryUntilCancelled(async () =>
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Connecting receive transport: {0}", inputAddress);

                    var context = new ServiceBusNamespaceContext(_host, _receiveObservers, _endpointObservers, supervisor);

                    try
                    {
                        await pipe.Send(context).ConfigureAwait(false);
                    }
                    catch (TaskCanceledException)
                    {
                    }
                    catch (OperationCanceledException)
                    {
                    }
                    catch (Exception ex)
                    {
                        if (_log.IsErrorEnabled)
                            _log.Error($"Azure Service Bus receiver faulted: {inputAddress}", ex);

                        await _endpointObservers.Faulted(new ReceiveTransportFaultedEvent(inputAddress, ex)).ConfigureAwait(false);

                        throw;
                    }
                }, supervisor.StoppingToken).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                _log.Error($"Unhandled exception on Receiver: {inputAddress}", ex);
            }
        }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:39,代码来源:ReceiveTransport.cs

示例13: SendUsingExistingConnection

        async Task SendUsingExistingConnection(IPipe<ConnectionContext> connectionPipe, ConnectionScope scope, CancellationToken cancellationToken)
        {
            try
            {
                using (var context = await scope.Attach(cancellationToken).ConfigureAwait(false))
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Using connection: {0}", ((ConnectionContext)context).HostSettings.ToDebugString());

                    await connectionPipe.Send(context).ConfigureAwait(false);
                }
            }
            catch (BrokerUnreachableException ex)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The broker was unreachable", ex);

                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.ConnectFaulted(ex);

                throw new RabbitMqConnectionException("Connect failed: " + _settings.ToDebugString(), ex);
            }
            catch (Exception ex)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The connection usage threw an exception", ex);

                Interlocked.CompareExchange(ref _scope, null, scope);

                scope.ConnectFaulted(ex);

                throw;
            }
        }
开发者ID:jsmale,项目名称:MassTransit,代码行数:35,代码来源:RabbitMqConnectionCache.cs

示例14: SendUsingExistingConnection

        async Task SendUsingExistingConnection(IPipe<ConnectionContext> connectionPipe, CancellationToken cancellationToken, ConnectionScope scope)
        {
            try
            {
                using (SharedConnectionContext context = await scope.Attach(cancellationToken).ConfigureAwait(false))
                {
                    if (_log.IsDebugEnabled)
                        _log.DebugFormat("Using existing connection: {0}", ((ConnectionContext)context).HostSettings.ToDebugString());

                    await connectionPipe.Send(context).ConfigureAwait(false);
                }
            }
            catch (BrokerUnreachableException ex)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The connection usage threw an exception", ex);

                throw new RabbitMqConnectionException("Connect failed: " + _connectionFactory.ToDebugString(), ex);
            }
            catch (Exception ex)
            {
                if (_log.IsDebugEnabled)
                    _log.Debug("The existing connection usage threw an exception", ex);

                throw;
            }
        }
开发者ID:JackWangCUMT,项目名称:MassTransit,代码行数:27,代码来源:RabbitMqConnectionCache.cs


注:本文中的IPipe.Send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。