The document seems a bit ambiguous. If you are using core client you can
use the server locator (with ha) to create clientSessionFactory.
Each client session factory will point to a different node in your cluster
(roundrobin case). Client sessions from on client session factory shares
one same physical connection as you observed.

Howard

On Fri, Sep 6, 2019 at 3:38 PM Marco Pivi <marco.pivi@easymarket.travel>
wrote:

> Hi,
>
> I'm having some trouble with client load balancing on my artemis cluster.
> The cluster is composed by 2 node with the following configuration:
>
> <raw><?xml version='1.0'?>
> <configuration xmlns="urn:activemq" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="urn:activemq
> /schema/artemis-configuration.xsd">
>     <core xmlns="urn:activemq:core" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance";
>           xsi:schemaLocation="urn:activemq:core ">
>
>         <name>${HOSTNAME}</name>
>         <persistence-enabled>true</persistence-enabled>
>         <journal-type>NIO</journal-type>
>         <paging-directory>/var/cache/artemis/paging</paging-directory>
>
> <bindings-directory>/var/cache/artemis/bindings</bindings-directory>
>         <journal-directory>/var/cache/artemis/journal</journal-directory>
>         <large-messages-directory>/var/cache/artemis
> /large-messages</large-messages-directory>
>         <journal-datasync>true</journal-datasync>
>         <journal-min-files>2</journal-min-files>
>         <journal-pool-files>10</journal-pool-files>
>         <journal-file-size>10M</journal-file-size>
>         <journal-buffer-timeout>724000</journal-buffer-timeout>
>         <journal-max-io>1</journal-max-io>
>
>         <connectors>
>             <connector name="artemis
>
> -connector-1">tcp://${HOSTNAME}:61617?sslEnabled=true&amp;trustStorePath=${ARTEMIS_INSTANCE}/etc/truststore.jks</connector>
>         </connectors>
>
>         <disk-scan-period>5000</disk-scan-period>
>         <max-disk-usage>95</max-disk-usage>
>         <critical-analyzer>true</critical-analyzer>
>         <critical-analyzer-timeout>120000</critical-analyzer-timeout>
>
> <critical-analyzer-check-period>60000</critical-analyzer-check-period>
>         <critical-analyzer-policy>HALT</critical-analyzer-policy>
>
>         <acceptors>
>             <acceptor name="artemis
>
> -acceptor-1">tcp://${HOSTNAME}:61617?sslEnabled=true;keyStorePath=${ARTEMIS_INSTANCE}/etc/keystore.jks;keyStorePassword=changeit;trustStorePassword=${ARTEMIS_INSTANCE}/etc/truststore.jks;enabledProtocols=TLSv1.2;enableCipherSuites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_GCM_SHA256;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
>         </acceptors>
>
>         <cluster-user>[...]</cluster-user>
>         <cluster-password>[...]</cluster-password>
>         <broadcast-groups>
>             <broadcast-group name="artemis-broadcast-group-1">
>                 <group-address>231.0.0.1</group-address>
>                 <group-port>9876</group-port>
>                 <connector-ref>artemis-connector-1</connector-ref>
>             </broadcast-group>
>         </broadcast-groups>
>         <discovery-groups>
>             <discovery-group name="artemis-discovery-group-1">
>                 <group-address>231.0.0.1</group-address>
>                 <group-port>9876</group-port>
>             </discovery-group>
>         </discovery-groups>
>         <cluster-connections>
>             <cluster-connection name="artemis-cluster-1">
>                 <connector-ref>artemis-connector-1</connector-ref>
>                 <message-load-balancing>ON_DEMAND</message-load-balancing>
>                 <discovery-group-ref discovery-group-name="artemis
> -discovery-group-1"/>
>             </cluster-connection>
>         </cluster-connections>
>
>
>         <security-settings>
>             <security-setting match="#">
>                 <permission type="createNonDurableQueue" roles="amq"/>
>                 <permission type="deleteNonDurableQueue" roles="amq"/>
>                 <permission type="createDurableQueue" roles="amq"/>
>                 <permission type="deleteDurableQueue" roles="amq"/>
>                 <permission type="createAddress" roles="amq"/>
>                 <permission type="deleteAddress" roles="amq"/>
>                 <permission type="consume" roles="amq"/>
>                 <permission type="browse" roles="amq"/>
>                 <permission type="send" roles="amq"/>
>                 <permission type="manage" roles="amq"/>
>             </security-setting>
>         </security-settings>
>
>         <address-settings>
>             <address-setting match="activemq.management#">
>                 <dead-letter-address>DLQ</dead-letter-address>
>                 <expiry-address>ExpiryQueue</expiry-address>
>                 <redelivery-delay>0</redelivery-delay>
>                 <max-size-bytes>-1</max-size-bytes>
>
> <message-counter-history-day-limit>10</message-counter-history-day-limit>
>                 <address-full-policy>PAGE</address-full-policy>
>                 <auto-create-queues>true</auto-create-queues>
>                 <auto-create-addresses>true</auto-create-addresses>
>                 <auto-create-jms-queues>true</auto-create-jms-queues>
>                 <auto-create-jms-topics>true</auto-create-jms-topics>
>             </address-setting>
>             <address-setting match="#">
>                 <dead-letter-address>DLQ</dead-letter-address>
>                 <expiry-address>ExpiryQueue</expiry-address>
>                 <redelivery-delay>0</redelivery-delay>
>                 <max-size-bytes>-1</max-size-bytes>
>
> <message-counter-history-day-limit>10</message-counter-history-day-limit>
>                 <address-full-policy>PAGE</address-full-policy>
>                 <auto-create-queues>true</auto-create-queues>
>                 <auto-create-addresses>true</auto-create-addresses>
>                 <auto-create-jms-queues>true</auto-create-jms-queues>
>                 <auto-create-jms-topics>true</auto-create-jms-topics>
>                 <redistribution-delay>0</redistribution-delay>
>             </address-setting>
>         </address-settings>
>
>         <addresses>
>
>
>         </addresses>
>                 <broker-plugins>
>                         <broker-plugin class-name="org.apache.activemq.
> artemis.core.server.plugin.impl.NotificationActiveMQServerPlugin">
>                                 <property key="SEND_EXPIRED_NOTIFICATIONS"
> value="true" />
>                         </broker-plugin>
>                 </broker-plugins>
>     </core>
> </configuration></raw>
> <p>
> Looking at the documentation of Artemis, section Clusters, paragraph<a
> href="https://activemq.apache.org/components/artemis
> /documentation/latest/clusters.html#client-side-load-balancing">
> Client-Side Load balancing</a>, I've found this:
> </p>
> <i>With Apache ActiveMQ Artemis client-side load balancing, subsequent
> sessions created using a single session factory can be connected to
> different nodes of the cluster. This allows sessions to spread smoothly
> across the nodes of a cluster and not be "clumped" on any particular
> node.</i>
> <p>
> But once I created a <b>ClientSessionFactory</b>, each <b>ClientSession
> </b>generated by it is always attached to same node of the cluster, even if
> the load balancing strategy is RoundRobinConnectionLoadBalancingPolicy
> (I've tried also RandomConnectionLoadBalancingPolicy or leave default, that
> should be  RoundRobinConnectionLoadBalancingPolicy  ).
> </p>
> <p>
> Looking at the code, I noticed that the ClientSessionFactory use indeed
> always the same RemoteConnection when generates a new ClientSession, so I
> don't understand how to balance the load using the same factory.
> </p>
>
> Am I missing something?
> Thanks in advance
>

Reply via email to