Skip to content

Commit

Permalink
Exclude self from static cluster connectors
Browse files Browse the repository at this point in the history
The static-connectors of a cluster should not contain this brokers'
own connector as it will happily connect to itself and thus not
properly participate in the cluster.

Also added an option to configure allow-direct-connections-only and
set it to false. This would allow a cluster to become dynamic using
an initial static list.
  • Loading branch information
Michiel Hendriks committed Nov 13, 2023
1 parent 213248c commit 1af323f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
11 changes: 11 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ The following parameters are available in the `activemq::instance` defined type:
* [`address_settings`](#-activemq--instance--address_settings)
* [`addresses`](#-activemq--instance--addresses)
* [`allow_failback`](#-activemq--instance--allow_failback)
* [`allow_direct_connections_only`](#-activemq--instance--allow_direct_connections_only)
* [`bind`](#-activemq--instance--bind)
* [`broadcast_groups`](#-activemq--instance--broadcast_groups)
* [`broker_plugins`](#-activemq--instance--broker_plugins)
Expand Down Expand Up @@ -478,6 +479,16 @@ Data type: `Boolean`

Should stop backup on live restart.

##### <a name="-activemq--instance--allow_direct_connections_only"></a>`allow_direct_connections_only`

Data type: `Optional[Boolean]`

When using `static` for [`server_discovery`](#-activemq--server_discovery)
only make connections to the defined connectors and not any other
broker in the cluser.

Default value: `true`

##### <a name="-activemq--instance--bind"></a>`bind`

Data type: `String`
Expand Down
6 changes: 6 additions & 0 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
# @param allow_failback
# Should stop backup on live restart.
#
# @param allow_direct_connections_only
# When using static server discovery only make connections to the
# defined connectors and not any other broker in the cluser.
#
# @param bind
# Configure which IP address to listen on. Should be either a FQDN
# or an IP address.
Expand Down Expand Up @@ -167,6 +171,7 @@
String $java_xms = $activemq::java_xms,
String $java_xmx = $activemq::java_xmx,
# Optional parameters
Optional[Boolean] $allow_direct_connections_only = true,
Optional[Integer] $global_max_size_mb = undef,
Optional[String] $group = undef,
Optional[Boolean] $service_enable = undef,
Expand Down Expand Up @@ -379,6 +384,7 @@
'address_settings' => $address_settings,
'addresses' => $addresses,
'allow_failback' => $allow_failback,
'allow_direct_connections_only' => $allow_direct_connections_only,
'bind' => $bind,
'broadcast_groups' => $broadcast_groups,
'broker_plugins' => $_broker_plugins,
Expand Down
5 changes: 4 additions & 1 deletion templates/broker.xml.epp
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,12 @@ under the License.
<message-load-balancing><%= $message_load_balancing %></message-load-balancing>
<max-hops><%= $max_hops %></max-hops>
<% if $activemq::server_discovery == 'static' { -%>
<static-connectors allow-direct-connections-only="true">
<static-connectors allow-direct-connections-only="<%= $allow_direct_connections_only %>">
<% $connectors.each |$key, $value| { -%>
<%# # Do not add the connector that matches the name of this instance. -%>
<% if ($key != "artemis-${name}") { -%>
<connector-ref><%= $key %></connector-ref>
<% } -%>
<% } -%>
</static-connectors>
<% } -%>
Expand Down

0 comments on commit 1af323f

Please sign in to comment.