Ejemplo n.º 1
0
 /// <summary>
 /// Configures a fault consumer of the specified type via convention.
 /// This is for subscribing to <see cref="Fault{T}"/> events when using fire-and-forget messages.
 /// Note that send-receive messages do not publish faults.
 /// </summary>
 /// <typeparam name="TConsumer">The type of the consumer.</typeparam>
 /// <typeparam name="TMessage">The type of the message.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="retry">The optional retry configurator action.</param>
 /// <param name="receiveEndpointConfigurator">The optional endpoint configurator action.</param>
 /// <returns></returns>
 public static IMassTransitRabbitMqHostingBuilder ConsumeFaultByConvention <TConsumer, TMessage>(
     this IMassTransitRabbitMqHostingBuilder builder,
     Action <IRetryConfigurator> retry = null,
     Action <IRabbitMqReceiveEndpointConfigurator> receiveEndpointConfigurator = null)
     where TConsumer : class, IConsumer <Fault <TMessage> >
     where TMessage : class
 => builder.Consume <TConsumer, Fault <TMessage> >($"{builder.GetQueueName<TMessage>()}_{FaultQueuePostfix}", retry, receiveEndpointConfigurator);
Ejemplo n.º 2
0
 /// <summary>
 /// Configures an error consumer of the specified type.
 /// This is MassTransit's standard for hard failed messages.
 /// I.e. all messages that fail are routed to queues post-fixed with _error. Consume them again with this.
 /// </summary>
 /// <typeparam name="TConsumer">The type of the consumer.</typeparam>
 /// <typeparam name="TMessage">The type of the message.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="queueName">Name of the queue.</param>
 /// <param name="retry">The optional retry configurator action.</param>
 /// <param name="receiveEndpointConfigurator">The optional endpoint configurator action.</param>
 /// <returns></returns>
 public static IMassTransitRabbitMqHostingBuilder ConsumeError <TConsumer, TMessage>(
     this IMassTransitRabbitMqHostingBuilder builder,
     string queueName,
     Action <IRetryConfigurator> retry = null,
     Action <IRabbitMqReceiveEndpointConfigurator> receiveEndpointConfigurator = null)
     where TConsumer : class, IConsumer <TMessage>
     where TMessage : class
 => builder.Consume <TConsumer, TMessage>($"{queueName}_{ErrorQueuePostfix}", retry, receiveEndpointConfigurator);
 /// <summary>
 /// Configures a consumer of the specified type via convention.
 /// </summary>
 /// <typeparam name="TConsumer">The type of the consumer.</typeparam>
 /// <typeparam name="TMessage">The type of the message.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="retry">The optional retry configurator action.</param>
 /// <param name="receiveEndpointConfigurator">The optional endpoint configurator action.</param>
 /// <param name="consumerFactory">The optional factory for producing customers.</param>
 /// <returns></returns>
 public static IMassTransitRabbitMqHostingBuilder ConsumeByConvention <TConsumer, TMessage>(
     this IMassTransitRabbitMqHostingBuilder builder,
     Action <IRetryConfigurator> retry = null,
     Action <IRabbitMqReceiveEndpointConfigurator> receiveEndpointConfigurator = null,
     Func <IServiceProvider, TConsumer> consumerFactory = null)
     where TConsumer : class, IConsumer <TMessage>
     where TMessage : class
 => builder.Consume <TConsumer, TMessage>(builder.GetQueueName <TMessage>(), retry, receiveEndpointConfigurator, consumerFactory);
 /// <summary>
 /// Configures a fault consumer of the specified type.
 /// This is for subscribing to <see cref="Fault{T}"/> events when using fire-and-forget messages.
 /// Note that send-receive messages do not publish faults.
 /// </summary>
 /// <typeparam name="TConsumer">The type of the consumer.</typeparam>
 /// <typeparam name="TMessage">The type of the message.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="queueName">Name of the queue.</param>
 /// <param name="retry">The optional retry configurator action.</param>
 /// <param name="receiveEndpointConfigurator">The optional endpoint configurator action.</param>
 /// <param name="consumerFactory">The optional factory for producing customers.</param>
 /// <returns></returns>
 public static IMassTransitRabbitMqHostingBuilder ConsumeFault <TConsumer, TMessage>(
     this IMassTransitRabbitMqHostingBuilder builder,
     string queueName,
     Action <IRetryConfigurator> retry = null,
     Action <IRabbitMqReceiveEndpointConfigurator> receiveEndpointConfigurator = null,
     Func <IServiceProvider, TConsumer> consumerFactory = null)
     where TConsumer : class, IConsumer <Fault <TMessage> >
     where TMessage : class
 => builder.Consume <TConsumer, Fault <TMessage> >($"{queueName}_{FaultQueuePostfix}", retry, receiveEndpointConfigurator, consumerFactory);
 /// <summary>
 /// Configures an error consumer of the specified type via convention.
 /// This is MassTransit's standard for hard failed messages.
 /// I.e. all messages that fail are routed to queues post-fixed with _error. Consume them again with this.
 /// </summary>
 /// <typeparam name="TConsumer">The type of the consumer.</typeparam>
 /// <typeparam name="TMessage">The type of the message.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="remoteApplicationName">Name of the remote application.</param>
 /// <param name="retry">The optional retry configurator action.</param>
 /// <param name="receiveEndpointConfigurator">The optional endpoint configurator action.</param>
 /// <param name="consumerFactory">The optional factory for producing customers.</param>
 /// <returns></returns>
 public static IMassTransitRabbitMqHostingBuilder ConsumeErrorByConvention <TConsumer, TMessage>(
     this IMassTransitRabbitMqHostingBuilder builder,
     string remoteApplicationName,
     Action <IRetryConfigurator> retry = null,
     Action <IRabbitMqReceiveEndpointConfigurator> receiveEndpointConfigurator = null,
     Func <IServiceProvider, TConsumer> consumerFactory = null)
     where TConsumer : class, IConsumer <TMessage>
     where TMessage : class
 => builder.Consume <TConsumer, TMessage>($"{GetQueueName<TMessage>(remoteApplicationName)}_{ErrorQueuePostfix}", retry, receiveEndpointConfigurator, consumerFactory);
 /// <summary>
 /// Configures a fault consumer of the specified type.
 /// This is for subscribing to <see cref="Fault{T}"/> events when using fire-and-forget messages.
 /// Note that send-receive messages do not publish faults.
 /// </summary>
 /// <typeparam name="TConsumer">The type of the consumer.</typeparam>
 /// <typeparam name="TMessage">The type of the message.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="queueName">Name of the queue.</param>
 /// <param name="retry">The optional retry configurator action.</param>
 /// <returns></returns>
 public static IMassTransitRabbitMqHostingBuilder ConsumeFault <TConsumer, TMessage>(this IMassTransitRabbitMqHostingBuilder builder,
                                                                                     string queueName,
                                                                                     Action <IRetryConfigurator> retry = null)
     where TConsumer : class, IConsumer <Fault <TMessage> >
     where TMessage : class
 => builder.Consume <TConsumer, Fault <TMessage> >($"{queueName}_{FaultQueuePostfix}", retry);
 /// <summary>
 /// Configures a consumer of the specified type via convention.
 /// </summary>
 /// <typeparam name="TConsumer">The type of the consumer.</typeparam>
 /// <typeparam name="TMessage">The type of the message.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="retry">The optional retry configurator action.</param>
 /// <returns></returns>
 public static IMassTransitRabbitMqHostingBuilder ConsumeByConvention <TConsumer, TMessage>(this IMassTransitRabbitMqHostingBuilder builder,
                                                                                            Action <IRetryConfigurator> retry = null)
     where TConsumer : class, IConsumer <TMessage>
     where TMessage : class
 => builder.Consume <TConsumer, TMessage>(builder.GetQueueName <TMessage>(), retry);
 /// <summary>
 /// Configures an error consumer of the specified type via convention.
 /// This is MassTransit's standard for hard failed messages.
 /// I.e. all messages that fail are routed to queues post-fixed with _error. Consume them again with this.
 /// </summary>
 /// <typeparam name="TConsumer">The type of the consumer.</typeparam>
 /// <typeparam name="TMessage">The type of the message.</typeparam>
 /// <param name="builder">The builder.</param>
 /// <param name="remoteApplicationName">Name of the remote application.</param>
 /// <param name="retry">The optional retry configurator action.</param>
 /// <returns></returns>
 public static IMassTransitRabbitMqHostingBuilder ConsumeErrorByConvention <TConsumer, TMessage>(this IMassTransitRabbitMqHostingBuilder builder,
                                                                                                 string remoteApplicationName,
                                                                                                 Action <IRetryConfigurator> retry = null)
     where TConsumer : class, IConsumer <TMessage>
     where TMessage : class
 => builder.Consume <TConsumer, TMessage>($"{GetQueueName<TMessage>(remoteApplicationName)}_{ErrorQueuePostfix}", retry);