Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rabbit credentials might be incomplete / miss virtualhost info #52

Open
imod opened this issue Apr 26, 2019 · 5 comments
Open

rabbit credentials might be incomplete / miss virtualhost info #52

imod opened this issue Apr 26, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@imod
Copy link

imod commented Apr 26, 2019

We deploy or applications on two different CF installations (pivotal and swisscom). The two are different in terms of how the rabbit credentials are defined in VCAP_SERVICES.

The rabbit credentials on pivotal only provide uri and http_api_uri in the credentials, where swisscom also provides things like the very important virtualhost (vhost). Although the virtual host ist also part of the uri on pivotal (last part of the uri), it is quite cumbersome to get hold of it. As a workaround we currently take advantage of the fact that virtualhost is equals to the username when the service is provided by cloudamqp on pivotal.

So our current config looks like this (we fallback to the username in case there is no vhost defined):

@Bean
public ConnectionFactory rabbit(CfEnv cfEnv) {
	// "label" must match name of bound service on CF!
	CfCredentials rabbitCredentials = cfEnv.findCredentialsByName("rabbit");
	CachingConnectionFactory connectionFactory = new CachingConnectionFactory(rabbitCredentials.getHost(), Integer.parseInt(rabbitCredentials.getPort()));
	connectionFactory.setChannelCacheSize(CHANNEL_CACHE_SIZE);
	connectionFactory.setUsername(rabbitCredentials.getUsername());
	connectionFactory.setPassword(rabbitCredentials.getPassword());

	String vhost = StringUtils.isNotBlank(rabbitCredentials.getString("vhost")) ? rabbitCredentials.getString("vhost") : rabbitCredentials.getUsername();
	connectionFactory.setVirtualHost(vhost);

	return connectionFactory;
}

With this issue, I ask you to provide a more reliable way to access the virtualhost also in case where it is only configured in the uri (as in the case on run.pivotal.io). If not possible, I suggest to add some kind of documentation about this.
...btw, this did not make any difference with the old cloud connector api - everything was picked up automatically and was working fine.

VCAP_SERVICES details:
on run.pivotal.io, service provided by cloudamqp:

...
"cloudamqp": [
        {
          "label": "cloudamqp",
          "provider": null,
          "plan": "tiger",
          "name": "rabbit",
          "tags": [
            "amqp",
            "rabbitmq"
          ],
          "instance_name": "rabbit",
          "binding_name": null,
          "credentials": {
            "uri": "amqp://xxxxx:[email protected]/xxxxx",
            "http_api_uri": "https://xxxxx:[email protected]/api/"
          },
          "syslog_drain_url": null,
          "volume_mounts": []
        }
      ]
    }
...

