Re: No suitable ServiceConnectorCreator found trying to connect to RabbitMQ

Scott Frederick <scottyfred@...>

It looks like the main problem is the type of connection bean you are
expecting Spring Cloud Connectors to create. In the PivotalConfig class,
you have this:

import com.rabbitmq.client.ConnectionFactory;

public class PivotalConfig extends AbstractCloudConfig{
public ConnectionFactory rabbitConnectionFactory(){

return cloud.getServiceConnector(serviceId,
ConnectionFactory.class, null);

The spring-cloud-spring-service-connector module of Spring Cloud Connectors
expects to work with Spring types. In the the case of a RabbitMQ
connection, it will create a
org.springframework.amqp.rabbit.connection.ConnectionFactory, not a
com.rabbitmq.client.ConnectionFactory. If you change this import, and the
matching one in FilePoller, you should get past this error.

If you are extending AbstractCloudConfig in your @Configuration class, you
can write much less code to get the same result. The PivotalConfig class
can look like this:

public class PivotalConfig extends AbstractCloudConfig {
public ConnectionFactory rabbitConnectionFactory(){
return connectionFactory.rabbitConnectionFactory();

The name of the service instance isn’t required if you only have one
service of that type bound to your application. If you had more than one
RabbitMQ service bound to the app then you can do return connectionFactory.
rabbitConnectionFactory(“JasonMCFTest-rabbit”) instead.


On Wed, Dec 2, 2015 at 11:57 AM, Jason Brown <jasbro(a)> wrote:

I'm trying to connect to RabbitMQ from our Pivotal CloudFoundry
environment and I can't get it to work. The only artifact I don't have in
my pom is org.cloudfoundry:auto-reconfiguration:1.7.0.RELEASE (or whatever
version is current). The error I get in logs is:
2015-12-02T10:12:58.19-0700 [App/0] OUT Caused by: No suitable
ServiceConnectorCreator found: service id=JasonMCFTest-rabbit, service info, connector
type=class com.rabbitmq.client.ConnectionFactory

The following classes are my config class and a simple component that
tries to autowire my rabbit bean. I'm also pretty new to Spring, so feel
free to bash that too.
package com.jasbro.mcftest;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.rabbitmq.client.ConnectionFactory;

public class PivotalConfig extends AbstractCloudConfig{
public ConnectionFactory rabbitConnectionFactory(){
CloudFactory cloudFactory = new CloudFactory();
Cloud cloud = cloudFactory.getCloud();
AmqpServiceInfo serviceInfo = (AmqpServiceInfo)
String serviceId = serviceInfo.getId();
return cloud.getServiceConnector(serviceId,
ConnectionFactory.class, null);

package com.jasbro.mcftest.scheduled;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.rabbitmq.client.ConnectionFactory;

public class FilePoller {
private ConnectionFactory rabbitConnectionFactory;

And here is the service listing showing (I think) that rabbit is set up
and bound to my app.
C:\src\main\JasonMCFTest>cf s
Getting services in org crt / space dev as jason.c.brown...

name service plan bound apps last
JasonMCFTest-rabbit p-rabbitmq standard JasonMCFTest create

Lastly, the list of dependencies from my pom (some of these are probably
not needed, but I don't know which):

Join { to automatically receive all group messages.