Developing JMS Applications Using JBoss1

Shortly, you will be developing a simple JMS application. As with all the code examples in this book, the application will be developed using J2EE RI. Although J2EE RI provides a good environment for learning about JMS, it is not intended to support commercial applications. Before developing this JMS application, there will be a short digression to show the JMS features available with JBoss.

JBoss is in an open-source implementation of J2EE developed by the JBoss Group. JBoss is available to download for free from www.jboss.org.

JMS Implementation in JBoss

JBoss contains a JMS provider called JBossMQ. JBossMQ is fully JMS API-compliant and can be used for standalone JMS clients. JBossMQ has a number of configuration files, the most important of which is called jboss.jcml. This file resides under the JBoss installation in the conf/default directory. To create a message application in Jboss, you first have to read or edit this file to

  1. Look up the names of the available connection factories

  2. Add destinations (queues and topics)

Additionally, you can optionally add client identifiers (JBossMQ users) to the jbossmq-state.xml file (also in conf/default) for authentication. The purpose and use of authentication is to associate a client connection and its objects with a state maintained by the JMS provider. At the current time, the only state defined is that required to support durable subscriptions.

Administered Objects

Connection factories and destinations are the administered objects that are configured by the JMS administrator.

Connection Factory

The purpose of a connection factory is to encapsulate connection configuration. Clients use a pre-configured connection factory to create connections to the JMS provider.

JBoss includes several different connection factories with varying characteristics, as shown in Table 9.3.

Table 9.3. Connection Factories Provided in JBoss
JNDI Name Description
ConnectionFactory The default factory. A fast two-way socket-based communication protocol.
XAConnectionFactory Also a fast two-way socket based protocol that also has support for XA transactions.
RMIConnectionFactory Uses RMI to implement communication mechanism.
RMIXAConnectionFactory Uses RMI and also has support for XA transactions.
java:/ConnectionFactory Very fast in-VM protocol that does not use sockets. Available when the client is in the same virtual machine as JBossMQ.
java:/XAConnectionFactory Fast in-VM protocol that also. supports XA transactions.
UILConnectionFactory Protocol multiplexed over one socket. Used when going through firewalls or when the client is not able to look up the server IP address correctly.
UILXAConnectionFactory Same as UILConnectionFactory but also has support for XA transactions.

You should choose the connection factory appropriate for your application. The default connection factory in JBossMQ is ConnectionFactory, which is implemented over a two-way, socket-based communication protocol.

Note that other JMS providers may have different connection factories with different characteristics and different names.

Destinations

Destinations define the address parameters for queues and topics. New queue and topic destinations are added to the jboss.jcml file with the following:

<mbean code="org.jboss.mq.server.TopicManager" name="JBossMQ:service=Topic
,name=YourTopicName"/>
<mbean code="org.jboss.mq.server.QueueManager" name="JBossMQ:service=Queue
,name=YourQueueName"/>

You have now finished looking at JBoss. The following examples illustrate how to connect to queues and topics using J2EE RI.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.12.140