I try to implement Artemis with wildfly (jboss).
I would like to add a custom connection load balancing behavior (client-side) to jboss (check: https://activemq.apache.org/components/artemis/documentation/1.1.0/clusters.html in "Client-Side Load balancing")
I am using a cli file to execute all my jboss commands:
here it is (I cut it there is only there interesting part):
## Artemis Broker Config
/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=remote-artemis1:add(host=my-broker, port=61616)
/subsystem=messaging-activemq/server=default/remote-connector=remote-artemis1:add(socket-binding=remote-artemis1)
## Global Artemis Conf
/subsystem=messaging-activemq/server=default/pooled-connection-factory=remote-artemis:add(entries=["java:/RemoteJmsXA", "java:jboss/RemoteJmsXA"],connectors=["remote-artemis1"], user="###ARTEMIS_USER###", password="###ARTEMIS_USER_PASSWORD###", ha="true", min-pool-size="3", max-pool-size="30", statistics-enabled="true", connection-load-balancing-policy-class-name="online.myproject.utils.amqartemis.RoundRobinFromFirstConnectionLoadBalancingPolicy") <--- problem here
/subsystem=naming/binding=java\:global\/remoteContext:add(binding-type=external-context, module="org.apache.activemq.artemis", class="javax.naming.InitialContext", environment=[java.naming.factory.initial="org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory", java.naming.provider.url="tcp://my-broker:61616", queue.Server_Emit_MyQueue="Server_Emit_MyQueue"])
As you can see, I try to add to the JBOSS Artemis configuration
connection-load-balancing-policy-class-name="online.myproject.utils.amqartemis.RoundRobinFromFirstConnectionLoadBalancingPolicy"
My custom load balancing class is
package online.myproject.utils.amqartemis;
import org.apache.activemq.artemis.api.core.client.loadbalance.ConnectionLoadBalancingPolicy;
import java.io.Serializable;
public class RoundRobinFromFirstConnectionLoadBalancingPolicy implements ConnectionLoadBalancingPolicy, Serializable {
private int pos = -1;
@Override
public int select(final int max) {
pos++;
if (pos >= max) {
pos = 0;
}
return pos;
}
}
But it doesn't work. It says ClassNotFoundException. Here is the logs:
[0m[33m12:18:16,024 WARN [org.apache.activemq.artemis.ra] (default-threads - 1) AMQ152005: Failure in broker activation org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec(ra=org.wildfly.extension.messaging.activemq.ActiveMQResourceAdapter@69686637 destination=java:global/remoteContext/RestServer_Receive_MediaCreation destinationType=javax.jms.Queue selector=messageType='MEDIA_REFERENCE_CREATED_1.0.0' ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): ActiveMQInternalErrorException[errorType=INTERNAL_ERROR message=AMQ219004: Failed to initialise session factory]
at org.apache.activemq.artemis@2.10.1//org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.initialize(ServerLocatorImpl.java:313)
at org.apache.activemq.artemis@2.10.1//org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:768)
at org.apache.activemq.artemis.ra@2.10.1//org.apache.activemq.artemis.ra.inflow.ActiveMQActivation.setup(ActiveMQActivation.java:314)
at org.apache.activemq.artemis.ra@2.10.1//org.apache.activemq.artemis.ra.inflow.ActiveMQActivation$SetupActivation.run(ActiveMQActivation.java:731)
at org.wildfly.extension.messaging-activemq//org.wildfly.extension.messaging.activemq.ActiveMQResourceAdapter$WorkWrapper.run(ActiveMQResourceAdapter.java:171)
at org.jboss.ironjacamar.impl@1.4.17.Final//org.jboss.jca.core.workmanager.WorkWrapper.runWork(WorkWrapper.java:445)
at org.jboss.as.connector@18.0.1.Final//org.jboss.as.connector.services.workmanager.WildflyWorkWrapper.runWork(WildflyWorkWrapper.java:69)
at org.jboss.ironjacamar.impl@1.4.17.Final//org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:223)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:29)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:789)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:44)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:809)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads@2.3.3.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: java.lang.IllegalStateException: java.lang.ClassNotFoundException: online.myproject.utils.amqartemis.RoundRobinFromFirstConnectionLoadBalancingPolicy from [Module "org.wildfly.extension.messaging-activemq" from local module loader @22f31dec (finder: local module finder @34c01041 (roots: /opt/jboss/wildfly/modules,/opt/jboss/wildfly/modules/system/layers/base))]
at org.apache.activemq.artemis.journal//org.apache.activemq.artemis.utils.ClassloadingUtil.newInstanceFromClassLoader(ClassloadingUtil.java:59)
at org.apache.activemq.artemis@2.10.1//org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl$3.run(ServerLocatorImpl.java:281)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.apache.activemq.artemis@2.10.1//org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.instantiateLoadBalancingPolicy(ServerLocatorImpl.java:278)
at org.apache.activemq.artemis@2.10.1//org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.initialize(ServerLocatorImpl.java:302)
... 13 more
Caused by: java.lang.ClassNotFoundException: online.myproject.utils.amqartemis.RoundRobinFromFirstConnectionLoadBalancingPolicy from [Module "org.wildfly.extension.messaging-activemq" from local module loader @22f31dec (finder: local module finder @34c01041 (roots: /opt/jboss/wildfly/modules,/opt/jboss/wildfly/modules/system/layers/base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
at org.apache.activemq.artemis.journal//org.apache.activemq.artemis.utils.ClassloadingUtil.newInstanceFromClassLoader(ClassloadingUtil.java:55)
... 17 more
It seems we have to make an additional move to make it
Here are all links to help you!
https://docs.google.com/document/d/1MxvnuSmLhcJSbUSPTNvULvbrNhj8661j_x5RFjZvoVQ/edit?usp=sharing
https://kb.novaordis.com/index.php/Writing_a_Custom_WildFly_Module http://www.mastertheboss.com/jbossas/jboss-as-7/how-to-install-a-module-on-jboss-as-7/#:~:text=Statically%20Deployed%20Modules.,just%20like%20any%20other%20application
http://docs.wildfly.org/15/Developer_Guide.html
https://docs.wildfly.org/26/Developer_Guide.html
parag. 1.8
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.