Esempio n. 1
0
 /// <summary>
 /// Registers a consumer and associated message type using the competing consumer pattern. With the competing consumer pattern, only the first consumer on a given node to obtain a message will handle that message.
 /// This is in contrast to the Publisher-Subscriber pattern, where a message will be delivered to the consumer on all nodes in a cluster. To register a Publisher-Subscriber consumer, use <seealso cref="AddPubSubConsumer{TConsumer,TMessage}"/>
 /// </summary>
 public static ElsaOptionsBuilder AddCompetingConsumer <TConsumer, TMessage>(this ElsaOptionsBuilder elsaOptions, string?queueName = default) where TConsumer : class, IHandleMessages <TMessage>
 {
     elsaOptions.AddCompetingConsumerService <TConsumer, TMessage>();
     elsaOptions.AddCompetingMessageType <TMessage>(queueName);
     return(elsaOptions);
 }
 /// <summary>
 /// Registers a consumer and associated message type using the competing consumer pattern. With the competing consumer pattern, only the first consumer on a given node to obtain a message will handle that message.
 /// This is in contrast to the Publisher-Subscriber pattern, where a message will be delivered to the consumer on all nodes in a cluster. To register a Publisher-Subscriber consumer, use <seealso cref="AddPubSubConsumer{TConsumer,TMessage}"/>
 /// </summary>
 /// <param name="elsaOptions"></param>
 /// <typeparam name="TConsumer"></typeparam>
 /// <typeparam name="TMessage"></typeparam>
 /// <returns></returns>
 public static ElsaOptionsBuilder AddCompetingConsumer <TConsumer, TMessage>(this ElsaOptionsBuilder elsaOptions) where TConsumer : class, IHandleMessages <TMessage>
 {
     elsaOptions.Services.AddTransient <IHandleMessages <TMessage>, TConsumer>();
     elsaOptions.AddCompetingMessageType <TMessage>();
     return(elsaOptions);
 }