Wildfly 10 - ActiveMQ Artemis Failover with Standalone client
vincent.sourin Mar 8, 2016 4:15 AMHello,
I've got two wildly 10 instances (lastest master) running on two different severs with ActiveMQ messaging configured with colocated replication :
<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
<server name="default">
<cluster password="${jboss.messaging.cluster.password:vs1979anpasswdcluster}"/>
<replication-colocated excluded-connectors="netty-connector" request-backup="true">
<master check-for-live-server="true" cluster-name="my-cluster"/>
<slave cluster-name="my-cluster"/>
</replication-colocated>
<security-setting name="#">
<role name="guest" delete-non-durable-queue="true" create-non-durable-queue="true" create-durable-queue="true" consume="true" send="true"/>
</security-setting>
<address-setting name="#" redistribution-delay="1000" 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>
<remote-connector name="netty-connector" socket-binding="messaging"/>
<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>
<remote-acceptor name="netty-acceptor" socket-binding="messaging"/>
<in-vm-acceptor name="in-vm" server-id="0"/>
<broadcast-group name="bg-group1" connectors="http-connector" jgroups-channel="activemq-cluster"/>
<discovery-group name="dg-group1" jgroups-channel="activemq-cluster"/>
<cluster-connection name="my-cluster" discovery-group="dg-group1" connector-name="http-connector" address="jms"/>
<jms-queue name="ExpiryQueue" entries="java:/jms/queue/ExpiryQueue"/>
<jms-queue name="DLQ" entries="java:/jms/queue/DLQ"/>
<jms-queue name="PanoramaScanPresses" entries="java:jboss/exported/jms/queue/PanoramaScanPresses"/>
<jms-topic name="TopicPanoramaScanPresses" entries="jms/topic/TopicPanoramaScanPresses java:jboss/exported/jms/topic/TopicPanoramaScanPresses"/>
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
<connection-factory name="RemoteConnectionFactory" failover-on-initial-connection="true" reconnect-attempts="-1" block-on-acknowledge="true" client-failure-check-period="10000" ha="true" 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>
</subsystem>
and I've got a standalone JMS client connecting to wildlfy :
[...]
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, "http-remoting://as1.XXXXX.corp:8080,http-remoting://as2.XXXXX.corp:8080"));
env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", "user"));
env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", "pass"));
Context jndiContext = new InitialContext(env);
connectionFactory = (ConnectionFactory) jndiContext.lookup("java:jms/RemoteConnectionFactory");
System.out.println(connectionFactory.toString());
queue = (Destination) jndiContext.lookup("java:jms/topic/TopicPanoramaScanPresses");
jndiContext.close();
jmsContext = connectionFactory.createContext("user", "pass", JMSContext.AUTO_ACKNOWLEDGE);
[...]
When I kill one of my wildfly instance, I can see in the logs that the backup server becomes live in the second server. But the client received this error :
WARN: AMQ212037: Connection failure has been detected: AMQ119015: The connection was disconnected because of server shutdown [code=DISCONNECTED]
and doesn't failover to the second server. If I relaunched the killed server, the client reconnects to that server.
What bothers me it's the connection factory received by my client does not mention the second server available and I think that's why the client does not failover :
System.out.println(connectionFactory.toString()); => ActiveMQConnectionFactory [serverLocator=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=null, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory) ?httpUpgradeEnabled=true&port=8080&httpPpgradeEndpoint=http-acceptor&host=10-10-2-134], discoveryGroupConfiguration=null], clientID=null, consumerWindowSize = 1048576, dupsOKBatchSize=1048576, transactionBatchSize=1048576, readOnly=false]
Does someone can tell me how to configure the connection factory correctly to allow failover of the client ?
Thanks.
Vincent.