Ensure RabbitMQ WithDataVolume/WithDataBindMount methods actually enable persistent storage#3152
Conversation
|
|
||
| private static IResourceBuilder<RabbitMQServerResource> RunWithStableNodeName(this IResourceBuilder<RabbitMQServerResource> builder) | ||
| { | ||
| if (builder.ApplicationBuilder.ExecutionContext.IsRunMode) |
There was a problem hiding this comment.
What happens when you publish?
There was a problem hiding this comment.
The assumption is when you publish the host name of the container is stable, rather than what happens in dev where we randomize the port every time.
There was a problem hiding this comment.
More details about how RabbitMQ auto-assigns node names in their docs: https://www.rabbitmq.com/docs/clustering#node-names and https://www.rabbitmq.com/docs/configure
From the latter link:
The node name should be unique per Erlang-node-and-machine combination. To run multiple nodes, see the clustering guide.
Default:
Unix: rabbit@$HOSTNAME
Windows: rabbit@%COMPUTERNAME%
So ultimately, what happens after publish depends on what $HOSTNAME results in on the container where RabbitMQ is running.
|
Is it possible to add some tests? |
| var rabbitMqPw = builder.AddParameter("rabbitmqpw", secret: true); | ||
| var messaging = builder.AddRabbitMQ("messaging", password: rabbitMqPw) | ||
| .WithDataVolume() | ||
| .PublishAsContainer(); |
There was a problem hiding this comment.
Why is .PublishAsContainer(); necessary?
There was a problem hiding this comment.
I didn't add that, it was there already.
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…ble persistent storage (#3152) * Use stable node name for RabbitMQ resources * Update TestShop to use durable messages Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
This updates the
WithDataVolumeandWithDataBindMountmethods for RabbitMQ to set theRABBITMQ_NODENAMEenvironment variable to a stable value so that RabbitMQ's internal storage is laid out with a stable storage directory. I also updated TestShop so that it uses persistent storage for its RabbitMQ messaging. I'm able to run TestShop with theorderprocessorresource commented out and make some "orders" by added items to the basket and then clicking the basket summary icon, then stop the session, uncommentorderprocessor, and start a new session, and see thatorderprocessorprocesses the order messages from the previous session.Fixes #2247
Microsoft Reviewers: Open in CodeFlow