12.4. Map Client Connections to Broker Instances
Map Client Connections to Broker Instances
The MQ Gateway includes a configuration PID,
io.fabric8.gateway.detecting
. It sets the following properties:
# configures the protocol detecting gateway port=61616 httpEnabled=true openWireEnabled=true stompEnabled=true mqttEnabled=true amqpEnabled=true sslEnabled=false defaultVirtualHost=default zooKeeperPath=/fabric/registry/clusters/amq loadBalancerType=roundrobin stickyLoadBalancerCacheSize=10000
The
defaultVirtualHost
setting is used to specify the broker group name to be used by default for all clients. For example, if you have a Fabric broker group called us-east
, with one or more broker instances running under this group (created using mq-create -group us-east
). You can configure defaultVirtualHost
to be us-east using the setting defaultVirtualHost=us-east
.
How to Connect to a Specific Broker on the MQ Gateway
You can map to a broker group other than the default specified in
defaultVirtualHost
.
For example, if you had a broker group called
us-west
, set up in the same way as us-east
above, you can map directly to it by configuring the MQ Gateway in the following way:
- Set up the Fabric broker group
us-west
usingmq-create -group us-west
- Add the Fabric broker group name
us-west
as a virtual hostname for the machine that runs your MQ Gateway. This will require proper DNS configuration so that this virtual hostname can be resolved by any client. - When your broker clients contact the MQ Gateway, use the hostname
us-west
in the broker url. For example,tcp://us-west:61616
The Gateway will map the request it receives via the virtual hostname
us-west
to one of your broker instances in the broker group us-west
.
An alternative approach to that shown above is to define multiple instances of MQ Gateway. Configure each instance to a different default broker group in
defaultVirtualHost
and have broker clients explicitly connect to the instance of MQ Gateway that will bridge clients to the specific broker group.
For OpenWire only, you can use the following parameter to specify which broker group you want to be connected to:
?wireFormat.host=groupname
If this command parameter is not specified, then the request is directed to the value in
defaultVirtualHost
.
MQ Gateway Client Connections for For Openwire and STOMP
An MQ Gateway can have its services exposed over multiple host names. When it receives a connection request, it uses the host the client was trying to connect to to look up a broker fabric group by the same name. The client is then connected to one of the brokers in the group that supports the protocol the client is connecting with. If the host the client is trying to connect to cannot be determined or does not match any of the fabric broker groups, then the client will be connected to a broker group that matches the
defaultVirtualHost
configuration.
AMQP and MQTT connections do not pass the hostname information so they always connect to the broker group that matches the
defaultVirtualHost
configuration.
Using MQ Gateway with SSL/HTTPS
The HTTP gateway does not directly support SSL/HTTPS, but the MQ Gateway does. If MQ Gateway is deployed alongside the HTTP Gateway, it will re-direct the decrypted http traffic to the HTTP Gateway.
Configuration changes need to be made to accommodate SSL/HTTPS. Edit
io.fabric8.gateway.detecting
to change the following properties:
sslEnabled=true trustStoreURL must be configured along with trustStorePassword keyStoreURL must be configured along with keyStorePassword keyAlias keyPassword
You can also optionally configure the following properties:
sslProtocol, sslStoreType, sslAlgorithm, enabledCipherSuites, disabledCypherSuites
Change the Listening Port on MQ Gateway
To change the listening port on MQ Gateway, edit io.fabric8.gateway.detecting using the following command:
profile-edit --pid io.fabric8.gateway.detecting/port=61619 gateway-mq or gateway_mq profile -> configurations -> Detecting Gateway -> Bind Port on