Configure a JMS queue in standalone.xml of JBoss AS7

Today I am going show how we can configure JMS queue support in standalone.xml of JBoss AS7. Actually in earlier versions of JBoss, JMS configuration was in the standalone.xml file. But in JBoss AS7 and after versions, all the JMS queue configurations are in standalone-full.xml and standalone-ha.xml files and removed from other files.

When we start the server with default configurations, it will run the standalone.xml file. If we want to setup a queue in the server, we have to configure it in standalone-full.xml file and start the server with that file like follow.

 For Linux:  JBOSS_HOME_SERVER_1/bin/standalone.sh -c standalone-full.xml
 For Windows:  JBOSS_HOME_SERVER_1\bin\standalone.bat -c standalone-full.xml

But we may need to keep the default configurations and start the server with that. Therefore we need to add queue configurations into that standalone.xml file.

First open standalone.xml file located in following folder.

JBOSS_HOME/standalone/configuration

Then we need to create an extension for messaging. Add following part under <extensions> element

<extension module="org.jboss.as.messaging"/>

After that, under <profile> <subsystem xmlns=”urn:jboss:domain:ejb3:1.2″> element, add following part.

<mdb>
     <resource-adapter-ref resource-adapter-name="hornetq-ra"/>
     <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb>

After doing that, we should add a subsystem under profile which will include the all the configurations related to the queue. JBoss use HornetQ as JMS queue implementation. Add following subsystem under <profile> element.

<subsystem xmlns="urn:jboss:domain:messaging:1.1">
            <hornetq-server>
                <persistence-enabled>true</persistence-enabled>
                <journal-file-size>102400</journal-file-size>
                <journal-min-files>2</journal-min-files>

                <connectors>
                    <netty-connector name="netty" socket-binding="messaging"/>
                    <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
                        <param key="batch-delay" value="50"/>
                    </netty-connector>
                    <in-vm-connector name="in-vm" server-id="0"/>
                </connectors>

                <acceptors>
                    <netty-acceptor name="netty" socket-binding="messaging"/>
                    <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
                        <param key="batch-delay" value="50"/>
                        <param key="direct-deliver" value="false"/>
                    </netty-acceptor>
                    <in-vm-acceptor name="in-vm" server-id="0"/>
                </acceptors>

                <security-settings>
                    <security-setting match="#">
                        <permission type="send" roles="guest"/>
                        <permission type="consume" roles="guest"/>
                        <permission type="createNonDurableQueue" roles="guest"/>
                        <permission type="deleteNonDurableQueue" roles="guest"/>
                    </security-setting>
                </security-settings>

                <address-settings>
                    <address-setting match="#">
                        <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                        <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                        <redelivery-delay>0</redelivery-delay>
                        <max-size-bytes>10485760</max-size-bytes>
                        <address-full-policy>BLOCK</address-full-policy>
                        <message-counter-history-day-limit>10</message-counter-history-day-limit>
                    </address-setting>
                </address-settings>

                <jms-connection-factories>
                    <connection-factory name="InVmConnectionFactory">
                        <connectors>
                            <connector-ref connector-name="in-vm"/>
                        </connectors>
                        <entries>
                            <entry name="java:/ConnectionFactory"/>
                        </entries>
                    </connection-factory>
                    <connection-factory name="RemoteConnectionFactory">
                        <connectors>
                            <connector-ref connector-name="netty"/>
                        </connectors>
                        <entries>
                            <entry name="RemoteConnectionFactory"/>
                            <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                        </entries>
                    </connection-factory>
                    <pooled-connection-factory name="hornetq-ra">
                        <transaction mode="xa"/>
                        <connectors>
                            <connector-ref connector-name="in-vm"/>
                        </connectors>
                        <entries>
                            <entry name="java:/JmsXA"/>
                        </entries>
                    </pooled-connection-factory>
                </jms-connection-factories>

                <jms-destinations>
                    <jms-queue name="example">
                        <entry name="queue/exampleQueue"/>
                        <entry name="java:jboss/exported/jms/queue/exampleQueue"/>
                    </jms-queue>
                </jms-destinations>
            </hornetq-server>
        </subsystem>

Finally, we need to add socket binding for messaging. Add following part under <socket-binding-group name=”standard-sockets” default-interface=”public” port-offset=”${jboss.socket.binding.port-offset:0}”> element

<socket-binding name="messaging" port="5445"/>
<socket-binding name="messaging-throughput" port="5455"/>

Now we are done. You can save the file and start the server by typing only,

For Linux:  JBOSS_HOME_SERVER_1/bin/standalone.sh
For Windows:  JBOSS_HOME_SERVER_1\bin\standalone.bat

And now you can add new queues to the server by adding them into this standalone.xml file

Leave a comment

Website Powered by WordPress.com.

Up ↑