RabbitMQ Consumer 连接到 https 域中的 rabbitMQ

RabbitMQ Consumer connection to rabbitMQ in https domain

我需要接收队列的消息,但是这个队列在另一台机器(AWS 实例)中,使用 https(https://www.mymachine.com/rabbitmq) 但是当我想建立到队列的连接时,我得到一个 NullPointerException .

这是部分代码:

factory.setHost(https://www.mymachine.com/rabbitmq);
Connection connection = factory.newConnection();
        channel = connection.createChannel();
        channel.exchangeDeclare(EXCHANGE_NAME, "fanout");
        queueName = channel.queueDeclare().getQueue();
        channel.queueBind(queueName, EXCHANGE_NAME, "");

RabbitMQ,默认不使用HTTP协议,它使用AMQP协议。

你必须用 ip 或主机名更改 factory.setHost

factory.setHost(yourmachine)

如果您需要 SSL 连接,请阅读: https://www.rabbitmq.com/ssl.html教程很清楚