Artemis Messaging (ActiveMQ) in Wildfly 10 Cluster (Domain)

Can someone provide an example messaging application running under the Wildfly 10 cluster (domain)? We are struggling with this and given that this is a new technology, there is a terrible lack of resources.

We currently have the following:

A domain consisting of two hosts (nodes) and three groups on each, that is, six separate servers in the domain.

The corresponding part of the server configuration (in domain.xml):

        <subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
            <server name="default">
                <security enabled="false"/>
                <cluster password="${jboss.messaging.cluster.password}"/>
                <security-setting name="#">
                    <role name="guest" delete-non-durable-queue="true" create-non-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-siz
                <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>
                <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>
                <in-vm-acceptor name="in-vm" server-id="0"/>
                <broadcast-group name="bg-group1" connectors="http-connector" jgroups-channel="activemq-cluster" jgroups-stack="tcphq"/>
                <discovery-group name="dg-group1" jgroups-channel="activemq-cluster" jgroups-stack="tcphq"/>
                <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="TestQ" entries="java:jboss/exported/jms/queue/testq"/>
                <connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
                <connection-factory name="RemoteConnectionFactory" reconnect-attempts="-1" block-on-acknowledge="true" ha="true" entries="java
                <pooled-connection-factory name="activemq-ra" transaction="xa" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" co
            </server>
        </subsystem>

The configuration is more or less the default, with the exception of the added TestQ queue.

The tcphq stack is defined in the JGroups configuration as follows:

                <stack name="tcphq">
                    <transport type="TCP" socket-binding="jgroups-tcp-hq"/>
                    <protocol type="TCPPING">
                        <property name="initial_hosts">
                          dev1[7660],dev1[7810],dev1[7960],dev2[7660],dev2[7810],dev2[7960]
                        </property>
                        <property name="port_range">
                            0
                        </property>
                    </protocol>
                    <protocol type="MERGE3"/>
                    <protocol type="FD_SOCK" socket-binding="jgroups-tcp-hq-fd"/>
                    <protocol type="FD"/>
                    <protocol type="VERIFY_SUSPECT"/>
                    <protocol type="pbcast.NAKACK2"/>
                    <protocol type="UNICAST3"/>
                    <protocol type="pbcast.STABLE"/>
                    <protocol type="pbcast.GMS"/>
                    <protocol type="MFC"/>
                    <protocol type="FRAG2"/>
                </stack>

I wrote a test application consisting of a simple "server", which means MDB and client as follows:

Server (MDB):

@MessageDriven(mappedName = "test", activationConfig = {
    @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/exported/jms/queue/testq"),
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class MessageServer implements MessageListener {

    @Override
    public void onMessage(Message message) {

        try {
            ObjectMessage msg = null;

            if (message instanceof ObjectMessage) {
                msg = (ObjectMessage) message;
            }
            System.out.print("The number in the message: "+ msg.getIntProperty("count"));
        } catch (JMSException ex) {
            Logger.getLogger(MessageServer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

Customer:

@Singleton
@Startup
public class ClientBean implements ClientBeanLocal {

    @Resource(mappedName = "java:jboss/exported/jms/RemoteConnectionFactory")
    private ConnectionFactory factory;

    @Resource(mappedName = "java:jboss/exported/jms/queue/testq")
    private Queue queue;

    @PostConstruct
    public void sendMessage() {

        Connection connection = null;
        try {

            connection = factory.createConnection();
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer producer = session.createProducer(queue);

            Message message = session.createObjectMessage();
            message.setIntProperty("count", 1);

            producer.send(message);
            System.out.println("Message sent.");

        } catch (JMSException ex) {
            Logger.getLogger(ClientBean.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NamingException ex) {
            Logger.getLogger(ClientBean.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                if (connection != null) connection.close();
            } catch (JMSException ex) {
                Logger.getLogger(ClientBean.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

}

, . , (). , , MDB . , , MDB , 0. MDB , , .

JMS Wildfly 10. HornetQ, Artemis. - ? .

+4
1

- , .

, developer.jboss.org, , , - socket-binding "jgroups-tcp-hq" port-offset .
<socket-binding name="jgroups-tcp-hq" ... port="7600"/> port-offset (, jboss.socket.binding.port-offset) 60 dev1 [7660] ; 210 dev1 [7810]; 360 dev1 [7960]. dev2.

jboss.bind.address.private.
jgroups socket-binding "private", .

<socket-binding name="jgroups-tcp-hq" interface="private" port="7600"/>

"private" jboss.bind.address.private (, jboss.bind.address.private=dev1) - , ClusterConnectionBridge !
. .

ActiveMQ , server.log: AMQ221027: Bridge ClusterConnectionBridge@63549ead [name=sf.my-cluster ...] is connected.
. .

0

All Articles