The template for the file used when adding a message bus to a project using the `add:consumer`, `add:bc`, or `new:domain` commands.
|EndpointRegistrationMethodName||Yes||A deliberately long name to try and promote readability. This is a string that will determine the name of the method used to register the consumer inside MassTransit.||None|
|ConsumerName||Yes||A string that determines the name of the consumer.||None|
|MessageName||Yes||A string that determines the name of the message the consumer will, well, consume!||None|
|QueueName||Yes||A string that determines the name of the queue that you want this particular consumer to be linked to for getting messages.||None|
|ExchangeName||Yes||A string that determines the name of the exchange that this consumer will be tied to. Note that this should match exchange name in the producer that you want this to be linked to.||None|
|ExchangeType||No||The type of exchange you want to use. This can be set to ||direct|
|RoutingKey||No||A string value that determines the routing key that you want to use if you are working with a ||None|
|IsQuorum||No||A boolean that determines whether or not you want to use a quorum queue. This is generally recommended as a best practice.||true|
|IsLazy||No||A boolean that determines whether or not you want to use a lazy queue. This is generally recommended as a best practice. Generally, these can be disabled if you require really high performance, if the queues are always short, or if you have set a max-length policy||true|
|UsesDb||No||A boolean that determines whether ot not the scaffolded consumer feature will inject the db context in the project.||true|
When adding consumers to an existing project, be sure to run the
add:buscommand if you don't already have a message bus in your project. This bus command should be completed before running an
In this example, we're adding a message bus, consumer, message, and producer to our project. Notice how the exchange and message names match between the producer and the consumer.
DomainName: WeSendReportsCompany Messages: - Name: ISendReportRequest Properties: - Name: ReportId Type: guid - Name: Provider Type: string - Name: Target Type: string BoundedContexts: - SolutionName: Reporting Producers: - EndpointRegistrationMethodName: SubmitReportRequest ExchangeName: report-requests MessageName: ISendReportRequest ExchangeType: fanout ProducerName: ReportWasRequested UsesDb: true Consumers: - EndpointRegistrationMethodName: AllReportsGetSentFromHereEndpoint ConsumerName: SenderOfAllReports ExchangeName: report-requests MessageName: ISendReportRequest QueueName: all-reports ExchangeType: fanout Bus: AddBus: true # additional new:domain properties here
If you've already created your Wrapt project and want to add one or more consumers after the fact, you can use the
add:consumer command to pass through one or more consumers to your project.
Make sure you have a message bus already in your project. If you don't have a bus, you add one with the
This particular example will add consumers using a direct exchange.
Consumers: - EndpointRegistrationMethodName: EmailReportsEndpoint ConsumerName: EmailConsumer ExchangeName: report-requests MessageName: ISendReportRequest QueueName: email-reports ExchangeType: direct RoutingKey: email - EndpointRegistrationMethodName: FaxReportsEndpoint ConsumerName: FaxConsumer ExchangeName: report-requests QueueName: fax-reports MessageName: ISendReportRequest ExchangeType: direct RoutingKey: fax IsLazy: false IsQuorum: false
If you wanted to do a
topic exchange, it might look like this:
Consumers: - EndpointRegistrationMethodName: CloudReportsEndpoint ConsumerName: CloudConsumer ExchangeName: report-requests QueueName: cloud-reports MessageName: ISendReportRequest ExchangeType: topic RoutingKey: public.*