I'm using the RabbitMQ Java API to connect to a RabbitMQ server. I want to use ConnectionFactory.setUri(...)
to configure which server to use. It appears to munge the virtual host.
There's a default virtual host named /
.
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
import java.net.URI;
public class Worker {
public static void main(String[] argv) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
final URI uri = URI.create("amqp://guest:guest@localhost:5672/");
factory.setUri(uri);
final Connection connection = factory.newConnection();
final Channel channel = connection.createChannel();
}
}
Using the above code, the configured virtual host is empty. There doesn't seem to be a way, using the URI, to configure the virtual host to be /
.
Is there a way to do this?
I ended up solving this by not using setUri
but rather setting the individual URI components.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With