-
1. Re: WildFly10, external ArtemisMQ cluster, MDB
mnovak Nov 3, 2017 4:33 AM (in response to fioacnoaesn)Hi Stanislav,
I think it's better to avoid configuring this directly in MDB and it's better to have it in standalone-full-ha.xml like:
<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0"> <server name="default"> ... <remote-connector name="artemis1" socket-binding="artemis1"/> <remote-connector name="artemis2" socket-binding="artemis2"/> ... <pooled-connection-factory name="activemq-ra" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" connectors="artemis1 artemis2" transaction="xa"/> ... </server> </subsystem> ... <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"> ... <outbound-socket-binding name="artemis1"> <remote-destination host="127.0.0.1" port="61616"/> </outbound-socket-binding> <outbound-socket-binding name="artemis2"> <remote-destination host="127.0.0.1" port="62616"/> </outbound-socket-binding> </socket-binding-group>
My MDB then looks like:
import javax.ejb.ActivationConfigProperty; import javax.ejb.MessageDriven; import javax.jms.Message; import javax.jms.MessageListener; @MessageDriven(name = "SimpleMdb", activationConfig = { @ActivationConfigProperty(propertyName = "destination", propertyValue = "InQueue"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge")}) public class SimpleMdb implements MessageListener { public void onMessage(Message rcvMessage) { System.out.println("Received message: " + rcvMessage); } }
connectors="artemis1 artemis2" in configuration of WF server points to acceptors of Artemis servers and will use CORE protocol. Those are just initial connectors so MDB will use one of those connectors for initial connection, load cluster topology of Artemis servers and then load balance connections. So every invocation of MDB (sessions) will be connected to different node.
There is also possibility do configure discovery-group instead of connectors in pooled-connection-factory which would listen for broadcasted connectors from Artemis cluster and use it for initial connectors.
Cheers,
Mirek