![]() ![]() ![]() Messages are usually part of a conversation and identifiers are used to connect messages to that conversation. Message headers can be read using the ConsumeContext interface and specified using the SendContext interface. The host information of the machine that sent or published the message.Īdditional headers, which can be added by the user, middleware, or diagnostic trace filters. When the message should expire, which may be used by the transport to remove the message if it isn't consumed by the expiration time.Īn array of message types, in a MessageUrn format, which can be deserialized. Where responses to the request should be sent. Where the message originated (may be a temporary address for messages published or sent from IBus). Generated for each message using NewId.NextGuid.Īssigned by the application, or automatically by convention, and should uniquely identify the operation, event, etc.Īssigned by the request client, and automatically copied by the Respond methods to correlate responses to the original request.Īssigned when publishing or sending from a consumer, saga, or activity to the value of the CorrelationId on the consumed message.Īssigned when the first message is sent or published and no consumed message is available, ensuring that a set of messages within the same conversation have the same identifier. The envelope adds a series of message headers, including: MassTransit encapsulates every sent or published message in a message envelope (described by the Envelope Wrapper pattern). OrderSubmitted, OrderAccepted, OrderRejected, OrderShipped.Events are published (using Publish) via either ConsumeContext (within a message consumer), IPublishEndpoint (within a container scope), or IBus (standalone).Įvents should be expressed in a noun-verb (past tense) sequence, indicating that something happened. For example:Īn event signifies that something has happened. For low- to medium-volume message loads this isn't a major concern, but for larger high-volume loads it may be preferable to send (using Send) commands directly to the queue to reduce latency and cost.Ĭommands should be expressed in a verb-noun sequence, following the tell style. However, both Azure Service Bus and Amazon SQS have a more complicated routing structure and because of that structure, additional charges may be incurred since messages need to be forwarded from topics to queues. When using RabbitMQ, there is no additional overhead using this approach. By maintaining the one-to-one relationship of a command to a consumer, commands may by published and they will be automatically routed to the consumer. If you have a command, such as SubmitOrder, then you should have only one consumer that implements IConsumer or one saga state machine with the Event configured. CommandsĪ command tells a service to do something, and typically a command should only be consumed by a single consumer. When choosing a name for a message, the type of message should dictate the tense of the message. There are two main message types, events and commands. If an exception is thrown, the buffered messages are discarded.Don't create an exchange or topic unless it is directly consumed or publishedĭon't create a middleware filter for the message type MassTransit provides an outbox to buffer those messages until the consumer completes successfully. If the consumer publishes events or sends messages (using ConsumeContext, which is provided via the Consume method on the consumer) and subsequently throws an exception, it isn't likely that those messages should still be published or sent. ![]() This could mean a total of 15 retry attempts (on top of the initial 4 attempts prior to the retry/redelivery filters taking control). Now, if the initial 5 immediate retries fail (the database is really, really down), the message will retry an additional three times after 5, 15, and 30 minutes. Public class SubmitOrderConsumer : IConsumer ) ![]()
0 Comments
Leave a Reply. |