pivotal-cf / java-cfenv

Apache License 2.0
94 stars 59 forks source link

java-cfenv-boot RabbitMQ support on IBM Cloud #69

Open Rainer-krueger opened 5 years ago

Rainer-krueger commented 5 years ago

I am trying to use this lib on IBM Cloud for a Spring Boot/Cloud App but the RabbitMQ Config is not recognized. IBM Cloud use "messages-for-rabbitmq" as VCAP Label. It's use also a mandatory client SSL Certificate that I guess ist not supported in java-cfenv-boot.

Here is my VCAP Json:

{
    "messages-for-rabbitmq": [
        {
            "label": "messages-for-rabbitmq",
            "provider": null,
            "plan": "standard",
            "name": "RabbitMQ",
            "tags": [
                "data_management",
                "ibm_created",
                "rc_compatible",
                "ibmcloud-alias"
            ],
            "instance_name": "RabbitMQ",
            "binding_name": null,
            "credentials": {
                "connection": {
                    "amqps": {
                        "authentication": {
                            "method": "direct",
                            "password": "xxxxx",
                            "username": "xxxx"
                        },
                        "certificate": {
                            "certificate_base64": "xxxxx",
                            "name": "45dc1d70-521a-11e9-8c84-xxxx"
                        },
                        "composed": [
                            "amqps://ibm_user:xxxxx@xxxxx.xxxxxxxxx.databases.appdomain.cloud:30301"
                        ],
                        "hosts": [
                            {
                                "hostname": "xxxxx.xxxxxxxxx.databases.appdomain.cloud",
                                "port": 30301
                            }
                        ],
                        "path": "",
                        "query_options": {},
                        "scheme": "amqps",
                        "type": "uri"
                    },
                    "cli": {
                        "arguments": [
                            [
                                "--username=ibm_user",
                                "--password=xxxxxx",
                                "--ssl",
                                "--ssl-ca-cert-file=xxxxxxx",
                                "--host=xxxxxxx.databases.appdomain.cloud",
                                "--port=32689"
                            ]
                        ],
                        "bin": "rabbitmqadmin",
                        "certificate": {
                            "certificate_base64": "xxxxxxx",
                            "name": "xxxxxxx"
                        },
                        "composed": [
                            "rabbitmqadmin --username=ibm_user --password=xxxxxx --ssl --ssl-ca-cert-file=xxxxxxx --host=xxxxxxx.databases.appdomain.cloud --port=32689"
                        ],
                        "environment": {},
                        "type": "cli"
                    },
                    "https": {
                        "authentication": {
                            "method": "direct",
                            "password": "xxxxxx",
                            "username": "ibm_user"
                        },
                        "browser_accessible": true,
                        "certificate": {
                            "certificate_base64": "xxxxxxx",
                            "name": "xxxxxxx"
                        },
                        "composed": [
                            "https://ibm_user:xxxxxx@xxxxxxx.databases.appdomain.cloud:32689"
                        ],
                        "hosts": [
                            {
                                "hostname": "xxxxxxx.databases.appdomain.cloud",
                                "port": 32689
                            }
                        ],
                        "path": "",
                        "query_options": {},
                        "scheme": "https",
                        "type": "uri"
                    },
                    "stomp_ssl": {
                        "authentication": {
                            "method": "direct",
                            "password": "xxxxxx",
                            "username": "ibm_user"
                        },
                        "certificate": {
                            "certificate_base64": "xxxxxxx",
                            "name": "xxxxxxx"
                        },
                        "composed": [
                            "--username=ibm_user --password=xxxxxx --ssl=true --host=xxxxxxx.databases.appdomain.cloud --port=32333"
                        ],
                        "hosts": [
                            {
                                "hostname": "xxxxxxx.databases.appdomain.cloud",
                                "port": 32333
                            }
                        ],
                        "ssl": true,
                        "type": "stomp"
                    }
                },
                "instance_administration_api": {
                    "deployment_id": "crn:v1:bluemix:public:messages-for-rabbitmq:eu-de:a/xxxx:xxxx::",
                    "instance_id": "crn:v1:bluemix:public:messages-for-rabbitmq:eu-de:a/xxxxx:xxxx::",
                    "root": "https://api.eu-de.databases.cloud.ibm.com/v4/ibm"
                }
            },
            "syslog_drain_url": null,
            "volume_mounts": []
        }
    ]
}

Thank you and best regards Rainer Krüger

markpollack commented 5 years ago

The current support for Rabbit is based on the format of VCAP_SERVICES that is created when using https://docs.pivotal.io/rabbitmq-cf/1-17/ tile from Pivotal. Unfortunately, there is no standard schema that defines how the credentials should be populated. The accept method is looking for tags relating to the Pivotal tile. To support the IBM tile you would have to create your own CfEnvProcessor that would work for the set of tags/credentails that IBM creates. I don't think that I could reliably implement such a class but would very much welcome a contribution.

gfoster1 commented 4 years ago

@Rainer-krueger See the following processor [1] and example [2].

Thanks for bringing this up and please let me know if you have feedback.

[1] https://github.com/IBM/ibmcloud-cfenv-processors/tree/master/processors/amqp-cfenv-processor [2] https://github.com/IBM/ibmcloud-cfenv-processors/tree/master/samples/amqp-mongo-kafka