Index Changes

Dynamic Binding By Leveraging NM Properties

1. Overview

Binding - Static

Up to Glassfish ESB v2.x, WSDL binding extensibility element is the mechanism used by JBI components to represent concrete binding information, usually, the info is specified as a set of attribute values of the extensibility element(s) at WSDL creation.

Binding - Resolve at Deployment Time

There are systemic qualities, i.e. Application Configuration & Application Variable, that allow WSDLs have special tokens (reference to application variables) placed as the attribute values, and they are resolved at the deployment time with the application variables and/or application instances defined at the target application server.

Binding - Dynamic

There are use cases where the application logic only know where to connect at the runtime, e.g., based on some per message knowledge, for these use cases, JBI components systemic qualities - Normalized Message Properties (NM props) can be used to achieve dynamic binding.

In the following demos, FileBC and FTPBC are used to transfer files between sources and destinations which are changed dynamically on per message basis:
Note, in the followings, netbeans IDE is used for the project creation, build, and deploy.

2. Transfer File Local To Remote

2.0. Description


This sample project demonstrates a simple flow of FileBC Inbound -> BPEL SE BP -> FTPBC Outbound, where the application logic in BP probes the inbound message's NM properties, e.g. "File Name", and put the message to the destination on different FTP server depending on the characteristics of the file name, e.g., if the input file name starts with prefix "to_ftp_1", then put outbound message to a destination on FTP server "sun.ftp001.com", otherwise, put it to a destination on FTP server "sun.ftp002.com" by setting FTPBC Outbound NM properties, such as "FTP Host Name".
Figure 2.1 illustrates the flow and components interaction


Figure 2.1

2.1. Create A Blank BPEL Module Project


The following tabbed section shows steps to create a BPEL module which will host the services definitions (WSDL files) and business process (BPEL script):

Create New Project - BPEL Module

Set Project Info - Name, Location, etc.

The Blank BPEL Module Project

2.2. Create Services for Local File Read & Remote FTP Put


Create Local File Read Service:


Start Creating Service Definition (WSDL) - Right Click on "Process Node", select "New" -> WSDL Document ...

Create WSDL for Local File Read Service - Check "Concrete WSDL" and Select "File" Binding and Select "Poll" as sub binding type.

More Local File Read Service Details Set, When done, Click "Finish" to start the WSDL generation.

Create Remote FTP Put Service:


Start Creating Service Definition (WSDL) - Right Click on "Process Node", select "New" -> WSDL Document ...

Create FTP Put Service

Set FTP Put Service Connection Info - Such as host name, port, user login, password, etc.

More FTP Service Info - Messaging Repository - the base directory where messages are written to or read from, and the message name format, etc.

2.3. Compose BP




Compose the BP - Create BP Flow and Map File / FTP services to BP activities

Create a Variable to hold the value of File Binding Inbound NM property "File Name" coming out of receive activity

In Assign1 - Do Message Copy Through and create a variable ("inputFileNameVar") and populate inbound NM property "File Name" from receive activity to the variable

Adding IF Checking for the inbound NM property "File Name", and dynamically change the FTP server accordingly in Assign2 / Assign3 respectively

In Assign2: set target FTP server to "ftp.server.001"

In Assign3: set target FTP server to "ftp.server.002"

2.4. Create Composite Application Project and Add BPEL Module To It


With the BPEL Module created, it is time to create an application that can be deployed and run... The following shows a composite application with the BPEL module created previously, the flow is rendered in CASA editor:
For briefness, only the screen shot showing the final resulted composite application is shown, the creation of a composite application is similar to the creation of a SOA BPEL Module, from netbeans IDE main menu, select File -> New Project->Select "SOA" as project category->Select "Composite Application" as project type, then a blank composite application will be created which contains 0 processes and 0 modules, right click the "Modules" node under the project, select "Add Module", a file browser pops up, navigate to the location of the BPEL module created above and select it, the BPEL module will be added as part of the composite application.
Do "Clean & Build" of the composite application, when it builds correctly, select "Service Assembly" node and right click and select "Edit", the flow will be loaded into CASA editor canvas.


2.5. Deploy and Check End to End Result


