spring-projects/spring-boot — pull request #1617 by hekonsek (2014-09-25 11:13:56+00:00)
Title: AMQ connection URL autodetection.

Hi,

I'm working with the ActiveMQ projects and customers on the daily basis, so I'd like to propose some enhancement to the AMQ autoconfiguration.

From my experience ActiveMQ users tend to follow this usage pattern of the client connection URL:
- for tests they use `vm` transport, no matter what transport is used in the production
- for non-test environments, if there is some additional transport jar available in the classpath, then it is very likely that the user would use that transport for the AMQ client connection. For example presence of the `activemq-mqtt.jar` in the classpath indicates that MQTT connection will be used.
- for non-test environments, if there is no additional AMQ transport jar available, then use plain old TCP connection

Currently Spring Boot defaults to VM transport. Actually I don't think that this is the best default, as from my experience there are not so many non-test situations where AMQ users would like to connect to the embedded broker instead of the external one. This is especially true for Spring Boot apps, which usually aren't deployed into servers shipped with the broker, but are rather executed as fat jars.

I propose the following defaults:
a) connect to `tcp://localhost:61616` for non-tests environments
b) connect to `vm` for the test environment
c) for non-tests environments, try to detect if some other common AMQ transports are available in the classpath. If so, then Spring Boot should try to use them. For example presence of the `activemq-mqtt` jar in the classpath should result in connection URL defaulting to `mqtt://localhost:1883`

I've created a proof of concept demonstrating the approach I'm thinking about. Any thoughts? :)

Cheers.