rabbit credentials might be incomplete / miss virtualhost info
@markpollack is already working on this.
Since May 31, 2019.
Assessment
This issue has not been assessed yet.
Description
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",
}
}
- Dominant language
- Java
- Stars
- 97
- Forks
- 64
- Avg merge
- 10h 45m
- Merged PRs (30d)
- 8
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pivotal-cf/java-cfenv
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
pivotal-cf/java-cfenv#354 · 1 reaction ·
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 48/100
pivotal-cf/java-cfenv#296 · 3 reactions ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
pivotal-cf/java-cfenv#292 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
pivotal-cf/java-cfenv#255 · 2 comments ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
pivotal-cf/java-cfenv#249 · 2 comments ·
All issues in pivotal-cf/java-cfenv
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenAPITools/openapi-generator#25014 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
AloisSeckar/demos-java#380 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openhab/openhab-core#5847 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
appsmithorg/appsmith#42297 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100