How to set up messaging subsystem using CLI in Wildfly
Asked Answered
I

3

13

Does anyone have an example script for setting up the messaging subsystem in Wildfly using CLI?

The perfect example would be the CLI needed to take a server running the standalone.xml, and after running the CLI script it has the messaging subsystem as defined in the standalone-full.xml.

The examples I've found so far all start with the assumption the messaging subsystem is already in place.

Ical answered 23/7, 2014 at 21:47 Comment(5)
Is there a reason not to just use standalone-full.xml?Hod
Because standalone-full.xml has everything in it. We're trying to automate the deployment process, and we'd like to keep it to running just what we need.Ical
Fair enough. So you could start with /extension=org.jboss.as.messaging:add(module=org.jboss.as.messaging) then /subsystem=messaging:add. That will give you the base subsystem with defaults.Hod
I'm not sure all the defaults you want, it will exist :)Hod
That helps me get started. I've also was pointed to wildscribe.github.io/Wildfly/8.1.0.Final/subsystem/messaging/… If I get the final script running, I'll post it here.Ical
I
17

Here's the script to add messaging. This adds the messaging subsystem, and makes it look like the subsystem when running standalone-full.xml.

/extension=org.jboss.as.messaging:add()
batch
/subsystem=messaging:add
/subsystem=messaging/hornetq-server=default:add
/subsystem=messaging/hornetq-server=default/:write-attribute(name=journal-file-size, value=102400L)
/subsystem=messaging/hornetq-server=default/address-setting=#:add(address-full-policy="PAGE", \
    dead-letter-address="jms.queue.DLQ", expiry-address="jms.queue.ExpiryQueue", expiry-delay=-1L, \
    last-value-queue=false, max-delivery-attempts=10, max-size-bytes=10485760L, message-counter-history-day-limit=10, \
    page-max-cache-size=5, page-size-bytes=2097152L, redelivery-delay=0L, redistribution-delay=-1L, send-to-dla-on-no-route=false)

/subsystem=messaging/hornetq-server=default/in-vm-connector=in-vm:add(server-id=0)
/subsystem=messaging/hornetq-server=default/in-vm-acceptor=in-vm:add(server-id=0)

/subsystem=messaging/hornetq-server=default/http-connector=http-connector:add(socket-binding="http", param={http-upgrade-endpoint="http-acceptor"})
/subsystem=messaging/hornetq-server=default/http-connector=http-connector-throughput:add(socket-binding="http", param={http-upgrade-endpoint="http-acceptor-throughput", batch-delay=50})
/subsystem=messaging/hornetq-server=default/http-acceptor=http-acceptor:add(http-listener="default")
/subsystem=messaging/hornetq-server=default/http-acceptor=http-acceptor-throughput:add(http-listener="default", param={batch-delay=50, direct-deliver=false})

/subsystem=messaging/hornetq-server=default/connection-factory=InVmConnectionFactory:add(connector={"in-vm"=>undefined}, entries = ["java:/ConnectionFactory"])
/subsystem=messaging/hornetq-server=default/connection-factory=RemoteConnectionFactory:add(connector={"http-connector"=>undefined}, entries = ["java:jboss/exported/jms/RemoteConnectionFactory"])

/subsystem=messaging/hornetq-server=default/pooled-connection-factory=hornetq-ra:add(connector={"in-vm"=>undefined}, entries=["java:/JmsXA","java:jboss/DefaultJMSConnectionFactory"])
/subsystem=messaging/hornetq-server=default/security-setting=#:add()
/subsystem=messaging/hornetq-server=default/security-setting=#/role=guest:add(consume=true, create-durable-queue=false, create-non-durable-queue=true, delete-durable-queue=false, delete-non-durable-queue=true, manage=false, send=true)

jms-queue add --queue-address=ExpiryQueue --durable=true --entries=["java:/jms/queue/ExpiryQueue"] 
jms-queue add --queue-address=DLQ --durable=true --entries=["java:/jms/queue/DLQ"]
run-batch
Ical answered 25/7, 2014 at 21:55 Comment(0)
T
11

Here is an updated CLI command for new Wildfly 10 (ActiveMQ Artemis)

>> ADD MESSAGING SUBSYSTEM

/extension=org.wildfly.extension.messaging-activemq:add()
/subsystem=messaging-activemq:add
/:reload
/subsystem=messaging-activemq/server=default:add
/subsystem=messaging-activemq/server=default/security-setting=#:add
/subsystem=messaging-activemq/server=default/address-setting=#:add(dead-letter-address="jms.queue.DLQ", expiry-address="jms.queue.ExpiryQueue", expiry-delay="-1L", max-delivery-attempts="10", max-size-bytes="10485760", page-size-bytes="2097152", message-counter-history-day-limit="10")
/subsystem=messaging-activemq/server=default/http-connector=http-connector:add(socket-binding="http", endpoint="http-acceptor")
/subsystem=messaging-activemq/server=default/http-connector=http-connector-throughput:add(socket-binding="http", endpoint="http-acceptor-throughput" ,params={batch-delay="50"})
/subsystem=messaging-activemq/server=default/in-vm-connector=in-vm:add(server-id="0")
/subsystem=messaging-activemq/server=default/http-acceptor=http-acceptor:add(http-listener="default")
/subsystem=messaging-activemq/server=default/http-acceptor=http-acceptor-throughput:add(http-listener="default", params={batch-delay="50", direct-deliver="false"})
/subsystem=messaging-activemq/server=default/in-vm-acceptor=in-vm:add(server-id="0")
/subsystem=messaging-activemq/server=default/jms-queue=ExpiryQueue:add(entries=["java:/jms/queue/ExpiryQueue"])
/subsystem=messaging-activemq/server=default/jms-queue=DLQ:add(entries=["java:/jms/queue/DLQ"])

