Unable to connect to RabbitMQ in spark scala

Solution 1:

access to vhost '5672' refused for user '****'

I think you are confusing the TCP port with the Virtual host.

try with:

 factory.setVirtualHost("/")