/// <summary> /// Connect a consumer to the bus instance's default endpoint /// </summary> /// <typeparam name="T"></typeparam> /// <param name="connector"></param> /// <param name="consumerFactory"></param> /// <param name="pipeSpecifications"></param> /// <returns></returns> public static ConnectHandle ConnectConsumer<T>(this IConsumePipeConnector connector, IConsumerFactory<T> consumerFactory, params IPipeSpecification<ConsumerConsumeContext<T>>[] pipeSpecifications) where T : class, IConsumer { if (connector == null) throw new ArgumentNullException(nameof(connector)); if (consumerFactory == null) throw new ArgumentNullException(nameof(consumerFactory)); IConsumerSpecification<T> specification = ConsumerConnectorCache<T>.Connector.CreateConsumerSpecification<T>(); foreach (IPipeSpecification<ConsumerConsumeContext<T>> pipeSpecification in pipeSpecifications) { specification.AddPipeSpecification(pipeSpecification); } return ConsumerConnectorCache<T>.Connector.ConnectConsumer(connector, consumerFactory, specification); }
/// <summary> /// Connect a consumer to the bus instance's default endpoint /// </summary> /// <typeparam name="TConsumer"></typeparam> /// <param name="connector"></param> /// <param name="consumerFactory"></param> /// <param name="pipeSpecifications"></param> /// <returns></returns> public static ConnectHandle ConnectConsumer <TConsumer>(this IConsumePipeConnector connector, IConsumerFactory <TConsumer> consumerFactory, params IPipeSpecification <ConsumerConsumeContext <TConsumer> >[] pipeSpecifications) where TConsumer : class, IConsumer { if (connector == null) { throw new ArgumentNullException(nameof(connector)); } if (consumerFactory == null) { throw new ArgumentNullException(nameof(consumerFactory)); } LogContext.Debug?.Log("Connecting Consumer: {ConsumerType} (using supplied consumer factory)", TypeMetadataCache <TConsumer> .ShortName); IConsumerSpecification <TConsumer> specification = ConsumerConnectorCache <TConsumer> .Connector.CreateConsumerSpecification <TConsumer>(); foreach (IPipeSpecification <ConsumerConsumeContext <TConsumer> > pipeSpecification in pipeSpecifications) { specification.AddPipeSpecification(pipeSpecification); } return(ConsumerConnectorCache <TConsumer> .Connector.ConnectConsumer(connector, consumerFactory, specification)); }
public void AddPipeSpecification(IPipeSpecification <ConsumerConsumeContext <TConsumer> > specification) { _specification.AddPipeSpecification(specification); }