Masstransit Outbox messages setup with RabbitMQ and SQL Server

115 views Asked by At

I'm currently working on implementing MassTransit's outbox pattern to replace a traditional RabbitMQ.Client setup. My Producer worker receives queues and messages from a database, and a while loop iterates to get new messages as they come in. I want to publish these messages immediately.

Here's the structure of my ProducerMessageDTO:

`namespace MessageProducer.Application.Common.DTOs;

public class ProducerMessageDTO
{
    public int IDMessage { get; set; }
    public string RoutingKey { get; set; } // example: #.redCro.#
    public string Message { get; set; } //XML message
    public int MessageTypeID { get; set; } //just an id which defines my UserInfo message type
}`

And this is how my queue from the database looks:

`IDQueue    ProducerID    QueueName    RoutingKey    Description                   Active
17         9             player_fin_cd #.redCro.#   Redis messages Masstransit    1
`

My challenge is to define and bind queues and exchanges dynamically when the application starts, using a topic exchange for routing messages. However, I'm not fond of hardcoding any endpoint in my MassTransit setup based on the information I get from each message in the database.

I'm looking for advice on the best way to handle this type of situation, ensuring that my setup remains dynamic and scalable. The consumer is separated and not part of this setup.

Any suggestions or guidance would be greatly appreciated.

0

There are 0 answers