17.6. Configuration
17.6.1. Configure the JMS Server
To configure the JMS Server for HornetQ, edit the server configuration file. The server configuration is contained in the
EAP_HOME/domain/configuration/domain.xml
file for domain servers, or in the EAP_HOME/standalone/configuration/standalone.xml
file for standalone servers.
The
<subsystem xmlns="urn:jboss:domain:messaging:1.3">
element contains all JMS configuration. Add any JMS ConnectionFactory
, Queue
, or Topic
instances required for the JNDI.
Enable the JMS subsystem in JBoss EAP 6.
In the<extensions>
element, verify that the following line is present and is not commented out:<extension module="org.jboss.as.messaging"/>
Add the basic JMS subsystem.
If the Messaging subsystem is not present in your configuration file, add it.- Look for the
<profile>
which corresponds to the profile you use, and locate its<subsystems>
tag. - Add a new line just beneath the
<subsystems>
tag. Paste the following into it:<subsystem xmlns="urn:jboss:domain:messaging:1.3"> </subsystem>
All further configuration will be added to the empty line above.
Add basic configuration for JMS.
<journal-file-size>102400</journal-file-size> <journal-min-files>2</journal-min-files> <journal-type>NIO</journal-type> <!-- disable messaging persistence --> <persistence-enabled>false</persistence-enabled>
Customize the values above to meet your needs.Warning
The value ofjournal-file-size
must be higher than the size of message sent to server, or the server won't be able to store the message.Add connection factory instances to HornetQ
The client uses a JMSConnectionFactory
object to make connections to the server. To add a JMS connection factory object to HornetQ, include a single<jms-connection-factories>
tag and<connection-factory>
element for each connection factory as follows:<subsystem xmlns="urn:jboss:domain:messaging:1.3"> ... <jms-connection-factories> <connection-factory name="myConnectionFactory"> <connectors> <connector-ref connector-name="netty"/> </connectors> <entries> <entry name="/ConnectionFactory"/> </entries> </connection-factory> </jms-connection-factories> ... </subsystem>
Configure the
netty
connectorThis JMS connection factory uses anetty
connector. This is a reference to a connector object deployed in the server configuration file. The connector object defines the transport and parameters used to actually connect to the server.To configure thenetty
connector, include the following settings:<subsystem xmlns="urn:jboss:domain:messaging:1.3"> ... <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> ... </subsystem>
The connector references themessaging
andmessaging-throughput
socket bindings. Themessaging
socket binding uses port 5445, and themessaging-throughput
socket binding uses port 5455. Ensure the following socket bindings are present in the<socket-binding-groups>
element:<socket-binding-groups> ... <socket-binding-group ... > <socket-binding name="messaging" port="5445"/> <socket-binding name="messaging-throughput" port="5455"/> ... </socket-binding-group> ... </socket-binding-groups>
Add queue instances to HornetQ
There are 4 ways to setup the queue instances (or JMS destinations) for HornetQ.- Use the Management ConsoleTo use the Management Console, the server must have been started in the
Message-Enabled
mode. You can do this by using the-c
option and forcing the use of thestandalone-full.xml
(for standalone servers) configuration file. For example, in the standalone mode, the following will start the server in a message enabled mode./standalone.sh -c standalone-full.xml
Once the server has started, logon to the Management Console and navigate to: Profile → Messaging → Destinations → default → View, and then click the add button to enter details of the JMS destination. - Use the Management CLI:First, connect to the Management CLI:
bin/jboss-cli.sh --connect
Next, change into the messaging subsystem:cd /subsystem=messaging/hornetq-server=default
Finally, execute an add operation, replacing the examples values given below with your own:./jms-queue=testQueue:add(durable=false,entries=["java:jboss/exported/jms/queue/test"])
- Create a JMS configuration file and add it to the deployments folderStart by creating a JMS configuration file: example-jms.xml. Add the following entries to it, replacing the values with your own:
<?xml version="1.0" encoding="UTF-8"?> <messaging-deployment xmlns="urn:jboss:messaging-deployment:1.0"> <hornetq-server> <jms-destinations> <jms-queue name="testQueue"> <entry name="queue/test"/> <entry name="java:jboss/exported/jms/queue/test"/> </jms-queue> <jms-topic name="testTopic"> <entry name="topic/test"/> <entry name="java:jboss/exported/jms/topic/test"/> </jms-topic> </jms-destinations> </hornetq-server> </messaging-deployment>
Save this file in the deployments folder and do a deployment. - Add entries in the JBoss EAP 6 configuration file.Using the standalone-full.xml as an example, find the messaging subsystem in this file.
<subsystem xmlns="urn:jboss:domain:messaging:1.3">
Add the following entries in it, again, replacing the example values with your own. You will need to add these entries in after the </jms-connection-factories> end tag but before the </hornetq-server> element:<jms-destinations> <jms-queue name="testQueue"> <entry name="queue/test"/> <entry name="java:jboss/exported/jms/queue/test"/> </jms-queue> <jms-topic name="testTopic"> <entry name="topic/test"/> <entry name="java:jboss/exported/jms/topic/test"/> </jms-topic> </jms-destinations>
Perform additional configuration
If you need additional settings, review the DTD inEAP_HOME/docs/schema/jboss-messaging_1_3.xsd
.