Tuesday, October 12, 2010

A TIBCO BusinessWorks-based file gateway – Part 3

Publishing an event to TIBCO EMS topic from BusinessWorks.


We will look at the mechanism to publish the file processing completion events from the FileGateway. The following use case describes the flow.

Trigger: FileGateway finished writing the XML file to the outbound folder.

Flow:
1. FileGateway publishes event to FGW.FILEREADY topic.
2. End of use case.

What we need

A target topic
We have configured the TIBCO EMS to address part of this requirement. Refer to this article for details of setting up the topic, user and access control list.

An xml schema for event message
This schema is used by both the producer and the consumer of the event message. The TIBCO BusinessWorks JMS Publish activity will publish the message according to this schema and the consumer will reference this schema when parsing the message.

As usual, create the schema using your favorite xml tool. Here is the completed schema.

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

  
    
      
        
        
        
        
          
            
              
                
                  
                  
                
              
            
            
          
        
      
    
  


Import the xml schema into the TIBCO Designer project.

If you haven't been following the series of articles on FileGateway, you can learn about the FileGateway in the following posts.


You may also simply download and examine the baselined TIBCO Designer project from here.

A JMS Publish activity in the BusinessWorks process
Here are the steps to add a publish JMS activity into the process
1. Create a JMS Connection shared configuration.
Under the PollEmpsCSV folder, create a JMS Connection. Uncheck the "Use JNDI for Connection Factory" as our consumers will be connecting directly without getting the resource handle from the JNDI. Enter the username and password of the fgwuser.


Start the TIBCO EMS server and click on the "Test Connection" button to ensure correct configuration.


2. Add a JMS Topic Publisher activity.
In the PollDumpCompletion process, add a JMS Topic Publisher and name it as "PublishEvent". In the configuration tab, enter "FGW.FILEREADY" in the Destination Topic field. In the "Message Type" dropdown, select "XML Text".

Create a transition from WriteXMLFile to PublishEvent, and from PublishEvent to End activities.

With PublishEvent activity selected, go to the "Input Editor" tab. Click on the "+" icon and select "XML Element Reference" from the "Content" dropdown. Browse to the schema fileInfo.xsd and select the element "fileInfo"


Go to the "Input" tab, map the fileName, fileSize and fileDateTime elements of the activity input to the corresponding fields of $WriteXMLFile process data.

Duplicate the "property" element of the fileInfo instance to contain additional informations, such as the username and password of the ftp server where the output file is located, the url of the ftp server and so forth. The value of the "transport" element indicates how the output file is hosted. Possible values are ftp, http, https or even a "RESTful file server"?!. Well, the password is in plain-text, not an ideal implementation, but that is a separate exercise!

Here we are, done. A FileGateway that broadcasts the file conversion event to interested parties. The output JMS body of the event is as follow.

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

    EMP-OUT00A-20101012-13-13-35.XML
    1646
    2010-10-12T13:13:36.234+11:00
    
        
        
        
        
    


Download the update FileGateway here.

In the next article, we will be looking at testing/consuming the publish feature from Oracle SOA Suite.

Cheers.

No comments:

Post a Comment