public ISubscription RespondAsync <TRequest, TResponse>(Func <TRequest, TMessageContext, Task <TResponse> > onMessage, Action <IResponderConfigurationBuilder> configuration = null) { var config = _configEval.GetConfiguration <TRequest, TResponse>(configuration); var exchangeCfg = config.Exchange.AssumeInitialized ? null : new ExchangeDeclaration { AutoDelete = config.Exchange.AutoDelete, Durable = config.Exchange.Durable, ExchangeType = config.Exchange.ExchangeType, Name = config.Exchange.ExchangeName, Arguments = config.Exchange.Arguments }; var queueCfg = config.Queue.AssumeInitialized ? null : new QueueDeclaration { Arguments = config.Queue.Arguments, Durable = config.Queue.Durable, AutoDelete = config.Queue.AutoDelete, Exclusive = config.Queue.Exclusive, Name = config.Queue.FullQueueName }; var respondCfg = new ConsumerConfiguration { Exchange = exchangeCfg, Queue = queueCfg, Consume = new ConsumeConfiguration { ConsumerTag = Guid.NewGuid().ToString(), ExchangeName = config.Exchange.ExchangeName, QueueName = config.Queue.FullQueueName, AutoAck = config.AutoAck, RoutingKey = config.RoutingKey, PrefetchCount = config.PrefetchCount } }; Action <IPipeContext> ctxAction = context => { context.Properties.Add(PipeKey.ConsumerConfiguration, respondCfg); context.Properties.Add(PipeKey.ConsumeConfiguration, respondCfg.Consume); context.Properties.Add(PipeKey.QueueDeclaration, respondCfg.Queue); context.Properties.Add(PipeKey.ExchangeDeclaration, respondCfg.Exchange); }; return(_client .RespondAsync(onMessage, ctxAction) .ContinueWith(tContext => tContext.Result.GetSubscription()) .GetAwaiter() .GetResult()); }
public ISubscription RespondAsync <TRequest, TResponse>(Func <TRequest, TMessageContext, Task <TResponse> > onMessage, Action <IResponderConfigurationBuilder> configuration = null) { return(_client.RespondAsync(onMessage, configuration)); }