JustJordanT / pizza-planet

Pizza Planet Application 🍕 🛻 - A place for me to build a modular Monolith
2 stars 0 forks source link

RabbitMQ for Shop to kitchen and kitchen to shop #22

Closed JustJordanT closed 1 year ago

JustJordanT commented 1 year ago

To publish a message for a pizza order to a queue using RabbitMQ with C#, you will need to perform the following steps:

Install the RabbitMQ .NET client library using the NuGet package manager in Visual Studio.

Establish a connection to the RabbitMQ server using the connection factory provided by the client library.

Create a new channel to communicate with the server.

Declare a queue for the pizza orders.

Serialize the pizza order message into a byte array.

Use the channel to publish the message to the queue.

Close the channel and connection to the server.

Here is an example of how this could be implemented:

using (var connection = factory.CreateConnection())
using (var channel = connection.CreateModel())
{
    channel.QueueDeclare(queue: "pizza_orders",
                        durable: false,
                        exclusive: false,
                        autoDelete: false,
                        arguments: null);

    var order = new PizzaOrder { ... };
    var body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(order));

    channel.BasicPublish(exchange: "",
                         routingKey: "pizza_orders",
                         basicProperties: null,
                         body: body);
}

It is important to note that this is just a basic example, and you will likely need to modify it to suit your specific needs.

JustJordanT commented 1 year ago

https://www.rabbitmq.com/tutorials/tutorial-six-dotnet.html

JustJordanT commented 1 year ago

https://www.youtube.com/playlist?list=PLx8uyNNs1ri2MBx6BjPum5j9_MMdIfM9C

JustJordanT commented 1 year ago

https://www.youtube.com/watch?v=_dfEMm7rRrI

JustJordanT commented 1 year ago

https://www.pulumi.com/registry/packages/rabbitmq/ https://www.pulumi.com/registry/packages/cloudamqp

JustJordanT commented 1 year ago

Completed tied to --> #26