Welcome
Home
FAQ
Who We Are
User Guides
Introduction
Download
Installation
Release Notes
Javadoc
Resources
Development
Project on SourceForge
To Do List
Mailing Lists
Component Guides
Base
Base Services
Business Data
Client Controller
Data Access
Data Domain
EJB
Java Class Generator
Messaging
Data Parser
Persistence
Property Tree
XML Wrapper
UI Framework
Messaging Component

The messaging component, of Arch4J,is a abstraction layer above JMS Messaging so that some of the more mundane Messaging code is all located in one place. The developer no longer needs to get the connection, manage the JNDI context, and close the objects. All that the developer needs to do is setup a properties file defining the QueueConnectionFactory JNDI name, use the ARCH4J Messaging API to get the various JMS Objects of interest.

Get Started

If you are installing as part of the full Arch4J distribution, you need to put the arch4j.jar file into your classpath.
If you are only interested in the messaging component, you need the base.jar, baseservices.jar, and arch4j_messaging.jar in your classpath.
You will also need to configure your JMS provider so it is accessible via JNDI..

Overview

The messaging model is designed around just being a thin veneer over the standard JMS api, which manages all the boring stuff. You will need to obtain a MessagingProvider, then a MessageQueueFacade, from this you can then create a QueueSender to send your messages and also create TextMessages etc... after sending your messages to finish up all you need to do is close the sender and the facade.

The reason for doing things this way is to move allot of the connection and queue management into a single class that can manage it all for you.

How To

In order to use the Messaging component, you will need to do four things:

  1. Configure the messaging properties in the messaging.properties file.

  2. Depending on the messaging factory you configured, there may well be a related properties file you need to configure, for example if you use webshpere you'll also need to configure messaging-websphere.properties.

  3. Configure the base services properties in baseservices.properties.

  4. Depending on the base services factory you configured, there may well be a related properties file you need to configure, for example if you use webshpere or weblogic you'll also need to configure system.properties.

  5. Get a reference to a MessageQueueFacade using the MessagingProvider class.

  6. Sending Messages.

  7. Finshing up.

Property File Configuration

The property file name is messaging.properties. This is where you define the class names of the Factory implementations of MessageQueueFacade and MessageTopicFacade.

Property Name Property Value Required
messagequeuefacade.class <class name of the implementation of the Message Queue Facade> Yes
messagetopicfacade.class <class name of the implementation of the Message Topic Facade> Yes

Examples

Here is a sample property file for WebLogic messaging:

messagequeuefacade.class=org.arch4j.messaging.weblogic.WebLogicMessageQueueFacade
messagetopicfacade.class=org.arch4j.messaging.weblogic.WebLogicMessageTopicFacade

Here is a sample property file for Websphere messaging:

messagequeuefacade.class=org.arch4j.messaging.websphere.WebsphereMessageQueueFacade
messagetopicfacade.class=org.arch4j.messaging.websphere.WebsphereMessageTopicFacade
                                    
Property File Configuration

The property file name is messaging-websphere.properties. This is where you define the JNDI names of the QueueConnectionFactory and TopicConnectionFactory.

Property Name Property Value Required
queueConnectionFactoryLookup <JNDI name of the Queue Connection Factory> Yes
topicConnectionFactoryLookup <;JNDI name of the Topic Connection Factory> Yes

Examples

Here is a sample property file:

queueConnectionFactoryLookup=jms/QCF2
topicConnectionFactoryLookup=jms/TCF
                                
Property File Configuration

The property file name is baseservices.properties. This is where you define the class name of the Factory implementations of BaseServices.

Property Name Property Value Required
baseservices.class <class name of the implementation of the BaseServices> Yes

Examples

Here is a sample property file:

baseservices.class=org.arch4j.baseservices.websphere.WebsphereBaseServices
                                
Property File Configuration

The property file name is system.properties. This is where you define the url of the JNDI service, plus additional data.

Property Name Property Value Required
url <url of the JNDI service> Yes
initialContextFactory <class name of the Context Factory> No, only for Websphere

Examples

Here is a sample property file for Weblogic:

url=t3://localhost:7001
                                    

Here is a sample property file for Websphere:

url=iiop://spidertest
initialContextFactory=com.ibm.websphere.naming.WsnInitialContextFactory
                                    
Acessing the MessageQueueFacade

To get a reference to the MessageQueueFacade, you need to use the MessagingProvider class. This class uses the singleton pattern. To get the instance of the provider, use the getProvider() method.

You can then get get an instance of the MessageQueueFacade using getMessageQueueFacade( boolean isTransactional )

Examples

Getting an instance:
MessageQueueFacade qFacade = MessagingProvider.getProvider().getMessageQueueFacade(false);
 
Sending Messages

The process of sending a message is pretty simple. You just create a Sender, start it up, send your various messages and then close it.

Examples

Create a QueueSender and send a text message.
QueueSender sender = qFacade.createQueueSender("exampleQueue"); 

qFacade.startConnection(); 

TextMessage message = qFacade.createTextMessage(new StringBuffer("Hello Whirled")); 

sender.send(message); 

sender.close(); 
					
Finishing up

Once you've sent and reveiced your various messages, you just need to close the facade, which will do some cleanup behind the scenes.

Examples

Closing the facade:
qFacade.close();

Arch4J is hosted by

SourceForge Logo

Copyright © 2001-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.