swisscom, service provided by swisscom:

    "rabbitmqent": [
      {
        "label": "rabbitmqent",
        "provider": null,
        "plan": "usage",
        "name": "rabbit",
        "tags": [
          "rabbitmq"
        ],
        "instance_name": "rabbit",
        "binding_name": null,
        "credentials": {
          "uri": "amqp://xxxxx:[email protected]/vvvvvvvvvvvv",
          "uris": [
            "amqp://xxxxx:[email protected]/vvvvvvvvvvvv",
            "amqp://xxxxx:[email protected]/vvvvvvvvvvvv",
            "amqp://xxxxx:[email protected]/vvvvvvvvvvvv"
          ],
          "vhost": "vvvvvvvvvvvv",
          "username": "xxxxx",
          "password": "pppppppppp",
          "hostname": "rabbitmq.service.consul",
          "hostnames": [
            "node-0.service.consul",
            "node-1.service.consul",
            "node-2.service.consul"
          ],
          "port": 5672,
          "amqp_port": 5672,
          "mqtt_port": 1883,
          "stomp_port": 61613,
          "management_port": 15672,
          "http_api_uri": "http://xxxxx:[email protected]:15672/api",
          "http_api_uris": [
            "http://xxxxx:[email protected]:15672/api",
            "http://xxxxx:[email protected]:15672/api",
            "http://xxxxx:[email protected]:15672/api"
          ],
          "protocols": {
            "amqp": {
              "username": "xxxxx",
              "password": "pppppppppp",
              "port": 5672,
              "host": "rabbitmq.service.consul",
              "hosts": [
                "node-0.service.consul",
                "node-1.service.consul",
                "node-2.service.consul"
              ],
              "uri": "amqp://xxxxx:[email protected]/vvvvvvvvvvvv",
              "uris": [
                "amqp://xxxxx:[email protected]/vvvvvvvvvvvv",
                "amqp://xxxxx:[email protected]/vvvvvvvvvvvv",
                "amqp://xxxxx:[email protected]/vvvvvvvvvvvv"
              ],
              "vhost": "vvvvvvvvvvvv"
            },
            "http": {
              "username": "xxxxx",
              "password": "pppppppppp",
              "port": 15672,
              "host": "rabbitmq.service.consul",
              "hosts": [
                "node-0.service.consul",
                "node-1.service.consul",
                "node-2.service.consul"
              ],
              "uri": "http://xxxxx:[email protected]/vvvvvvvvvvvv",
              "uris": [
                "http://xxxxx:[email protected]/vvvvvvvvvvvv",
                "http://xxxxx:[email protected]/vvvvvvvvvvvv",
                "http://xxxxx:[email protected]/vvvvvvvvvvvv"
              ],
              "vhost": "vvvvvvvvvvvv"
            },
            "mqtt": {
              "username": "vvvvvvvvvvvv:xxxxx",
              "password": "pppppppppp",
              "port": 1883,
              "host": "rabbitmq.service.consul",
              "hosts": [
                "node-0.service.consul",
                "node-1.service.consul",
                "node-2.service.consul"
              ],
              "uri": "mqtt://vvvvvvvvvvvv%3Axxxxx:[email protected]",
              "uris": [
                "mqtt://vvvvvvvvvvvv%3Axxxxx:[email protected]",
                "mqtt://vvvvvvvvvvvv%3Axxxxx:[email protected]",
                "mqtt://vvvvvvvvvvvv%3Axxxxx:[email protected]"
              ]
            },
            "stomp": {
              "username": "xxxxx",
              "password": "pppppppppp",
              "port": 61613,
              "host": "rabbitmq.service.consul",
              "hosts": [
                "node-0.service.consul",
                "node-1.service.consul",
                "node-2.service.consul"
              ],
              "uri": "stomp://xxxxx:[email protected]",
              "uris": [
                "stomp://xxxxx:[email protected]",
                "stomp://xxxxx:[email protected]",
                "stomp://xxxxx:[email protected]"
              ],
              "vhost": "vvvvvvvvvvvv"
            },
            "management": {
              "uri": "http://xxxxx:[email protected]:15672/api",
              "uris": [
                "http://xxxxx:[email protected]:15672/api",
                "http://xxxxx:[email protected]:15672/api",
                "http://xxxxx:[email protected]:15672/api"
              ],
              "username": "xxxxx",
              "password": "pppppppppp",
              "host": "rabbitmq.service.consul",
              "hosts": [
                "node-0.service.consul",
                "node-1.service.consul",
                "node-2.service.consul"
              ],
              "port": 15672,
              "path": "/api",
            }
          }
@imod imod changed the title rabbit might be credentials incomplete rabbit credentials might be incomplete / miss virtualhost info Apr 26, 2019
@markpollack
Copy link
Collaborator

Great feedback, thanks, will address!

@markpollack markpollack added this to the 1.1.0.RC1 milestone May 31, 2019
@markpollack markpollack self-assigned this May 31, 2019
@imod
Copy link
Author

imod commented Jun 3, 2019

something along CfEnvJdbc for Rabbit would be great :)

@markpollack
Copy link
Collaborator

It is going to take a bit longer to figure this one out, so removing the assigned milestone 1.1.0.RC1

@markpollack markpollack removed this from the 1.1.0.RC1 milestone Jun 11, 2019
@pivotal-david-osullivan pivotal-david-osullivan added the enhancement New feature or request label Apr 7, 2022
@pivotal-david-osullivan
Copy link
Member

@imod Revisiting this issue, since the run.pivotal.io service is no longer active, is there any problem accessing the vhost on Swisscom or other providers?

@imod
Copy link
Author

imod commented Apr 13, 2022

@pivotal-david-osullivan thanks for asking - we moved away from CF, so I don't have the issue anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants