XML Messaging Using JBoss

XML Messaging Using JBoss

Using Castor in JBoss

Castor is one of the data-binding frameworks for Java. At the time of this writing, there is no JMX implementation for Castor (yet).



In order to use it, we just follow the instructions from the Castor home page:

  • Create the mapping file.
  • Generate or create the Java bean.
  • Load the mapping file.
  • Create a reader to the file to unmarshal from the XML message.
  • Create a new unmarshaller.
  • Unmarshal the object.

Note: Although JBoss 4.0.0 provides a Castor .jar file (castor-0.9.5-xml.jar), you need the complete .jar (castor-0.9.5.3.jar). This is needed to handle a date field.

Design Pattern for the Producer

The figure below depicts the design pattern for the producer:

Figure2
Figure 2. Design pattern for the producer

Based on the following cron expression for Oracle:

<attribute name="OracleCron">

  <![CDATA[0 * 08-18 * * ?]]>

</attribute>

QuartzService schedules HibernateService to retrieve data from IProducerContact using the HSQL SELECT statement:

<attribute name="OracleQuery">

  <![CDATA[FROM IContact as contact 

   WHERE contact.sendStatus <> 'S']]>

</attribute>

Note: IContact here is the name of the persistence class, and not the name of the interface table.

HibernateService, armed with the mapping files, unmarshalls the data retrieved to construct the Java objects. These objects are passed on to the Databinder.toGenericXML() or Databinder.toXML() methods to generate XML output.

The XML output is then transformed by XSLT. This new XML format is sent to the JMS provider, such as JBossMQ or WebSphere MQ.

To help you understand the provided code, Figure 3 shows the class diagram:

Figure3
Figure 3. XMLProducer's class diagram

Figure 4 is the sequence diagram:

Figure4
Figure 4. XMLProducer's sequence diagram

Design Pattern for the Consumer

Figure 5 depicts the design pattern for the consumer:

Figure 5
Figure 5. Design Pattern for the consumer

The consumer has two components, XMLConsumer.jar and XMLConsumerService.sar. The first one is the MDB component, and the second one is the business process. There are two types of incoming messages: Contact messages and Ccy messages. These will be consumed by ContactMDB or CcyMDB, respectively. There's one MDB for one type of message. This allows a concurrency process. Each MDB will then delegate the process to an MBean, called XMLConsumerService.

When an XML message is consumed, Castor marshals that message to a Java object. Then Hibernate will take over this Java object to store the data into the interface tables IConsumerContact and IConsumerCcy.

Once the data in those interface tables, it's up to AppTarget to put the data into the master database.

To help you understand the provided code, Figure 6 shows a class diagram:

Figure6
Figure 6. XMLConsumer's class diagram

and Figure 7 shows a sequence diagram:

Figure7
Figure 7. XMLConsumer's sequence diagram

Prev  [1] [2] [3] [4] Next

Close    To Top
  • Prev Article-Java:
  • Next Article-Java:
  • Now: Tutorial for Web and Software Design > Java > Java EE > Java Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction