question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support amqps:// URIs in spring.rabbitmq.addresses

See original GitHub issue

I can connect to a RabbitMQ over amqp+ssl by setting these properties:

spring.rabbitmq.host: 10.0.0.123
spring.rabbitmq.password: password
spring.rabbitmq.port: 5671
spring.rabbitmq.ssl.enabled: true
spring.rabbitmq.username: user
spring.rabbitmq.virtualHost: virtualhost

I would expect that this would work as well

spring.rabbitmq.addresses: amqps://user:password@10.0.0.123/virtualhost

But https://github.com/spring-projects/spring-boot/blob/v1.3.6.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java#L118 doesn’t handle the amqps scheme. See https://www.rabbitmq.com/uri-spec.html for the spec on the amqps URI scheme.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
garyrussellcommented, Oct 25, 2017

You can override boot’s auto configured connection factory.

@SpringBootApplication
public class So46937522Application {

	public static void main(String[] args) {
		SpringApplication.run(So46937522Application.class, args);
	}

	@Bean
	public CachingConnectionFactory rabbitConnectionFactory(RabbitProperties config)
			throws Exception {
		CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
		connectionFactory.getRabbitConnectionFactory().setUri("amqps://guest:guest@10.0.0.3:5671/virtualhost");
		return connectionFactory;
	}

	@RabbitListener(queues = "si.test.queue")
	public void listen(Message in) {
		System.out.println(in);
	}

}
4reactions
swagataroycommented, Jul 29, 2016

I had a similar issue while deploying a Spring AMQP app on PCF. With the current RabbitMQ Java client, the default SSL Protocol is TLSv1 and that errors out when TLS 1 is disabled from the PCF-Rabbit tile. I had to add the following properties -

spring.rabbitmq.host=${vcap.services.swagataRMQService1.credentials.hostname}
spring.rabbitmq.port=5671
spring.rabbitmq.virtual-host=${vcap.services.swagataRMQService1.credentials.vhost}
spring.rabbitmq.username=${vcap.services.swagataRMQService1.credentials.username}
spring.rabbitmq.password=${vcap.services.swagataRMQService1.credentials.password}
spring.rabbitmq.ssl.enabled=${vcap.services.swagataRMQService1.credentials.ssl}
spring.rabbitmq.ssl.algorithm=TLSv1.2

I was hoping that only adding the following would resolve my issue -

spring.rabbitmq.addresses=${vcap.services.swagataRMQService1.credentials.uri}

Please note that the uri property from VCAP_SERVICES is as follows -

"uri": "amqps://2249d8f6-52c2-4dc7-8f37-67717d75cf79:6mv0o1rsup2e5m12k188jne1hj@10.64.53.68/ff8ca300-59b4-467b-9c39-9a2df7dceeeb",

The code here - https://github.com/spring-projects/spring-boot/blob/v1.3.6.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java#L122 needs to check for amqps also and the port should be set to 5671 for amqps

Read more comments on GitHub >

github_iconTop Results From Across the Web

RabbitMQ URI Specification
This specification defines an "amqp" URI scheme. Conforming URIs represent the information needed by AMQP 0-9-1 clients as well as some RabbitMQ plugins...
Read more >
Spring AMQP
The Spring AMQP project applies core Spring concepts to the development of AMQP-based messaging solutions. We provide a “template” as a high-level ...
Read more >
Access amqp_URI from spring boot application.properties file
I need access to this server from Spring boot application.properties file. I have tried spring.rabbitmq.addresses property .But no luck.
Read more >
spring-projects/spring-amqp - Gitter
I am currently trying to come up with a spring-amqp integration for spring-cloud-contract. ... No, it's not currently supported; I opened a JIRA...
Read more >
RabbitMQ Message Dispatching with Spring AMQP - Baeldung
We can modify this and other defaults in application.yaml. Our project exposes HTTP endpoint on the URI – /broadcast – that accepts POSTs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found