Example #1
0
        public RequestChannel(
            CommunicateChannelFactoryPool channelFactoryPool,
            RequestMessageContext requestMessageContext,
            IBinarySerializer binarySerializer)
        {
            _requestMessageContext = requestMessageContext;

            _channelFactoryPool = channelFactoryPool;

            _binarySerializer = binarySerializer;
        }
Example #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()];
        }
Example #3
0
        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;
        }