使用letsencrypt ssl连接到远程RabbitMQ服务器

时间:2017-12-23 09:01:14

标签: spring-amqp

我有这个配置能够连接到compose.io rabbitmq服务

public class MinimumClass<T extends Comparable<T>> {
    public T minElement(MySet<T> mySet) {
        return Collections.min(mySet.getSet());
    }
}

然而,在运行程序时,我在这一行中收到错误

package com.gandalf.configuration; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.core.AmqpAdmin; import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.connection.RabbitConnectionFactoryBean; @Configuration public class SpringAmqpConfiguration { @Bean public ConnectionFactory connectionFactory() { CachingConnectionFactory connectionFactory = new CachingConnectionFactory(); connectionFactory.setAddresses("portal274-33.***,...."); connectionFactory.setUsername("amqpuser"); connectionFactory.setPassword("muggledone"); connectionFactory.setUseSsl(true); return connectionFactory; } @Bean public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() { SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); factory.setConnectionFactory(connectionFactory()); factory.setConcurrentConsumers(3); //If you want a fixed number of consumers, omit the max. factory.setMaxConcurrentConsumers(10); return factory; } @Bean public RabbitTemplate rabbitTemplate() { RabbitTemplate template = new RabbitTemplate(connectionFactory()); return template; } }

这是我得到的错误

connectionFactory.setUseSsl(true);

为什么找不到 Compilation failure /SpringAmqpConfiguration.java:[24,26] cannot find symbol [ERROR] symbol: method setUseSsl(boolean) [ERROR] location: variable connectionFactory of type org.springframework.amqp.rabbit.connection.CachingConnectionFactory

1 个答案:

答案 0 :(得分:1)

useSsl上没有属性CachingConnectionFactory;基础useSslProtocol 一个com.rabbitmq.client.ConnectionFactory属性。

使用connectionFactory.getRabbitConnectionFactory().useSslProtocol()