Chapter 4. JBoss Messaging Installation

This section describes procedures on how to install JBoss Messaging into JBoss Application Server community edition 4.2. At the end of this procedure, you will create a JBoss Messaging configuration that will start a clustered or non-clustered messaging server.

Please note that JBoss EAP 4.3 comes with JBoss Messaging pre-installed as default JMS provider so if you are using that, there is no need to manually install JBoss Messaging

By default, JBoss AS 4.2 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.

Note

A JBossMQ and a JBoss Messaging instance cannot coexist, at least not unless special precautions are taken. Do not simply attempt to copy the Messaging release artifact jboss-messaging.sar over to the JBoss instance deploy directory. Follow one of the alternate installation procedures outlined below instead.

Note

We only recommend and support installing JBoss Messaging in JBoss AS 4.2 or later. You should avoid using JBoss Messaging on any version of JBoss AS prior to JBoss 4.2.0.GA, such as 4.0.5.GA and 4.0.4.GA.

Note

JBoss Messaging is built against the JBoss AS 4.2 libraries which are built using Java 5. Therefore JBoss Messaging only runs with Java 5 or later.

4.1. Installing JBoss Messaging on JBoss AS 4.2

In this section we present two different methods of installing JBoss Messaging in JBoss AS 4.2

4.1.1. Automated Installation

Note

This procedure should only be performed from a clean JBoss AS 4.2 installation. If you have modifed the JBoss AS 4.2 installation at all since installation then you will need to perform a manual clustered JBoss Messaging installation

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)

  • Warning

    For a clustered installation it is mandatory that a shared database is available to all nodes in the cluster. The default JBoss AS uses HSQLDB for its database which is a local shared database. Therefore in order to use clustering you must replace this with a different shared database. If the database is not replaced then clustering will not work.

    • 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

      .

      If you are installing in a clustered configuration make sure to set the Clustered attribute to true

    • Configure a JCA datasource using an example from $JBOSS_HOME/docs/examples/jca

      and copying to $JBOSS_CONFIG/deploy

      JBoss 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.

    Warning

    Each node must have a unique ServerPeerID irrespective of whether you are using clustering.

  • 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:

    Warning

    JBoss5 has introduced a much simpler ServiceBindingManager. You should refer to the JBoss5 documentation about how to administer the new bindingManager if you are using JBoss5.
    • 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>
                    
                    

      Warning

      The above config only apply to JBoss 4.2 and EAP 4.3. On EAP4.3 and JBOSS 4.2 You must ensure that the config (like above) is identical to that in remoting-bisocket-service.xml With the exception of the actual serverBindPort which clearly must be different for each ports range. Please note that the default JBoss Messaging service binding manager bindings in sample-bindings.xml shipped with JBAS 4.2.0 may be out of date and you will need to copy the config from remoting-bisocket-service.xml. DO NOT just copy and paste from the above example - copy it from the JBoss Messaging distribution.. On JBoss5 the ports are controlled by system-property substitution hence you don't need to worry about copying the config into bindings.xml

      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”

  • That's it

4.1.2. Manual Installation

Note

This installation procedure should be performed if you are installing into a JBoss AS configuration that you have changed in some way from the default JBoss AS distribution. If you are just using the standard, untouched JBoss AS 4.2 distribution you can use the automated procedure above

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

    .

    Note

    You can find an example messaging-users.properties and messaging-roles.properties in the JBoss Messaging distribution in the <downloadPackage>src/etc/server/default/config 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

  • Warning

    For a clustered installation it is mandatory that a shared database is available to all nodes in the cluster. The default JBoss AS uses HSQLDB for its database which is a local shared database. Therefore in order to use clustering you must replace this with a different shared database. If the database is not replaced then clustering will not work.
    • 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

      If you are installing in a clustered configuration make sure to set the Clustered attribute to true

    • Configure a JCA datasource using an example from $JBOSS_HOME/docs/examples/jca

      and copying to $JBOSS_CONFIG/deploy

      JBoss 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.

    Warning

    Each node must have a unique ServerPeerID irrespective of whether you are using clustering.
  • 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>
                    
                    

      Warning

      You must ensure that the config (like above) is identical to that in remoting-bisocket-service.xml With the exception of the actual serverBindPort which clearly must be different for each ports range. Please note that the default JBoss Messaging service binding manager bindings in sample-bindings.xml shipped with JBAS 4.2.0 may be out of date and you will need to copy the config from remoting-bisocket-service.xml. DO NOT just copy and paste from the above example - copy it from the JBoss Messaging distribution.

      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”

  • That's it

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:

  • Warning

    SECURITY RISK! To avoid a security risk, you MUST specify the value of the attribute SuckerPassword in the Server Peer config (messaging-service.xml). If you do not specify a value, the default value will be used. Any person that knows the default value will be able to access to all destinations on the server. The password chosen should only be exposed to administrators

  • Note

    JBoss Messaging 1.4.4 requires pecific versions of jboss-remoting.jar. If you are installing JBoss Messaging with JBoss 4.2+, you should use this version: Remoting 2.2.3. If you are using EAP you don't need to take any extra steps on the remoting installation.

  • 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>
    -->
                 
                

4.2. Starting the Server

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

   

Note

The warning message "DataSource connection transaction isolation should be READ_COMMITTED, but it is currently NONE" is there to remind you that by default JBossAS ships with Hypersonic, an in-memory Java-based database engine, which is apropriate for demo purposes, but not for heavy load production environments. The Critique of Hypersonic wiki page outlines some of the well-known issues occuring when using this database.

Warning

Before using Messaging in production, you must configure the Messaging instance to use an enterprise-class database backend such as Oracle, Sybase, PostgreSQL, MS SQL or MySQL, otherwise you risk losing your data. See Section 6.2, “Changing the Database” for details about replacing Hypersonic.

4.3. Installation Validation

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.

4.4. Accessing JBoss Messaging from a remote client - JBoss 4.2 and EAP 4.3

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:

  • Note

    This version of JBoss Messaging requires JBoss Remoting 2.2.3. If you are using EAP 4.3 you will have the required JAR available already. Always use the version of JBoss Remoting that comes with the EAP 4.3. If you're using a different version of Application Server you should download it. The patched jar can be found at here [http://repository.jboss.com/jboss/remoting/2.2.3-brew/lib/]. Please download it and make sure this jar is on your classpath *before* jbossall-client.jar.
  • 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 2.0.1.GA

    http://repository.jboss.com/jboss/aop/2.0.1.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.8.0.GA

    http://repository.jboss.com/javassist/3.8.0.GA/lib/

  • $JBOSS_HOME/server/<SERVER_NAME>/lib/trove.jar

    trove 1.0.2

    http://repository.jboss.com/trove/1.0.2/lib/

  • log4j

4.5. Migrating Messages from JBoss MQ to JBoss Messaging

This configuration will allow you to migrate your systems using JBossMQ to JBM(JBoss Messaging). Many Enterprise systems are complex and have multiple applications and can't be migrated from JBossMQ to JBM all at one time.

Made up Use Case: For instance, your business is selling items, some you make directly and some you farm out to other distributors. Your ordering system is JBossMQ based. Customers place orders that are then queued up to be processed(via JBossMQ). You also use MQ to queue up the orders that you need to produce and you also queue up the orders that will go to your other distributors. You use MDB's in three separate places in your operation. You want to do a staged migration from JBossMQ to JBM. That requires that JBossMQ and JBM work together. This is exactly what the JBM bridge was meant to do. It's meant to take messages from one queue/topic and transfer them to another queue/topic. This helps with the migration by allowing you to pull messages from your JBossMQ queues automatically and push them into your JBM Queues. You can also do the opposite, you can push messages from your JBM system to your JBossMQ system. In our example, we want to replace the ordering side(producer) with JBM. We push messages into the JBM Order queue, but we set the bridge up to send all of those messages to the JBossMQ Order queue. The rest of your processing happens as normal. Lets say you want to leave your ordering system intact, but you want to have JBM and EJB3 MDBs process the orders. You can have your old client put messages in JBossMQ as normal, but you set the bridge up to pull the messages from JBossMQ Order queue and push them into the JBM Order queue.

This allows JBM and JBossMQ to interact together by pushing messages back and forth between different systems.

The Following Assumptions are made:

  • You have one JBoss instance set up for JBoss Messaging and One JBoss instance set up that has your old JBoss MQ on it.
  • We are copying messages from JBossMQ(Source) to JBM(Target)

4.5.1. Steps to Set up the bridge

  • Copy the jbossmq.jar from the Source Machine(JBossMQ) under the server/default/lib/ to the messaging configuration on the Target JBM machine(server/messaging/lib)

    Note

    substitute what ever your messaging server configuration is above. I used the default stand alone messaging server configuration note: This is required to dereference the JBossMQ objects that are dereferenced on the JBM side. If you don't copy the jar over, you will get a "java.lang.ClassCastException: javax.naming.Reference" exception and the bridge will not be able to start
  • Add the remote JBossMQ provider to the jms-ds.xml file in the server/messaging/deploy directory on your target(JBM) machine.

    Here is an example of the provider to add.

    <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
                   name="jboss.messaging:service=JMSProviderLoader,
                   name=MyRemoteJMSProvider">
      <attribute name="ProviderName">RemoteXAConnectionFactory</attribute>
      <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
      <!-- The combined connection factory -->
      <attribute name="FactoryRef">XAConnectionFactory</attribute>
      <!-- The queue connection factory -->
      <attribute name="QueueFactoryRef">XAConnectionFactory</attribute>
      <!-- The topic factory -->
      <attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
      <attribute name="Properties">
         java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
         java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
         java.naming.provider.url=192.168.0.199:1099
      </attribute>
    </mbean>
                

    Note

    you will need to change the java.naming.provider.url so that it points to your JBossMQ machine. Everything else should remain the same. Keep your jms-ds.xml file open, because you will be addning another entry in it for the next step.
  • Add the Bridge provider to the jms-ds.xml file in the server/messaging/deploy directory on your target(JBM) machine.

    Here is an example bridge configuration

    <mbean code="org.jboss.jms.server.bridge.BridgeService"
                      name="jboss.messaging:service=Bridge,name=TestBridge"
                      xmbean-dd="xmdesc/Bridge-xmbean.xml">
         <depends optional-attribute-name="SourceProviderLoader">
                      jboss.messaging:service=JMSProviderLoader,
                      name=MyRemoteJMSProvider</depends>
         <depends optional-attribute-name="TargetProviderLoader">
                      jboss.messaging:service=JMSProviderLoader,
                      name=JMSProvider</depends>
         <attribute name="SourceDestinationLookup">/queue/testQueue</attribute>
         <attribute name="TargetDestinationLookup">/queue/A</attribute>
         <attribute name="QualityOfServiceMode">0</attribute>
         <attribute name="MaxBatchSize">5</attribute>
         <attribute name="MaxBatchTime">-1</attribute>
         <attribute name="FailureRetryInterval">5000</attribute>
         <attribute name="MaxRetries">-1</attribute>
         <attribute name="AddMessageIDInHeader">false</attribute>
    </mbean>
                   

    Note

    my target is the current JBM JMS Provider and the source is the JBossMQ remote provider. If you have a pretty stock system and you want to move messages from JBossMQ to JBM, you will not have to change this example except for the queue Names. If you wish to move from JBM to JBossMQ, just switch the soure and target definitions.

Start the JBossMQ system and then just start the JBM system and the messages will begin to move over.

The following is an example of the jms-ds.xml file that was used for the test. If you want to test the bridge first and you have a stock JBM system(JBM has been installed using the default configuration), then you can just copy the jms-ds.xml file over the one in server/messaging/deploy and begin to put messages in the JBossMQ system under the /queue/TestQueue. The messages will then be moved over to your JBM queue /queue/A. Both of these queues exist in the stock versions of JBM and JBossMQ.

