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


C# IBus.Receive方法代码示例

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


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

示例1: MessageBusInputChannel

        public MessageBusInputChannel(
            BufferManager bufferManager, MessageEncoderFactory encoder, ChannelManagerBase parent,
            EndpointAddress localAddress,
            IBus bus)
            : base(bufferManager, encoder, parent)
        {
            _localAddress = localAddress;
            _bus = bus;
            _aLock = new object();

            _tryReceiveDelegate = (TimeSpan timeout, out Message message) =>
            {
                message = null;
                try
                {
                    var requestMessage = _bus.Receive(true, null);
                    if (requestMessage != null)
                    {
                        message = GetWcfMessageFromString(requestMessage.Content);
                        OnAfterTryReceive(requestMessage);
                    }
                }
                catch (Exception ex)
                {
                    throw new CommunicationException(ex.Message, ex);
                }
                return true;
            };

            _receiveDelegate = (TimeSpan timeout) =>
            {
                var requestMessage = _bus.Receive(false, ChannelID);
                return GetWcfMessageFromString(requestMessage.Content);
            };
        }
开发者ID:shaunxu,项目名称:roma,代码行数:35,代码来源:MessageBusInputChannel.cs

示例2: MessageBusDuplexChannel

        public MessageBusDuplexChannel(
            BufferManager bufferManager, MessageEncoderFactory encoder, EndpointAddress remoteAddress,
            ChannelManagerBase parent, Uri via,
            IBus bus, bool isClient)
            : base(bufferManager, encoder, parent)
        {
            _serverAddress = remoteAddress;
            _via = via;
            _bus = bus;
            _isClient = isClient;
            _replyTos = new ConcurrentDictionary<UniqueId, string>();

            _tryReceiveDelegate = (TimeSpan timeout, out Message message) =>
            {
                message = null;
                try
                {
                    // listen the message bus based on the sticky mode:
                    // channel: only receive the message that reply to this channel's id
                    // scaling gourp: receive the message the reply to this channel's id and the scaling group id of this channel
                    var requestMessage = _bus.Receive(!_isClient, ChannelID);
                    if (requestMessage != null)
                    {
                        message = GetWcfMessageFromString(requestMessage.Content);
                        if (message.Headers.MessageId != null)
                        {
                            _replyTos.AddOrUpdate(message.Headers.MessageId, requestMessage.From, (key, value) => requestMessage.From);
                        }
                        OnAfterTryReceive(requestMessage);
                    }
                }
                catch (Exception ex)
                {
                    throw new CommunicationException(ex.Message, ex);
                }
                return true;
            };
        }
开发者ID:shaunxu,项目名称:roma,代码行数:38,代码来源:MessageBusDuplexChannel.cs

示例3: MessageBusReplyChannel

        public MessageBusReplyChannel(
            BufferManager bufferManager, MessageEncoderFactory encoder, ChannelManagerBase parent,
            EndpointAddress localAddress,
            IBus bus)
            : base(bufferManager, encoder, parent)
        {
            _localAddress = localAddress;
            _bus = bus;
            _aLock = new object();

            _tryReceiveRequestDelegate = (TimeSpan t, out RequestContext rc) =>
            {
                rc = null;
                // receive the request message from the bus
                var busMsg = _bus.Receive(true, null);
                // box the wcf message
                var message = GetWcfMessageFromString(busMsg.Content);
                // initialize the request context and return
                rc = new MessageBusRequestContext(message, this, _localAddress, _bus, busMsg.MessageID);
                OnAfterTryReceiveRequest(busMsg);
                return true;
            };
        }
开发者ID:shaunxu,项目名称:roma,代码行数:23,代码来源:MessageBusReplyChannel.cs


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