Routing to separated handlers for a given message type? #3829
-
|
I noticed that the default behavior of the consumers for a given message type is to "bundle" the consumers. For example, for a message type: public class EmailReceivedModel() : Event(Id.Random())
{
public string To { get; set; } = string.Empty;
public string From { get; set; } = string.Empty;
public string Subject { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
}If I have two Is there a mechanism to have separated consumers such that each handler is able to produce its own subscriber channel? I know I can create three subscriptions when setting up the consumers, but I see no obvious way to route the subscriptions to specific handlers. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Unfortunately, today there is no way to do it via Like The message public class EmailReceived() : Event(Id.Random())
{
public string To { get; set; } = string.Empty;
public string From { get; set; } = string.Empty;
public string Subject { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
}
public class EmailReceivedModel() : Event(Id.Random())
{
public string To { get; set; } = string.Empty;
public string From { get; set; } = string.Empty;
public string Subject { get; set; } = string.Empty;
public string Body { get; set; } = string.Empty;
}So your handler will be something like this: public class EmailReceived(IAmACommandProcessor processor) : RequestHandlerAsync<EmailReceived>()
{
public override Task<EmailReceived> HandleAsync(EmailReceived request, CancellationToken ct)
{
await processor.PublishAsync(new EmailReceivedModel { ... });
return base.HandleAsync(request, ct);
}
} |
Beta Was this translation helpful? Give feedback.
Unfortunately, today there is no way to do it via
Subscription, you can do a workaround, by having a message X and publishing it to the internal busLike
The message