After deployed correctly, the application is polling the input directory as shown below:
Feed with 8 messages - 4 of them with prefix "to_ftp_1", and 4 of them with prefix "to_ftp_2":


Using a ftp client connect to host 1 and 2 and exam the messages written to the destination:

4 messages are written to ftp host 1:


4 messages are written to ftp host 2:



3. Transfer File Remote To Local

3.0. Description


This sample project demonstrates a simple flow of FTPBC Inbound -> BPEL SE BP -> FileBC Outbound, where the application logic in BP probes the inbound message's NM properties, e.g. "Resolved File Name for FTP Get", and put the message to different output location depending on the characteristics of the remote file name, e.g., if the remote file name ends with an odd number, then write outbound message to a local file folder "C:\TEMP\ftp_to_file_nm_demo\odd_number_tagged_messages", otherwise, write it to "C:\TEMP\ftp_to_file_nm_demo\even_number_tagged_messages" by setting FileBC Outbound NM properties, such as "File Directory".
Figure 3.1 illustrates the flow and components interaction

Figure 3.1

3.1. Create BPEL Module

3.1.1. Create Blank BP + FTP Poll Service + File Write Service


Create FTPBC Binding WSDL & Configure FTP Polling service:

Create FileBC Binding WSDL & Configure File Write service:

3.1.2. Compose Flow in BP
Compose Biz Logic - Check FTP Inbound NM properties and write to local directories accordingly:

Compose IF condition:

Compose Assign1 Activity:
if inbound ftp file name is even number tagged, write the output message to directory: C:\TEMP\ftp_to_file_nm_demo\even_number_tagged_messages
keep the original ftp file name as the output file name:

Compose Assign2 Activity:
if inbound ftp file name is not even number tagged, write the output message to directory: C:\TEMP\ftp_to_file_nm_demo\odd_number_tagged_messages
keep the original ftp file name as the output file name:

3.2. Create Composite Application & Build & Deploy


3.3. Feed inputs and check outputs

Feed input files at the ftp polling directory as shown below:



Exam the outputs written into different directories respectively:


4. Scheduled File Transfer Local To Remote (Up Load)

4.0. Description


This project demonstrates a message flow as follows:

SchedulerBC (trigger every minute) -> BPELSE BP -> FileBC OnDemand Read (from date specific directories accordingly) -> FTPBC Put (to date specific directories accordingly)

Where:

the BP logicchecks the message from scheduler - a timestamp in the format of yyyy/mm/dd/hh/MM/ss, and invokes FileBC on demand read against a target directory indicated by the date information in the timestamp, as shown below:


this is achieved by extracting date info from the incoming message, and use the date info, i.e. /yyyy_mm_dd as the value of FileBC outbound NM property - "File Directory", then invoke the on demand read, the fetched message payload will be put to remote FTP target directory /yyyy_mm_dd.

The following diagram shows the message flow:



4.1. Create BPEL Module

The BPEL Module includes the following artifacts:

  • BPEL process: NM_PROP_BASED_SCHEDULER_FILE2FTP_TRANS.bpel
  • WSDL for File on demand read service: FILE_ONDEMAND_READ.wsdl
  • WSDL for FTP put service: FTP_PUT.wsdl
  • WSDL for SCHEDULER service: SCHEDULER.wsdl

As shown below:


Note, the WSDLs shown in the BPEL module are created by respective binding wizards.
Next, each services binding details will be examed.

4.2. Create and Configure Services

Using binding wizard for each binding type, the following shows the service binding details:

4.2.1. File OnDemand Read Service Setting


The directory where the on demand file read will be looking for a matching file
and read its content as message payload, note the static value c:\temp is set as a place holder,
the actual directory will be set via the NM property "File Directory" in BP, and the directory
name will be generated according to the current date.

the file name that will be read by the On Demand Read operation, in this case, it is a literal
i.e. read.xml, but a name pattern or regular expression can also be set as the "File Name".

4.2.2. FTP Put Service Setting


Parameters used for FTP connection etc.

Target Directory and File information for FTP PUT, and details for Pre/Post FTP file transfer operations as well.

