If I understand what you’re saying, you’d need to call
Endpoint.Start to create new endpoint every time you want to send a message. That is definitely not something we recommend. In fact, you’d have to create a new
EndpointConfiguration instance each time as well since they can’t be reused.
You’d also need to manage shutting down all of those endpoints correctly as well, or they’d all still be active, with their own connections to the broker running.
That also assumes these endpoints would only be used for sending messages and aren’t also receiving them. If you’re also receiving messages, then this definitely would not make sense since endpoints need to be long-running to process messages in a queue.
Overall, I don’t think it makes sense to do what you’re suggesting. It’s a much better idea to allow the new credentials to be picked up naturally during a process restart.