title: ActiveMQ Artemis replication colocated not working
body: <p>I have a cluster of ActiveMQ Artemis and config them to replication colocated over network.</p>
  
  <p>Here is two configs of them:</p>
  
  <p>Broker1</p>
  
  <pre><code>&lt;?xml version='1.0'?&gt;
  &lt;configuration xmlns="urn:activemq"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xi="http://www.w3.org/2001/XInclude"
             xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"&gt;
  
  &lt;core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:activemq:core "&gt;
  
    &lt;name&gt;10.1.1.130&lt;/name&gt;
  
  
    &lt;persistence-enabled&gt;true&lt;/persistence-enabled&gt;
  
    &lt;!-- this could be ASYNCIO, MAPPED, NIO
         ASYNCIO: Linux Libaio
         MAPPED: mmap files
         NIO: Plain Java Files
     --&gt;
    &lt;journal-type&gt;ASYNCIO&lt;/journal-type&gt;
  
    &lt;paging-directory&gt;data/paging&lt;/paging-directory&gt;
  
    &lt;bindings-directory&gt;data/bindings&lt;/bindings-directory&gt;
  
    &lt;journal-directory&gt;data/journal&lt;/journal-directory&gt;
  
    &lt;large-messages-directory&gt;data/large-messages&lt;/large-messages-directory&gt;
  
    &lt;journal-datasync&gt;true&lt;/journal-datasync&gt;
  
    &lt;journal-min-files&gt;2&lt;/journal-min-files&gt;
  
    &lt;journal-pool-files&gt;10&lt;/journal-pool-files&gt;
  
    &lt;journal-device-block-size&gt;4096&lt;/journal-device-block-size&gt;
  
    &lt;journal-file-size&gt;10M&lt;/journal-file-size&gt;
  
    &lt;journal-buffer-timeout&gt;23940000&lt;/journal-buffer-timeout&gt;
  
    &lt;journal-max-io&gt;1&lt;/journal-max-io&gt;
  
    &lt;!-- how often we are looking for how many bytes are being used on the disk in ms --&gt;
    &lt;disk-scan-period&gt;5000&lt;/disk-scan-period&gt;
  
    &lt;!-- once the disk hits this limit the system will block, or close the connection in certain protocols
         that won't support flow control. --&gt;
    &lt;max-disk-usage&gt;90&lt;/max-disk-usage&gt;
  
    &lt;!-- should the broker detect dead locks and other issues --&gt;
    &lt;critical-analyzer&gt;true&lt;/critical-analyzer&gt;
  
    &lt;critical-analyzer-timeout&gt;120000&lt;/critical-analyzer-timeout&gt;
  
    &lt;critical-analyzer-check-period&gt;60000&lt;/critical-analyzer-check-period&gt;
  
    &lt;critical-analyzer-policy&gt;HALT&lt;/critical-analyzer-policy&gt;
  
  
   &lt;!-- Clustering configuration --&gt;
    &lt;connectors&gt;
       &lt;connector name="netty-connector"&gt;tcp://localhost:61616&lt;/connector&gt;
       &lt;!-- connector to the server2 --&gt;
       &lt;connector name="server2-connector"&gt;tcp://10.1.1.131:61616&lt;/connector&gt;
    &lt;/connectors&gt;
    &lt;ha-policy&gt;
       &lt;replication&gt;
          &lt;colocated&gt;
             &lt;backup-request-retries&gt;-1&lt;/backup-request-retries&gt;
             &lt;backup-request-retry-interval&gt;2000&lt;/backup-request-retry-interval&gt;
             &lt;excludes&gt;
                &lt;connector-ref&gt;server2-connector&lt;/connector-ref&gt;
                &lt;connector-ref&gt;netty-connector&lt;/connector-ref&gt;
             &lt;/excludes&gt;
             &lt;max-backups&gt;1&lt;/max-backups&gt;
             &lt;request-backup&gt;true&lt;/request-backup&gt;
             &lt;master&gt; 
             &lt;/master&gt;
             &lt;slave&gt;
             &lt;/slave&gt;
          &lt;/colocated&gt;
       &lt;/replication&gt;
    &lt;/ha-policy&gt;
   &lt;cluster-user&gt;ACTIVEMQ.CLUSTER.ADMIN.USER&lt;/cluster-user&gt;
   &lt;cluster-password&gt;123456&lt;/cluster-password&gt;
   &lt;cluster-connections&gt;
       &lt;cluster-connection name="my-cluster"&gt;
          &lt;connector-ref&gt;netty-connector&lt;/connector-ref&gt;
          &lt;retry-interval&gt;500&lt;/retry-interval&gt;
          &lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
          &lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
          &lt;max-hops&gt;1&lt;/max-hops&gt;
          &lt;static-connectors&gt;
             &lt;connector-ref&gt;server2-connector&lt;/connector-ref&gt;
          &lt;/static-connectors&gt;
       &lt;/cluster-connection&gt;
    &lt;/cluster-connections&gt;
  
    &lt;acceptors&gt;
       &lt;!-- Acceptor for every supported protocol --&gt;
       &lt;acceptor name="artemis"&gt;tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300&lt;/acceptor&gt;
  
       &lt;!-- AMQP Acceptor.  Listens on default AMQP port for AMQP traffic.--&gt;
       &lt;acceptor name="amqp"&gt;tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpLowCredits=300&lt;/acceptor&gt;
  
       &lt;!-- STOMP Acceptor. --&gt;
       &lt;acceptor name="stomp"&gt;tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true&lt;/acceptor&gt;
  
       &lt;!-- HornetQ Compatibility Acceptor.  Enables HornetQ Core and STOMP for legacy HornetQ clients. --&gt;
       &lt;acceptor name="hornetq"&gt;tcp://0.0.0.0:5445?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;protocols=HORNETQ,STOMP;useEpoll=true&lt;/acceptor&gt;
  
       &lt;!-- MQTT Acceptor --&gt;
       &lt;acceptor name="mqtt"&gt;tcp://0.0.0.0:4883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true&lt;/acceptor&gt;
  
    &lt;/acceptors&gt;
  
  
    &lt;security-settings&gt;
       &lt;security-setting match="#"&gt;
          &lt;permission type="createNonDurableQueue" roles="amq"/&gt;
          &lt;permission type="deleteNonDurableQueue" roles="amq"/&gt;
          &lt;permission type="createDurableQueue" roles="amq"/&gt;
          &lt;permission type="deleteDurableQueue" roles="amq"/&gt;
          &lt;permission type="createAddress" roles="amq"/&gt;
          &lt;permission type="deleteAddress" roles="amq"/&gt;
          &lt;permission type="consume" roles="amq"/&gt;
          &lt;permission type="browse" roles="amq"/&gt;
          &lt;permission type="send" roles="amq"/&gt;
          &lt;!-- we need this otherwise ./artemis data imp wouldn't work --&gt;
          &lt;permission type="manage" roles="amq"/&gt;
       &lt;/security-setting&gt;
    &lt;/security-settings&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>Broker2:</p>
  
  <pre><code>&lt;?xml version='1.0'?&gt;
  &lt;configuration xmlns="urn:activemq"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xi="http://www.w3.org/2001/XInclude"
             xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"&gt;
  
  &lt;core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="urn:activemq:core "&gt;
  
  
    &lt;name&gt;10.1.1.131&lt;/name&gt;
  
  
    &lt;persistence-enabled&gt;true&lt;/persistence-enabled&gt;
  
    &lt;!-- this could be ASYNCIO, MAPPED, NIO
         ASYNCIO: Linux Libaio
         MAPPED: mmap files
         NIO: Plain Java Files
     --&gt;
    &lt;journal-type&gt;ASYNCIO&lt;/journal-type&gt;
  
    &lt;paging-directory&gt;data/paging&lt;/paging-directory&gt;
  
    &lt;bindings-directory&gt;data/bindings&lt;/bindings-directory&gt;
  
    &lt;journal-directory&gt;data/journal&lt;/journal-directory&gt;
  
    &lt;large-messages-directory&gt;data/large-messages&lt;/large-messages-directory&gt;
  
    &lt;journal-datasync&gt;true&lt;/journal-datasync&gt;
  
    &lt;journal-min-files&gt;2&lt;/journal-min-files&gt;
  
    &lt;journal-pool-files&gt;10&lt;/journal-pool-files&gt;
  
    &lt;journal-device-block-size&gt;4096&lt;/journal-device-block-size&gt;
  
    &lt;journal-file-size&gt;10M&lt;/journal-file-size&gt;
  
    &lt;journal-buffer-timeout&gt;23940000&lt;/journal-buffer-timeout&gt;
  
    &lt;journal-max-io&gt;1&lt;/journal-max-io&gt;
  
    &lt;!-- how often we are looking for how many bytes are being used on the disk in ms --&gt;
    &lt;disk-scan-period&gt;5000&lt;/disk-scan-period&gt;
  
    &lt;!-- once the disk hits this limit the system will block, or close the connection in certain protocols
         that won't support flow control. --&gt;
    &lt;max-disk-usage&gt;90&lt;/max-disk-usage&gt;
  
    &lt;!-- should the broker detect dead locks and other issues --&gt;
    &lt;critical-analyzer&gt;true&lt;/critical-analyzer&gt;
  
    &lt;critical-analyzer-timeout&gt;120000&lt;/critical-analyzer-timeout&gt;
  
    &lt;critical-analyzer-check-period&gt;60000&lt;/critical-analyzer-check-period&gt;
  
    &lt;critical-analyzer-policy&gt;HALT&lt;/critical-analyzer-policy&gt;
  
  
   &lt;!-- Clustering configuration --&gt;
    &lt;connectors&gt;
       &lt;connector name="netty-connector"&gt;tcp://localhost:61616&lt;/connector&gt;
       &lt;!-- connector to the server1 --&gt;
       &lt;connector name="server1-connector"&gt;tcp://10.1.1.130:61616&lt;/connector&gt;
    &lt;/connectors&gt;
    &lt;ha-policy&gt;
       &lt;replication&gt;
          &lt;colocated&gt;
             &lt;backup-request-retries&gt;-1&lt;/backup-request-retries&gt;
             &lt;backup-request-retry-interval&gt;2000&lt;/backup-request-retry-interval&gt;
             &lt;excludes&gt;
                &lt;connector-ref&gt;server1-connector&lt;/connector-ref&gt;
                &lt;connector-ref&gt;netty-connector&lt;/connector-ref&gt;
             &lt;/excludes&gt;
             &lt;max-backups&gt;1&lt;/max-backups&gt;
             &lt;request-backup&gt;true&lt;/request-backup&gt;
             &lt;master&gt; 
             &lt;/master&gt;
             &lt;slave&gt;
             &lt;/slave&gt;
          &lt;/colocated&gt;
       &lt;/replication&gt;
    &lt;/ha-policy&gt;
   &lt;cluster-user&gt;ACTIVEMQ.CLUSTER.ADMIN.USER&lt;/cluster-user&gt;
   &lt;cluster-password&gt;123456&lt;/cluster-password&gt;
   &lt;cluster-connections&gt;
       &lt;cluster-connection name="my-cluster"&gt;
          &lt;connector-ref&gt;netty-connector&lt;/connector-ref&gt;
          &lt;retry-interval&gt;500&lt;/retry-interval&gt;
          &lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
          &lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
          &lt;max-hops&gt;1&lt;/max-hops&gt;
          &lt;static-connectors&gt;
             &lt;connector-ref&gt;server1-connector&lt;/connector-ref&gt;
          &lt;/static-connectors&gt;
       &lt;/cluster-connection&gt;
    &lt;/cluster-connections&gt;
  
    &lt;acceptors&gt;
       &lt;!-- Acceptor for every supported protocol --&gt;
       &lt;acceptor name="artemis"&gt;tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300&lt;/acceptor&gt;
  
       &lt;!-- AMQP Acceptor.  Listens on default AMQP port for AMQP traffic.--&gt;
       &lt;acceptor name="amqp"&gt;tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpLowCredits=300&lt;/acceptor&gt;
  
       &lt;!-- STOMP Acceptor. --&gt;
       &lt;acceptor name="stomp"&gt;tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true&lt;/acceptor&gt;
  
       &lt;!-- HornetQ Compatibility Acceptor.  Enables HornetQ Core and STOMP for legacy HornetQ clients. --&gt;
       &lt;acceptor name="hornetq"&gt;tcp://0.0.0.0:5445?anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;protocols=HORNETQ,STOMP;useEpoll=true&lt;/acceptor&gt;
  
       &lt;!-- MQTT Acceptor --&gt;
       &lt;acceptor name="mqtt"&gt;tcp://0.0.0.0:4883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true&lt;/acceptor&gt;
  
    &lt;/acceptors&gt;
  
  
    &lt;security-settings&gt;
       &lt;security-setting match="#"&gt;
          &lt;permission type="createNonDurableQueue" roles="amq"/&gt;
          &lt;permission type="deleteNonDurableQueue" roles="amq"/&gt;
          &lt;permission type="createDurableQueue" roles="amq"/&gt;
          &lt;permission type="deleteDurableQueue" roles="amq"/&gt;
          &lt;permission type="createAddress" roles="amq"/&gt;
          &lt;permission type="deleteAddress" roles="amq"/&gt;
          &lt;permission type="consume" roles="amq"/&gt;
          &lt;permission type="browse" roles="amq"/&gt;
          &lt;permission type="send" roles="amq"/&gt;
          &lt;!-- we need this otherwise ./artemis data imp wouldn't work --&gt;
          &lt;permission type="manage" roles="amq"/&gt;
       &lt;/security-setting&gt;
    &lt;/security-settings&gt;
  </code></pre>
  
  <p>
  </p>
  
  <p>Here is Srping Boot java Code to send message:</p>
  
  <pre><code>@Configuration
  public class ArtemisProducerConfig extends BaseObject {
  @Value("${artemis.broker-url}")
  private String brokerUrl;
  
  @Bean
  public ActiveMQConnectionFactory senderActiveMQConnectionFactory() {
      return new ActiveMQConnectionFactory(brokerUrl);
  }
  
  @Bean
  public CachingConnectionFactory cachingConnectionFactory() {
      return new CachingConnectionFactory(senderActiveMQConnectionFactory());
  }
  
  @Bean
  public JmsTemplate jmsTemplate() {
      JmsTemplate template =  new JmsTemplate(cachingConnectionFactory());
      template.setExplicitQosEnabled(true);
      template.setDeliveryPersistent(true);
      return template;
  }
  
  }
  
  jmsTemplate.convertAndSend("test.address::test.queue", inputData.getData(), new MessagePostProcessor() {
  
          @Override
          public Message postProcessMessage(Message message) throws JMSException {
              // TODO Auto-generated method stub
              message.setJMSCorrelationID(inputData.getCorrID());
              return message;
          }
      });
  </code></pre>
  
  <p>The Messsage is send to Broker1 success, I can view this on the site <a href="http://10.1.1.130:8161" rel="nofollow noreferrer">http://10.1.1.130:8161</a>.
  But on Broker2 no message available now.I understand that the Messages must be backed up to Broker2 to meet HA.</p>
  
  <p>Can someone help me an example to configure Artemis to replication colocated over network?
  Thank you!</p>