-
Notifications
You must be signed in to change notification settings - Fork 586
Description
Is your feature request related to a problem? Please describe.
I am in the process of enabling Validated User-IDs to authorize RPCs.
Here is the example code from the documentation:
AMQP.BasicProperties properties = new AMQP.BasicProperties();
properties.setUserId("guest");
channel.basicPublish("amq.fanout", "", properties, "test".getBytes());
But right now getting the correct user id is kind of complicated. To gain access to the the username I would have to pass it down multiple layers of abstractions and dependency injection, as it is currently only available when creating the connection, not when using it.
Describe the solution you'd like
I would like to enable an option while creating the connection to always use my username as the user ID when publishing a message. Something like this:
connectionFactory.setUsername("bob")
.setPassword("mypassword")
.automaticallySetUserIdToUsername(true);
Alternatively this could be solved by making the username a public attribute of the Connection
, so I could solve it like this:
AMQP.BasicProperties properties = new AMQP.BasicProperties();
properties.setUserId(channel.getConnection().getUsername());
channel.basicPublish("amq.fanout", "", properties, "test".getBytes());
This would require me to update a handful of code segments, but would be doable.
Describe alternatives you've considered
No response
Additional context
No response