>> Refresh needed at this point

/subsystem=messaging-activemq/server=default/connection-factory=InVmConnectionFactory:add(connectors=["in-vm"], entries=["java:/ConnectionFactory"])
/subsystem=messaging-activemq/server=default/connection-factory=RemoteConnectionFactory:add(connectors=["http-connector"], entries = ["java:jboss/exported/jms/RemoteConnectionFactory"])
/subsystem=messaging-activemq/server=default/pooled-connection-factory=activemq-ra:add(transaction="xa", connectors=["in-vm"], entries=["java:/JmsXA java:jboss/DefaultJMSConnectionFactory"])
/subsystem=ee/service=default-bindings/:write-attribute(name="jms-connection-factory", value="java:jboss/DefaultJMSConnectionFactory")
/subsystem=ejb3:write-attribute(name="default-resource-adapter-name", value="${ejb.resource-adapter-name:activemq-ra.rar}")
/subsystem=ejb3:write-attribute(name="default-mdb-instance-pool", value="mdb-strict-max-pool")

>> ADD MESSAGE QUEUE

/subsystem=messaging-activemq/server=default/jms-queue=MyQueue:add(entries=[java:/jms/queue/MyQueue])

All commands may be ran as a batch command or separately like this:

$SERVER_CLI_PATH --connect --user=$SERVER_USER --password=$SERVER_PASSW --command="{{line with command}}"
Traylor answered 5/5, 2016 at 21:2 Comment(0)
T
5

To set up messaging in WildFly 14, I had to do the configuration with separate CLI script files, otherwise jboss-cli would fail with JBTHR00004: Operation was cancelled exceptions, probably due to incomplete reloads. In case you still encounter these errors, add sleep commands in between to the shell script that runs the CLI scripts.

  1. Add the messaging extension, 1-add-messaging-extension-and-subsystem.cli:

    batch
    
    # Add messaging extension
    /extension=org.wildfly.extension.messaging-activemq:add()
    
    # Add messaging subsystem
    /subsystem=messaging-activemq:add
    
    run-batch
    
    /:reload
    
  2. Add the messaging server allowing only in-VM connectors, 2-add-messaging-server.cli:

    batch
    
    # Add messaging server with default configuration, allow only in-VM connectors
    /subsystem=messaging-activemq/server=default:add
    /subsystem=messaging-activemq/server=default/security-setting=#:add
    /subsystem=messaging-activemq/server=default/address-setting=#:add( \
            dead-letter-address="jms.queue.DLQ", \
            expiry-address="jms.queue.ExpiryQueue", \
            max-size-bytes="10485760", \
            message-counter-history-day-limit="10", \
            page-size-bytes="2097152")
    /subsystem=messaging-activemq/server=default/in-vm-connector=in-vm:add( \
            server-id="0",params=buffer-pooling=false)
    /subsystem=messaging-activemq/server=default/in-vm-acceptor=in-vm:add( \
            server-id="0",params=buffer-pooling=false)
    /subsystem=messaging-activemq/server=default/jms-queue=ExpiryQueue:add( \
            entries=["java:/jms/queue/ExpiryQueue"])
    /subsystem=messaging-activemq/server=default/jms-queue=DLQ:add( \
            entries=["java:/jms/queue/DLQ"])
    /subsystem=messaging-activemq/server=default/connection-factory=InVmConnectionFactory:add( \
            connectors=["in-vm"], \
            entries=["java:/ConnectionFactory"])
    /subsystem=messaging-activemq/server=default/pooled-connection-factory=activemq-ra:add( \
            transaction="xa", \
            connectors=["in-vm"], \
            entries=["java:/JmsXA java:jboss/DefaultJMSConnectionFactory"])
    
    # Configure default connection factory in the EE subsystem
    /subsystem=ee/service=default-bindings/:write-attribute(name="jms-connection-factory", value="java:jboss/DefaultJMSConnectionFactory")
    
    # Configure message-driven beans in the EJB subsystem
    /subsystem=ejb3:write-attribute(name="default-resource-adapter-name", value="${ejb.resource-adapter-name:activemq-ra.rar}")
    /subsystem=ejb3:write-attribute(name="default-mdb-instance-pool", value="mdb-strict-max-pool")
    
    run-batch
    
    /:reload
    

In case you need HTTP connectors as well, see @petr-hunka's answer.

Typist answered 21/6, 2019 at 14:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.