This section describes procedures on how to install JBoss Messaging into JBoss AS. At the end of this procedure, you will create a JBoss Messaging configuration that will start a clustered or non-clustered messaging server.
By default, JBoss AS 4 ships with JBossMQ as default JMS provider. In order to use the JBoss AS instance with JBoss Messaging, you need to perform the installation procedure described below.
In this section we present two different methods of installing JBoss Messaging in JBoss AS 4.2
For the rest of the procedure we assume JBOSS_CONFIG refers to your new messaging configuration (e.g. messaging-node0 or messaging)
You don't actually have to create an environment variable JBOSS_CONFIG, this is just used in the installation instructions to describe the steps
Set up the JBOSS_HOME environment variable to point to the JBoss 4.2 installation you want to use JBoss Messaging with.
Run the installation script, available in the util directory of the release bundle as follows:
If you want to create a simple non clustered installion based on the default configuration:
cd util ant -f release-admin.xml
If you want to create a clustered installation based on the all configuration or change the configuration name:
cd util ant -f release-admin.xml -Dmessaging.config.source=all -Dmessaging.config.name=messaging-node0
In the above you would substitute messaging-node0 with whatever is the name you want to give the configuration. If you want several cluster nodes on the same machine, e.g. for development purposes then a good convention is to name them messaging-node0, messaging-node1 to match messaging-node<ServerPeerID>
The messaging.config.source variable determines which JBoss AS configuration (e.g. default or all) to base the installation on
The installation script will create a $JBOSS_HOME/server/messaging-node0 configuration. (If you have chosen messaging-node0)
Replace $JBOSS_CONFIG/deploy/jboss-messaging.sar/hsqldb-persistence-service.xml by the databasename>-persistence-service from <downloadPackage>/examples/config.. For instance mysql-persistence-service.xml
Configure a JCA datasource using an example from $JBOSS_HOME/docs/examples/jca
and copying to $JBOSS_CONFIG/deployJBoss Messaging uses DefaultDS by default so you should configure your datasource to bind to that
Remove hsqldb-ds.xml from $JBOSS_CONFIG/deploy
Copy your database driver to $JBOSS_CONFIG/lib
Your database driver can probably be downloaded from your database provider's web site
Ensure the ServerPeerID MBean attribute value in messaging-service.xml is unique for each node. The ServerPeerID value must be a valid integer. Every node MUST have a unique id, including those just connected by message bridges.
If you want to run multiple JBoss Messaging nodes on the same box using the same IP address, e.g. for development purposes, then you can use the ServiceBindingManager to do this as follows:
Uncomment binding manager service from $JBOSS_CONFIG/conf/jboss-service.xml
Specify the desired port rage (e.g. ports-01, ports-02... etc)
Look at $JBOSS_HOME/docs/examples/binding-manager/sample-bindings.xml. Here is an example:
<service-config name="jboss.messaging:service=Connector,transport=bisocket" delegateClass="org.jboss.services.binding.AttributeMappingDelegate"> <delegate-config> <attribute name="Configuration"><![CDATA[ <config> <invoker transport="bisocket"> <!-- There should be no reason to change these parameters - warning! Changing them may stop JBoss Messaging working correctly --> <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute> <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute> <attribute name="dataType" isParam="true">jms</attribute> <attribute name="socket.check_connection" isParam="true">false</attribute> <attribute name="timeout" isParam="true">0</attribute> <attribute name="serverBindAddress">${jboss.bind.address}</attribute> <attribute name="serverBindPort">4657</attribute> <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute> <attribute name="serverSocketClass" isParam="true">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute> <attribute name="numberOfCallRetries" isParam="true">1</attribute> <attribute name="pingFrequency" isParam="true">214748364</attribute> <attribute name="pingWindowFactor" isParam="true">10</attribute> <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute> <!-- Periodicity of client pings. Server window by default is twice this figure --> <attribute name="clientLeasePeriod" isParam="true">10000</attribute> <!-- Number of seconds to wait for a connection in the client pool to become free --> <attribute name="numberOfRetries" isParam="true">10</attribute> <!-- Max Number of connections in client pool. This should be significantly higher than the max number of sessions/consumers you expect --> <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute> <!-- Use these parameters to specify values for binding and connecting control connections to work with your firewall/NAT configuration <attribute name="secondaryBindPort">xyz</attribute> <attribute name="secondaryConnectPort">abc</attribute> --> </invoker> <handlers> <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler> </handlers> </config> ]]></attribute> </delegate-config> <binding port="4657"/> </service-config>
You should ensure that each node is configured to use a different ports range.
There are few extra steps at Section 4.1.3, “Extra steps to complete your installation”
For this procedure we assume you already have your custom configuration located at JBOSS_CONFIG=$JBOSS_HOME/server/<myconfiguration>, and that it contains a JBoss MQ installation.
You don't actually have to create an environment variable JBOSS_CONFIG, this is just used in the installation instructions to describe the steps
Move $JBOSS_CONFIG/deploy/jms/hajndi-jms-ds.xml and $JBOSS_CONFIG/deploy/jms/jms-ra.rar to $JBOSS_CONFIG/deploy
Remove the old JBoss MQ by removing the directory $JBOSS_CONFIG/deploy/jms.
.Remove the old JBoss MQ jar file: $JBOSS_CONFIG/lib/jbossmq.jar
Make sure you don't have any JBossMQ files under $JBOSS_CONFIG/deploy-hasingleton. For that just remove $JBOSS_CONFIG/deploy-hasingleton/jms
Add a security policy called "messaging" on $JBOSS_CONFIG/config/login-config.xml. You could use this as an example, or create one according to JBoss Security Documentation:
<application-policy name = "messaging"> <authentication> <login-module code = "org.jboss.security.auth.spi.UsersRolesLoginModule" flag = "required" > <module-option name = "unauthenticatedIdentity">guest</module-option> <module-option name = "usersProperties">props/messaging-users.properties</module-option> <module-option name = "rolesProperties">props/messaging-roles.properties</module-option> </login-module> </authentication> </application-policy>
In case you are using the above policy you should also create files messaging-users.properties and messaging-roles.properties in the $JBOSS_CONFIG/config/props/ directory
.
# messaging-roles.properties # Add roles as you like # user=role1,role2,... # guest=guest
# messaging-users.properties # Add users as you like # user=password # guest=guest
Unzip jboss-messaging.sar from your download package into the directory JBOSS_CONFIG/deploy/jboss-messaging.sar
JBoss Messaging should be deployed unzipped (exploded) so you have easy access to its config files which are stored there.
Copy jboss-messaging.jar from your download package into the directory JBOSS_CONFIG/lib
jboss-messaging.jar needs to go in the lib directory so it is accessible to other services e.g. the JBoss Transactions Recovery Manager
Replace $JBOSS_CONFIG/deploy/jboss-messaging.sar/hsqldb-persistence-service.xml by the databasename>-persistence-service from <downloadPackage>/examples/config.. For instance mysql-persistence-service.xml
Configure a JCA datasource using an example from $JBOSS_HOME/docs/examples/jca
and copying to $JBOSS_CONFIG/deployJBoss Messaging uses DefaultDS by default so you should configure your datasource to bind to that
Remove hsqldb-ds.xml from $JBOSS_CONFIG/deploy
Copy your database driver to $JBOSS_CONFIG/lib
Your database driver can probably be downloaded from your database provider's web site
Ensure the ServerPeerID MBean attribute value in messaging-service.xml is unique for each node on the cluster. The ServerPeerID value must be a valid integer.
If you want to run multiple JBoss Messaging nodes on the same box using the same IP address, e.g. for development purposes, then you can use the ServiceBindingManager to do this as follows:
Uncomment binding manager service from $JBOSS_CONFIG/conf/jboss-service.xml
Specify the desired port rage (e.g. ports-01, ports-02... etc)
Look at $JBOSS_HOME/docs/examples/binding-manager/sample-bindings.xml. On each port range, JBoss Remoting configuration should look like:
<service-config name="jboss.messaging:service=Connector,transport=bisocket" delegateClass="org.jboss.services.binding.AttributeMappingDelegate"> <delegate-config> <attribute name="Configuration"><![CDATA[ <config> <invoker transport="bisocket"> <!-- There should be no reason to change these parameters - warning! Changing them may stop JBoss Messaging working correctly --> <attribute name="marshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute> <attribute name="unmarshaller" isParam="true">org.jboss.jms.wireformat.JMSWireFormat</attribute> <attribute name="dataType" isParam="true">jms</attribute> <attribute name="socket.check_connection" isParam="true">false</attribute> <attribute name="timeout" isParam="true">0</attribute> <attribute name="serverBindAddress">${jboss.bind.address}</attribute> <attribute name="serverBindPort">4657</attribute> <attribute name="clientSocketClass" isParam="true">org.jboss.jms.client.remoting.ClientSocketWrapper</attribute> <attribute name="serverSocketClass" isParam="true">org.jboss.jms.server.remoting.ServerSocketWrapper</attribute> <attribute name="numberOfCallRetries" isParam="true">1</attribute> <attribute name="pingFrequency" isParam="true">214748364</attribute> <attribute name="pingWindowFactor" isParam="true">10</attribute> <attribute name="onewayThreadPool">org.jboss.jms.server.remoting.DirectThreadPool</attribute> <!-- Periodicity of client pings. Server window by default is twice this figure --> <attribute name="clientLeasePeriod" isParam="true">10000</attribute> <!-- Number of seconds to wait for a connection in the client pool to become free --> <attribute name="numberOfRetries" isParam="true">10</attribute> <!-- Max Number of connections in client pool. This should be significantly higher than the max number of sessions/consumers you expect --> <attribute name="JBM_clientMaxPoolSize" isParam="true">200</attribute> <!-- Use these parameters to specify values for binding and connecting control connections to work with your firewall/NAT configuration <attribute name="secondaryBindPort">xyz</attribute> <attribute name="secondaryConnectPort">abc</attribute> --> </invoker> <handlers> <handler subsystem="JMS">org.jboss.jms.server.remoting.JMSServerInvocationHandler</handler> </handlers> </config> ]]></attribute> </delegate-config> <binding port="4657"/> </service-config>
You should ensure that each node is configured to use a different ports range.
There are few extra steps at Section 4.1.3, “Extra steps to complete your installation”
You should also make these changes on any configuration you choose, to remove all references to the old JBossMQ:
Edit $JBOSS_CONFIG/deploy/jms-ds.xml and replace jboss.mq by jboss.messaging on every occurrence
If you are in a clustered installation, then do the above with the file $JBOSS_CONFIG/deploy/hajndi-jms-ds.xml
Edit $JBOSS_CONFIG/conf/standardjboss.xml and set CreateJBossMQDestination to false on every occurrence
Make sure it looks like this:
<CreateJBossMQDestination>false</CreateJBossMQDestination>
Those Proxies will try to create a Destination on JBossMQ if they can't find it on JNDI, what would cause some errors related to JBoss MQ.
Edit $JBOSS_CONFIG/conf/jboss-service.xml and remove the reference to JBoss MQ on JSR-77 Management Bean:
<!-- ==================================================================== --> <!-- JSR-77 Single JBoss Server Management Domain --> <!-- ==================================================================== --> <mbean code="org.jboss.management.j2ee.LocalJBossServerDomain" ... Remove this line ... <attribute name="JMSService">jboss.mq:service=DestinationManager</attribute>
Change $JBOSS_CONFIG/conf/login-config.xml and remove jboss-mq security policies
### Remove these lines: <!-- Security domain for JBossMQ --> <application-policy name = "jbossmq"> <authentication> <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule" flag = "required"> <module-option name = "unauthenticatedIdentity">guest</module-option> <module-option name = "dsJndiName">java:/DefaultDS</module-option> <module-option name = "principalsQuery"> SELECT PASSWD FROM JMS_USERS WHERE USERID=?</module-option> <module-option name = "rolesQuery"> SELECT ROLEID, 'Roles' FROM JMS_ROLES WHERE USERID=?</module-option> </login-module> </authentication> </application-policy> <!-- Security domain for JBossMQ when using file-state-service.xml <application-policy name = "jbossmq"> <authentication> <login-module code = "org.jboss.mq.sm.file.DynamicLoginModule" flag = "required"> <module-option name = "unauthenticatedIdentity">guest</module-option> <module-option name = "sm.objectname">jboss.mq:service=StateManager</module-option> </login-module> </authentication> </application-policy> -->
To run the server, execute the run.bat or run.sh script as appropriate for your operating system, in the $JBOSS_HOME/bin directory.
cd $JBOSS_HOME/bin ./run.sh -c <config name>
Where config_name is the name of the JBoss AS configuration where you have installed messaging. (The default is 'messaging')
A successful JBoss Messaging deployment generates logging output similar to for a non clustered installation (for a clustered installation you will also see extra cluster related output)
.... 13:19:14,914 WARN [JDBCPersistenceManager] JBoss Messaging Warning: DataSource connection transaction isolation should be READ_COMMITTED, but it is currently NONE. Using an isolation level less strict than READ_COMMITTED may lead to data consistency problems. Using an isolation level more strict than READ_COMMITTED may lead to deadlock. 13:19:15,166 INFO [ServerPeer] JBoss Messaging 1.4.0.GA server [0] started 13:19:15,411 INFO [ConnectionFactory] Connector bisocket://127.0.0.1:4457 has leasing enabled , lease period 10000 milliseconds 13:19:15,412 INFO [ConnectionFactory] [/ConnectionFactory, /XAConnectionFactory, java:/Connec tionFactory, java:/XAConnectionFactory] started 13:19:15,412 WARN [ConnectionFactoryJNDIMapper] supportsFailover attribute is true on connect ion factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support failover 13:19:15,413 WARN [ConnectionFactoryJNDIMapper] supportsLoadBalancing attribute is true on co nnection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balanc ing 13:19:15,449 INFO [ConnectionFactory] Connector bisocket://127.0.0.1:4457 has leasing enabled , lease period 10000 milliseconds 13:19:15,449 INFO [ConnectionFactory] [/ClusteredConnectionFactory, /ClusteredXAConnectionFac tory, java:/ClusteredConnectionFactory, java:/ClusteredXAConnectionFactory] started 13:19:15,468 INFO [QueueService] Queue[/queue/DLQ] started, fullSize=200000, pageSize=2000, d ownCacheSize=2000 13:19:15,474 INFO [QueueService] Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize =2000, downCacheSize=2000 13:19:15,476 INFO [TopicService] Topic[/topic/testTopic] started, fullSize=200000, pageSize=2 000, downCacheSize=2000 13:19:15,478 INFO [TopicService] Topic[/topic/securedTopic] started, fullSize=200000, pageSiz e=2000, downCacheSize=2000 13:19:15,479 INFO [TopicService] Topic[/topic/testDurableTopic] started, fullSize=200000, pag eSize=2000, downCacheSize=2000 13:19:15,482 INFO [QueueService] Queue[/queue/testQueue] started, fullSize=200000, pageSize=2 000, downCacheSize=2000 13:19:15,483 INFO [QueueService] Queue[/queue/A] started, fullSize=200000, pageSize=2000, dow nCacheSize=2000 13:19:15,485 INFO [QueueService] Queue[/queue/B] started, fullSize=200000, pageSize=2000, dow nCacheSize=2000 13:19:15,487 INFO [QueueService] Queue[/queue/C] started, fullSize=200000, pageSize=2000, dow nCacheSize=2000 13:19:15,489 INFO [QueueService] Queue[/queue/D] started, fullSize=200000, pageSize=2000, dow nCacheSize=2000 13:19:15,490 INFO [QueueService] Queue[/queue/ex] started, fullSize=200000, pageSize=2000, do wnCacheSize=2000 13:19:15,501 INFO [QueueService] Queue[/queue/PrivateDLQ] started, fullSize=200000, pageSize= 2000, downCacheSize=2000 13:19:15,503 INFO [QueueService] Queue[/queue/PrivateExpiryQueue] started, fullSize=200000, p ageSize=2000, downCacheSize=2000 13:19:15,507 INFO [QueueService] Queue[/queue/QueueWithOwnDLQAndExpiryQueue] started, fullSiz e=200000, pageSize=2000, downCacheSize=2000 13:19:15,508 INFO [TopicService] Topic[/topic/TopicWithOwnDLQAndExpiryQueue] started, fullSiz e=200000, pageSize=2000, downCacheSize=2000 13:19:15,511 INFO [QueueService] Queue[/queue/QueueWithOwnRedeliveryDelay] started, fullSize= 200000, pageSize=2000, downCacheSize=2000 13:19:15,512 INFO [TopicService] Topic[/topic/TopicWithOwnRedeliveryDelay] started, fullSize= 200000, pageSize=2000, downCacheSize=2000 13:19:15,514 INFO [QueueService] Queue[/queue/testDistributedQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000 13:19:15,519 INFO [TopicService] Topic[/topic/testDistributedTopic] started, fullSize=200000, pageSize=2000, downCacheSize=2000 13:19:15,809 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:servic e=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA' 13:19:15,834 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-consol e.war/ 13:19:16,322 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080 13:19:16,342 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009 13:19:16,480 INFO [Server] JBoss (MX MicroKernel) [4.2.0.GA (build: SVNTag=JBoss_4_2_0_GA dat e=200705111440)] Started in 19s:359ms
The release bundle contains a series of examples that should run "out of the box" and could be used to validate a new installation. Such an example sends a persistent JMS message to a queue called queue/testQueue.
To run the example and validate the installation, open an new command line window and set the JBOSS_HOME environment variable to point to the JBoss AS 4.x installation you've just installed Messaging on. Navigate to the folder where you extracted the release bundle and drill down to /examples/queue. Apache Ant must pe present in your path in order to be able to run the example.
Make sure you start the JBoss server before trying to run the tests
setenv JBOSS_HOME=<your_JBoss_installation> cd .../examples/queue $ant
A successfull execution log output looks similar to:
[tim@Vigor14 queue]$ ant Buildfile: build.xml identify: [echo] ########################################################################### [echo] # Running the QUEUE example # [echo] ########################################################################### [echo] The queue: testQueue [echo] The client jar: ../../../output/lib/jboss-messaging-client.jar sanity-check: init: [mkdir] Created dir: /home/tim/dev/jboss-messaging/trunk/docs/examples/queue/output/classe s [mkdir] Created dir: /home/tim/dev/jboss-messaging/trunk/docs/examples/common/output/class es compile: [javac] Compiling 5 source files to /home/tim/dev/jboss-messaging/trunk/docs/examples/comm on/output/classes [javac] Compiling 1 source file to /home/tim/dev/jboss-messaging/trunk/docs/examples/queue /output/classes run: [java] Queue /queue/testQueue exists [java] The message was successfully sent to the testQueue queue [java] Received message: Hello! [java] The example connected to JBoss Messaging version 1.4.0.GA (1.4) [java] ##################### [java] ### SUCCESS! ### [java] ##################### BUILD SUCCESSFUL Total time: 5 seconds [tim@Vigor14 queue]$
It is recommended to run all validation examples available in the example directory (queue, topic, mdb, stateless, etc.). In Chapter 5, Running the Examples, we will have a look at each of those examples.
In order to access JBoss Messaging from a client outside the JBoss app server, you will need to ensure the following jar files are on the client classpath:
jboss-messaging-client.jar - This is available in the messaging distribution
jbossall-client.jar - This is available in your $JBOSS_HOME/client directory
$JBOSS_HOME/server/<SERVER_NAME>/deploy/jboss-aop.deployer/jboss-aop.jar
JBoss AOP 1.5.5.GA+
http://repository.jboss.com/jboss/aop/1.5.5.GA/lib/
(For AOP, sometimes you have to use a specific JAR according to your JVM of choice. Use the most convenient for you)
$JBOSS_HOME/server/<SERVER_NAME>/lib/javassist.jar
Javassist 3.5.0.GA-brew+
$JBOSS_HOME/server/<SERVER_NAME>/lib/trove.jar
trove 1.0.2-brew
log4j