Client side configuration when connecting to broker in HA setup
Hi,
Is there any additional configuration that we need to use besides configuring below in the Producer/Consumer code in order to make sure it fails over to other when one fails or releases activity to other.properties.setProperty(JCSMPProperties.HOST, "HOST1,HOST2");
Thanks,
Raghu
Best Answer
-
@rdesoju ,
In addition to setting theJCSMPProperties.HOST
list as you've shown you can also configure retries & timeouts on the JCSMPChannelProperties. The defaults are reasonable for most use cases but it's definitely worth taking a few minutes to consider for your use case.
Properties are defined in the javadocs here: https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/JCSMPChannelProperties.htmlYou can find an example of how some of the properties are logically applied in the "Usage" section of the java docs below the HOST property that you set above. I also quoted it below for convenience.
https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/JCSMPProperties.html#HOSTSome applications might want to have a list of appliances available for connection. Use of a host list allows applications to connect to the alternate connections should the first appliance be unavailable. The host list is configured as a comma-separated list of hosts. Each host can optionally include a port number as well. For example, if there are two appliances at 192.168.160.128 and 192.168.160.129, but the second is using the non-default port 50005 for the message bus, the HOST property would be configured as: "192.168.160.128,192.168.160.129:50005"
When a connection is attempted, the API first attempts to connect to 192.168.160.128. If that connection fails for any reason, it attempts to connect to 192.168.160.129:50005. This process is repeated until all other entries in the host list are attempted.
After each entry has been attempted, and if all fail, the channel properties ConnectRetries, ReconnectRetries, and ReconnectRetryWaitInMillis determine the behavior of the API. If ConnectRetries is non-zero, the API waits for the amount of time set for ReconnectRetryWaitInMillis, then starts its connection attempts again from the beginning of the list. When traversing the list, each entry is attempted the number of times set for the ConnectRetriesPerHost property + 1.
If an established session to any host in the list fails, when ReconnectRetries is non-zero, the API automatically attempts to reconnect, starting at the beginning of the list.
Hope that helps!
6
Answers
-
@rdesoju That's specific to environment, In Some case people use DNS Name instead of IP and Data IP of Both Solace appliance point to one single name (Host) Also whenever fail-over occurred you don't need to change anything on Consumer/Publisher side.
Solace use feature of VRRP for internal fail-over.0 -
@rdesoju ,
In addition to setting theJCSMPProperties.HOST
list as you've shown you can also configure retries & timeouts on the JCSMPChannelProperties. The defaults are reasonable for most use cases but it's definitely worth taking a few minutes to consider for your use case.
Properties are defined in the javadocs here: https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/JCSMPChannelProperties.htmlYou can find an example of how some of the properties are logically applied in the "Usage" section of the java docs below the HOST property that you set above. I also quoted it below for convenience.
https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/JCSMPProperties.html#HOSTSome applications might want to have a list of appliances available for connection. Use of a host list allows applications to connect to the alternate connections should the first appliance be unavailable. The host list is configured as a comma-separated list of hosts. Each host can optionally include a port number as well. For example, if there are two appliances at 192.168.160.128 and 192.168.160.129, but the second is using the non-default port 50005 for the message bus, the HOST property would be configured as: "192.168.160.128,192.168.160.129:50005"
When a connection is attempted, the API first attempts to connect to 192.168.160.128. If that connection fails for any reason, it attempts to connect to 192.168.160.129:50005. This process is repeated until all other entries in the host list are attempted.
After each entry has been attempted, and if all fail, the channel properties ConnectRetries, ReconnectRetries, and ReconnectRetryWaitInMillis determine the behavior of the API. If ConnectRetries is non-zero, the API waits for the amount of time set for ReconnectRetryWaitInMillis, then starts its connection attempts again from the beginning of the list. When traversing the list, each entry is attempted the number of times set for the ConnectRetriesPerHost property + 1.
If an established session to any host in the list fails, when ReconnectRetries is non-zero, the API automatically attempts to reconnect, starting at the beginning of the list.
Hope that helps!
6