4.2.3. Scheduler Service Setting





4.3. Create Composite Application and Add BP To It


4.4. Deploy and Feed Inputs and Check Outputs

Prepare date info specific sub directories as shown below:
Feed input file read.xml to the file on demand read target directory: c:\TEMP\SUBMITTED_DATA_BY_DATE\2009_10_28 (the date the demo is prepare: Oct 28, 2009)


Within around 60 seconds (the interval set for the scheduler service), the file read.xml will be picked up, then check the output on the FTP side:


the output can be found on the FTP target: /


5. Scheduled File Transfer - Remote To Local (Down Load)

5.0. Description


The project demonstrates a message flow as follows:

SchedulerBC (trigger every minute) -> BPELSE BP -> FTPBC OnDemand GET (from date specific directories accordingly) -> FileBC Write (to date specific directories accordingly)

where:

the logic in BP checks the message from scheduler - a timestamp in the format of yyyy/mm/dd/hh/MM/ss, and invokes FTPBC on demand GET against a target directory indicated by the date information in the timestamp, as shown below:


this is achieved by extracting date info from the incoming message, and use the date info, i.e. /yyyy_mm_dd as the value of FileBC outbound NM property - "FTP Directory for GET", then invoke the on demand GET service, the fetched message payload will be written to local target directory /yyyy_mm_dd.

The following diagram shows the message flow:



5.1. Create BPEL Module

The BPEL Module includes the following artifacts:

  • BPEL process: NM_PROP_BASED_SCHEDULER_FTP2FILE_TRANS.bpel
  • WSDL for FTP on demand get service: FTP_ONDEMAND_GET.wsdl
  • WSDL for File write service: FILE_WRITE.wsdl
  • WSDL for SCHEDULER service: SCHEDULER.wsdl

As shown below:



the BPEL sequence in the BP do the following:

  • STEP1: sequence triggered by scheduler message per 60 seconds
  • STEP2: extract date info from current date and format it into yyyy_mm_dd and generate ftp target NM_PROP_BASED_SCHEDULED_FTP2FILE_TRANS//input0-9+\.txt,
set the ftp path to FTPBC NM property "Transfer Source" (ftp:transfer->receiveFrom) for the FTP OnDemand Get operation's input variable
Note, in the FTP_ONDEMAND_GET.wsdl, ftp:transfer->sendToHasPattern is set to true, and POST send operation has been set: RENAME the file that has been received to
an archive area, e.g. NM_PROP_BASED_SCHEDULED_FTP2FILE_TRANS/ARCHIVED.

  • STEP3: Invoke FTP On Demand Get
  • STEP4: extract date info from current date and format it into yyyy_mm_dd and generate file directory C:/TEMP/DATA_FROM_FTP_BY_DATE/
set the value to FileBC outbound NM property "File Directory" (file:address->fileDirectory) for the File Write operation's input variable

  • STEP5: Invoke File Write

5.2. Create and Configure Services

5.2.1. FTP On Demand Get Service Setting

Parameters used for FTP connection etc.

Target Directory and File information for FTP On Demand Get, and details for Pre/Post FTP file transfer operations as well.

5.2.2. File Write Service Setting


Set the directory where the file write operation will write the output files, note, it is only a place holder, since it will be overwritten
by NM property "File Directory" set dynamically in the BP.

Specify file name which will be used to generate output files, e.g. the output file can be:
UUID tagged, or sequence number tagged, or timestamp tagged etc.

5.2.3. Scheduler Service Setting

similar to that of the "Up Load" demo, omitted for brevity.

5.3. Create Composite Application and Add BP To It




5.4. Deploy and Feed Inputs and Check Outputs


Feed inputs at FTP side into a target directory yyyy_mm_dd which matches the current date, e.g. 2009_10_28:


Wait for around 3X60 seconds, all the input files picked up by FTP On Demand Get service:

Then Check the output files at the local file system side:

As expected, there is three output files in the 2009_10_28 directory.

JSPWiki v2.4.100
[RSS]
« Home Index Changes Prefs
This page (revision-60) was last changed on 18-Jun-10 14:51 PM, -0700 by jimfu