-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when you publish?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is .PublishAsContainer();
necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
WithDataVolume
andWithDataBindMount
methods for RabbitMQ to set theRABBITMQ_NODENAME
environment 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 theorderprocessor
resource 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 thatorderprocessor
processes the order messages from the previous session.Fixes #2247
Microsoft Reviewers: Open in CodeFlow