<?xml version="1.0" encoding="UTF-8"?>

<connection-factories>

  <!-- ==================================================================== -->
  <!-- JMS Stuff                                                            -->
  <!-- ==================================================================== -->

  <!-- The JMS provider loader -->
  <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
    name="jboss.messaging:service=JMSProviderLoader,name=JMSProvider">
    <attribute name="ProviderName">DefaultJMSProvider</attribute>

    <attribute name="ProviderAdapterClass">
      org.jboss.jms.jndi.JNDIProviderAdapter
    </attribute>
    <!-- The combined connection factory -->
    <attribute name="FactoryRef">java:/XAConnectionFactory</attribute>
    <!-- The queue connection factory -->
    <attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>
    <!-- The topic factory -->

    <attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>
    <!-- Uncomment to use HAJNDI to access JMS
    <attribute name="Properties">
       java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
       java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
       java.naming.provider.url=localhost:1100
    </attribute>
    -->
  </mbean>


<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
         name="jboss.messaging:service=JMSProviderLoader,
         name=MyRemoteJMSProvider">
     <attribute name="ProviderName">RemoteXAConnectionFactory</attribute>
     <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
     <!-- The combined connection factory -->

     <attribute name="FactoryRef">XAConnectionFactory</attribute>
     <!-- The queue connection factory -->
     <attribute name="QueueFactoryRef">XAConnectionFactory</attribute>
     <!-- The topic factory -->
     <attribute name="TopicFactoryRef">XAConnectionFactory</attribute>
     <attribute name="Properties">
        java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
        java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
        java.naming.provider.url=192.168.0.199:1099
     </attribute>

</mbean>

<mbean code="org.jboss.jms.server.bridge.BridgeService"
         name="jboss.messaging:service=Bridge,name=TestBridge"
         xmbean-dd="xmdesc/Bridge-xmbean.xml">
     <depends optional-attribute-name="SourceProviderLoader">
         jboss.messaging:service=JMSProviderLoader,
         name=MyRemoteJMSProvider</depends>
     <depends optional-attribute-name="TargetProviderLoader">
         jboss.messaging:service=JMSProviderLoader,
         name=JMSProvider</depends>
     <attribute name="SourceDestinationLookup">/queue/testQueue</attribute>
     <attribute name="TargetDestinationLookup">/queue/A</attribute>
     <attribute name="QualityOfServiceMode">0</attribute>

     <attribute name="MaxBatchSize">5</attribute>
     <attribute name="MaxBatchTime">-1</attribute>
     <attribute name="FailureRetryInterval">5000</attribute>
     <attribute name="MaxRetries">-1</attribute>
     <attribute name="AddMessageIDInHeader">false</attribute>
</mbean>

  <!-- The server session pool for Message Driven Beans -->
  <mbean code="org.jboss.jms.asf.ServerSessionPoolLoader"
    name="jboss.messaging:service=ServerSessionPoolMBean,name=StdJMSPool">
    <depends optional-attribute-name="XidFactory">jboss:service=XidFactory</depends>
    <attribute name="PoolName">StdJMSPool</attribute>
    <attribute name="PoolFactoryClass">
      org.jboss.jms.asf.StdServerSessionPoolFactory
    </attribute>
  </mbean>

  <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
  <tx-connection-factory>
    <jndi-name>JmsXA</jndi-name>
    <xa-transaction/>
    <rar-name>jms-ra.rar</rar-name>
    <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory
         </connection-definition>
    <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic
         </config-property>

    <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">
         java:/DefaultJMSProvider</config-property>
    <max-pool-size>20</max-pool-size>
    <security-domain-and-application>JmsXARealm</security-domain-and-application>
  </tx-connection-factory>

</connection-factories>

      

You can also merge topics back and forth from JBM to JBossMQ, by setting the subscription name and client id. You can see these arguments in the JBM Bridge chapter.