How to start multiple Artemis brokers inside Red Hat JBoss EAP-7 container in Master/Slave fashion

To be as simple as possible, we will walk through a stand-alone use-case.

Usually, when we require having messaging features in our stand-alone environment, we use full profile for EAP container.

If we have a requirement with clustering functionalities then we prefer to have HA profile but if clustering and messaging both are required then we go for a full-HA profile.

By default with a full/full-HA profile, EAP-7 container provides us the default configuration for the embedded Artemis Broker with default configuration. But, in certain scenarios, people might have a requirement for the additional broker inside the same EAP-7 container. In such cases, I recommend having separate connector mapping for additional Artemis Broker.

First, create the socket-binding entry inside the socket-binding-group for an additional Artemis broker:

<socket-binding name="http-2" port="${jboss.http.port:8180}" />

Here, I am creating http-2 as socket-binding for additional Artemis. Artemis uses http port 8080 for communication by default. However, it will be occupied when we will start our EAP-7 server hence to avoid conflict, I added an additional socket for the second instance of Artemis in a container.

Next, is to rename the existing default Artemis server/broker to identify between multiple instances. I am trying to set up master-slave topology and hence I am setting up server name as ‘master’.

<server name="master">

Then I copy the same server and pasted inside messaging subsystem with a name as a backup.

<server name="backup">

<security-setting name="#">

<role name="guest" send="true" consume="true" create-non-durable-queue="true" delete-non-durable-queue="true"/>

</security-setting>

<address-setting name="#" dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" page-size-bytes="2097152" message-counter-history-day-limit="10"/>

<http-connector name="http-connector-2" socket-binding="http-2" endpoint="http-acceptor-2"/>

<http-connector name="http-connector-throughput-2" socket-binding="http" endpoint="http-acceptor-throughput-2">

<param name="batch-delay" value="50"/>

</http-connector>

<in-vm-connector name="in-vm" server-id="1"/>

<http-acceptor name="http-acceptor-2" http-listener="default"/>

<http-acceptor name="http-acceptor-throughput-2" http-listener="default">

<param name="batch-delay" value="50"/>

<param name="direct-deliver" value="false"/>

</http-acceptor>

<in-vm-acceptor name="in-vm" server-id="1"/>

<jms-queue name="ExpiryQueue-2" entries="java:/jms/queue/ExpiryQueue-2"/>

<jms-queue name="DLQ-2" entries="java:/jms/queue/DLQ-2"/>

<connection-factory name="InVmConnectionFactory-2" connectors="in-vm" entries="java:/ConnectionFactory-2"/>

<connection-factory name="RemoteConnectionFactory-2" connectors="http-connector-2" entries="java:jboss/exported/jms/RemoteConnectionFactory-2"/>

<pooled-connection-factory name="activemq-ra-2" transaction="xa" connectors="in-vm" entries="java:/JmsXA-2 java:jboss/DefaultJMSConnectionFactory-2"/>

</server>

After this step, I thought to have a master and execute below command to make both the brokers in master-slave fashion:

$ /subsystem=messaging-activemq/server=master/ha-policy=shared-store-master:add(failover-on-server-shutdown=true)

$ /subsystem=messaging-activemq/server=backup/ha-policy=shared-store-slave:add(allow-failback=true,restart-backup=true,failover-on-server-shutdown=true)

The entire configuration of the messaging subsystem is as below:

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
 <server name="master">
 <shared-store-master failover-on-server-shutdown="true"/>
 <security-setting name="#">
 <role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/>
 </security-setting>
 <address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/>
 <http-connector name="http-connector" endpoint="http-acceptor" socket-binding="http"/>
 <http-connector name="http-connector-throughput" endpoint="http-acceptor-throughput" socket-binding="http">
 <param name="batch-delay" value="50"/>
 </http-connector>
 <in-vm-connector name="in-vm" server-id="0"/>
 <http-acceptor name="http-acceptor" http-listener="default"/>
 <http-acceptor name="http-acceptor-throughput" http-listener="default">
 <param name="batch-delay" value="50"/>
 <param name="direct-deliver" value="false"/>
 </http-acceptor>
 <in-vm-acceptor name="in-vm" server-id="0"/>
 <jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
 <jms-queue name="myQueue" entries="java:/jms/queue/myQueue"/>
 <jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
 <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
 <connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>
 <pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="in-vm"/>
 </server>
 <server name="backup">
 <shared-store-slave failover-on-server-shutdown="true"/>
 <security-setting name="#">
 <role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" consume="true" send="true"/>
 </security-setting>
 <address-setting name="#" message-counter-history-day-limit="10" page-size-bytes="2097152" max-size-bytes="10485760" expiry-address="jms.queue.ExpiryQueue" dead-letter-address="jms.queue.DLQ"/>
 <http-connector name="http-connector-2" endpoint="http-acceptor-2" socket-binding="http-2"/>
 <http-connector name="http-connector-throughput-2" endpoint="http-acceptor-throughput-2" socket-binding="http-2">
 <param name="batch-delay" value="50"/>
 </http-connector>
 <in-vm-connector name="in-vm" server-id="1"/>
 <http-acceptor name="http-acceptor-2" http-listener="default"/>
 <http-acceptor name="http-acceptor-throughput-2" http-listener="default">
 <param name="batch-delay" value="50"/>
 <param name="direct-deliver" value="false"/>
 </http-acceptor>
 <in-vm-acceptor name="in-vm" server-id="1"/>
 <jms-queue name="ExpiryQueue-2" entries="java:/jms/queue/ExpiryQueue-2"/>
 <jms-queue name="myQueue" entries="java:/jms/queue/myQueue2"/>
 <jms-queue name="DLQ-2" entries="java:/jms/queue/DLQ-2"/>
 <connection-factory name="InVmConnectionFactory-2" entries="java:/ConnectionFactory-2" connectors="in-vm"/>
 <connection-factory name="RemoteConnectionFactory-2" entries="java:jboss/exported/jms/RemoteConnectionFactory-2" connectors="http-connector-2"/>
 <pooled-connection-factory name="activemq-ra-2" transaction="xa" entries="java:/JmsXA-2 java:jboss/DefaultJMSConnectionFactory-2" connectors="in-vm"/>
 </server>
 </subsystem>

Save the configuration file and start the Red Hat JBoss EAP-7 server.


Click here and quickly get started with the JBoss EAP download.

Join the Red Hat Developer Program (it’s free) and get access to related cheat sheets, books, and product downloads.

Share