コード例 #1
0
ファイル: RequestChannel.cs プロジェクト: liuxiqin/Sevens
        public RequestChannel(
            CommunicateChannelFactoryPool channelFactoryPool,
            RequestMessageContext requestMessageContext,
            IBinarySerializer binarySerializer)
        {
            _requestMessageContext = requestMessageContext;

            _channelFactoryPool = channelFactoryPool;

            _binarySerializer = binarySerializer;
        }
コード例 #2
0
        public IRequestChannel GetRequestChannel(RequestMessageContext messageContext)
        {
            if (!_channelPools.ContainsKey(messageContext.ToString()))
            {
                lock (_lockObj)
                {
                    if (!_channelPools.ContainsKey(messageContext.ToString()))
                    {
                        _channelPools.TryAdd(messageContext.ToString(), new RequestChannel(_channelFactoryPools, messageContext, _binarySerializer));
                    }
                }
            }

            return _channelPools[messageContext.ToString()];
        }
コード例 #3
0
ファイル: EventPublisher.cs プロジェクト: liuxiqin/Sevens
        public Task<AsyncHandleResult> PublishAsync(IEvent evnt)
        {
            var publishTask = Task.Run(() =>
            {
                var queueMessage = BuildMessage(evnt);

                var requestContext = new RequestMessageContext(queueMessage.ExchangeName, queueMessage.RoutingKey, null);

                var requestChannel = _requestChannelPools.GetRequestChannel(requestContext);

                requestChannel.SendMessageAsync(queueMessage);

                return new AsyncHandleResult(HandleStatus.Success);
            });

            return publishTask;
        }