public RequestChannel( CommunicateChannelFactoryPool channelFactoryPool, RequestMessageContext requestMessageContext, IBinarySerializer binarySerializer) { _requestMessageContext = requestMessageContext; _channelFactoryPool = channelFactoryPool; _binarySerializer = binarySerializer; }
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()]; }
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; }