Connecting to RabbitMQ¶
This section describes how to configure WSO2 Micro Integrator to connect with RabbitMQ.
Tip
See the complete list of server-level configurations for the RabbitMQ Listener and RabbitMQ Sender in the deployment.toml
file (stored in the MI_HOME/conf
directory).
Setting up RabbitMQ¶
Please refer RabbitMQ Deployment
Enabling the RabbitMQ Listener¶
Uncomment the following parameters in the deployment.toml
file to configure the RabbitMQ listener.
[[transport.rabbitmq.listener]]
name = "AMQPConnectionFactory"
parameter.hostname = "localhost"
parameter.port = 5672
parameter.username = "guest"
parameter.password = "guest"
Enabling the RabbitMQ Sender¶
Uncomment the following parameters in the deployment.toml
file to enable the RabbitMQ sender.
[transport.rabbitmq]
sender_enable = true
Enabling SSL¶
Add the following parameters to enable SSL for the RabbitMQ listener.
[[transport.rabbitmq.listener]]
parameter.ssl_enable = true
parameter.ssl_version = "SSL"
Tip
Note that keystore information is not required for an SSL connection if the fail_if_no_peer_cert
parameter is set to false
in the RabbitMQ broker. You only need to enable SSL in the Micro Integrator (using the parameter.ssl_enable
parameter shown above). You can check the fail_if_no_peer_cert
parameter in the rabbitmq.conf
file in its OS-specific location.
Shown below is an example of the configuration file where fail_if_no_peer_cert
is set to false
:
ssl_options.cacertfile = /path/to/ca_certificate.pem
ssl_options.certfile = /path/to/server_certificate.pem
ssl_options.keyfile = /path/to/server_key.pem
ssl_options.verify = verify_peer
ssl_options.fail_if_no_peer_cert = false
However, if the fail_if_no_peer_cert
parameter is set to true
in RabbitMQ, the keystore configurations (given below) are also required for the Micro Integrator.
parameter.keystore_location ="repository/resources/security/wso2carbon.jks"
parameter.keystore_type = "JKS"
parameter.keystore_password = "wso2carbon"
parameter.truststore_location ="repository/resources/security/client-truststore.jks"
parameter.truststore_type = "JKS"
parameter.truststore_password = "wso2carbon"
Configuring connection recovery¶
Add the following parameters under the RabbitMQ to the deployment.toml file (stored in the MI_HOME/conf
directory).
[[transport.rabbitmq.listener]]
parameter.retry_interval = "10"
parameter.retry_count = 5
In case of a network failure or broker shutdown, WSO2 Micro Integrator will try to recreate the connection. The following parameters need to be configured in the transport listener to enable connection recovery in RabbitMQ.
If the parameters specified above are set, the Micro Integrator will retry 5 times with 10000 ms time intervals to reconnect when the connection is lost. If reconnecting also fails, the Micro Integrator will terminate the connection. If you do not specify values for the above parameters, the Micro Integrator uses 30000ms as the default retry interval and 3 as the default retry count.
Optionally, you can configure the following parameter in your proxy service when you define your mediation sequence:
<parameter name="rabbitmq.server.retry.interval" locked="false">10000</parameter>
The parameter specified above sets the retry interval with which the RabbitMQ client tries to reconnect. Generally having this value less than the value specified as rabbitmq.connection.retry.interval
will help synchronize the reconnection of the Micro Integrator and the RabbitMQ client.
Configuring high throughput of message delivery¶
For increased performance and higher throughput in message delivery, configure the transport sender as shown below.
Add the following parameters under the RabbitMQ to the deployment.toml file (stored in the MI_HOME/conf
directory).
[[transport.rabbitmq.sender]]
name = "CachedRabbitMQConnectionFactory"
parameter.hostname = "localhost"
parameter.port = 5672
parameter.username = "guest"
parameter.password = "guest"
rabbitmq.connection.factory=CachedRabbitMQConnectionFactory
.
Configure proxy-level throttling¶
To enable throttling for the RabbitMQ proxy service listener, you can add the following configuration to the proxy service:
<parameter name="rabbitmq.proxy.throttle.enabled">true</parameter>
<parameter name="rabbitmq.proxy.throttle.mode">fixed_interval</parameter>
<parameter name="rabbitmq.proxy.throttle.timeUnit">minute</parameter>
<parameter name="rabbitmq.proxy.throttle.count">60</parameter>
Note
Allowed parameters for rabbitmq.proxy.throttle.mode
: fixed_interval, batch
Allowed parameters for rabbitmq.proxy.throttle.timeUnit
: minute, hour, day
When enabling throttling for the RabbitMQ proxy service listener, to ensure that the message consumer retrieves only one message at a time from the RabbitMQ queue, you can add the following properties to the proxy service. This will avoid potential data loss if the server is restarted.
<parameter name="rabbitmq.channel.consumer.qos">1</parameter>
<parameter name="rabbitmq.queue.auto.ack">false</parameter>
The following table provides information on the proxy-level throttling parameters:
Parameter Name | Description | Required | Possible Values |
---|---|---|---|
rabbitmq.proxy.throttle.enabled |
Use this parameter to enable JMS message throttling at the proxy service level.
When enabled, the default throttle limit (rabbitmq.proxy.throttle.count ) is 60 messages per minute and the default throttle mode (jms.proxy.throttle.mode ) is fixed_interval .
That is, a maximum of 60 messages can be consumed per minute at a fixed rate of one message per second.
|
No | true ,false |
rabbitmq.proxy.throttle.timeUnit |
The time unit refers to the time period over which the allowed number of messages (throttling count) is measured. It defines the interval during which the rate of requests from a client is controlled.
For example, if you set the throttling count to 1000 and the time unit to minute, it will count the number of requests in each minute. If the messages received from RabbitMQ exceed 1000 within that minute, no more messages will be received until the next minute starts. The default time unit is MINUTE .
|
No |
minute ,hour ,day
|
rabbitmq.proxy.throttle.count |
The throttle count specifies the maximum number of messages that can be consumed per minute by the proxy service. The default throttle count is 60 when throttling is enabled. Note that the actual throttle limit will be equal to or less than the value specified by the throttle limit parameter depending on the time taken for message mediation. For example, if the throttle limit is 60 and if each message takes more than one second for mediation, the total number of messages that can be consumed during the one-minute window will always be less than 60. | No | Any positive integer |
rabbitmq.proxy.throttle.mode |
The throttle mode specifies whether or not messages should be consumed at a fixed rate during configured timeUnit .
The default throttle mode is fixed_interval when throttling is enabled.
|
No |
|