Introduction
This document provides the text for the procedures covered in the video “Creating and Debugging Flow Services” that is available on:
Problem Statement
Create an integration service to fetch the list of employees with salary greater than 10,000 from the database.
Steps Involved
- Create an Adapter Service to fetch the list of employees from the database.
- Create a Flow Service and write the logic using flow steps.
- Debug the logic to analyze and fix issues, if any.
Creating an Adapter Service
- Create a new package:
- Click File > New > Package.
- Type the package name as HR.
- Create a new folder in the package:
- Click File > New > Folder.
- Type the folder name as dept.
- Create a new folder in the folder:
- Click File > New > Folder.
- Type the folder name as finance.
- Create a new adapter service in the folder:
- Click File > New > Adapter Service.
- Type the name of the flow service as selectAllEmp and click Next.
- Select an Adapter type and click Next.
- Select an Adapter Connection Alias and click Next.
- Select a template and click Finish.
- Select the table name.
- From the Table Name column, click
.
- From the Adapter Tree Chooser screen, select HR > Jobs.
- Click OK.
- From the Table Name column, click
- Populate the table content:
- Click the SELECT tab.
- Click
to populate the table rows.
The Jobs table is displayed.
Creating a Flow Service
- Create a new folder in the package:
- Click File > New > Folder.
- Type the folder name as services.
- Create a new flow service in the folder:
- Right-click the folder and click New > Flow Service.
- Type the name for the flow service as fetchEmpWithMinSal.
- Click Finish.
- Add an invoke step to the flow service:
- Drag and drop the Invoke step from Palette > Insert.
- Type or select the selectAllEmp adapter service that you created.
Note: When you add a flow step, provide relevant comment describing the requirement of the flow step in Property > Comment field. This is a best practice.
- Add a LOOP flow step to the flow service:
- Drag and drop the LOOP step from Palette > Flow Steps.
- Select the selectAllEmp service and go to the Pipeline view.
- In Service Out, right-click results and select Copy.
- On the flow editor, select LOOP step and go to the Property view.
- In the Input array field, click
.
- In Input array text editor, paste the copied content.
- Add a BRANCH flow step under the LOOP step:
- Drag and drop the BRANCH step from Palette > Flow Steps.
- Go to the Property view.
- From the Evaluate label drop down, select True.
- Add a SEQUENCE flow step under the BRANCH step:
- Drag and drop the SEQUENCE step from Palette > Flow Steps.
- Select the selectAllEmp service and go to the Pipeline view.
- Right-click MIN_SALARY in Service Out and select Copy.
- On the flow editor, select SEQUENCE step and go to the Property view.
- In the Label field, paste the copied content.
- Edit the copied content to include the condition as follows: results/MIN_SALARY.
- Add a MAP flow step under the SEQUENCE step:
- Drag and drop the MAP step from Palette > Flow Steps.
- In the Pipeline view, right-click Add Transformer > pub.list > appendToDocumentList.
- Expand the Transformers.
- From the Pipeline In and transformer Service In, select the selectAllEmpOutput and fromItem respectively.
- Click
to create a link.
- Add a MAP flow step to the flow service to create a temporary variable:
- Drag and drop the MAP step from Palette > Flow Steps.
- Go to Pipeline view.
- In the Pipeline Out section, right click Insert > Document List.
- Type a name for the document list variable such as, tempList.
- Right click the document list variable and click Set Value.
- In the Enter Input screen, click OK.
- Link the input and output variable:
- Select the MAP flow step under the SEQUENCE step.
- From the Pipeline Out and Transformer Service Out, select tempList and toList respectively.
- Click
to create a link.
- From the d and transformer Service In, select tempList and toList respectively.
- Click
to create a link.
- Add a MAP flow step to the flow service to store the final output:
- Drag and drop the MAP step from Palette > Flow Steps.
- Select the Input/Output tab.
- Drag and drop the Document List from Palette > Variables.
- Type a name for the document list variable such as, empList.
- From the Pipeline In and Pipeline Out, select tempList and empList respectively.
- Click
to create a link.
- From the Pipleline Out, select SelectAllEmpOutput and tempList.
- Right click and select Drop.
- Run the flow service:
- Select the fetchAllEmpWithMinSal flow service.
- Click Run As > Run Flow Service.
The result is displayed in Results tab. In this case, no result is displayed.
Debugging Flow Service
- In the Package Navigator, select the fetchAllEmpWithMinSal flow service.
- Right-click and select Debug As > Debug Flow Service.
Debug view opens. The first step of flow service (INVOKE step) is highlighted.
- Click the Step Over icon
, each time to execute the next steps.
All the steps till the SEQUENCE step get executed.
- Click the
to terminate debug session.
- Select the SEQUENCE step. Right-click and select Show Properties View.
- Correct the condition provided in the Label field as follows: %selectAllEmpOutput/results/MIN_SALARY%>10000
The syntax to retrieve values from the pipeline variable is now corrected.
- Click Run > Debug to resume debugging.
- Click
each time to execute the flow steps till the MAP step.
- When the MAP step is executing, click
.
- Check the Variables view to view the list of the tempList variables carrying the required result.
- When the tempList variables no more display the new results, right click the MAP step to store the output.
- Click Toggle Breakpoint.
- Click
to resume the debug session.
- Click
each time to execute the flow steps till all the steps are executed.
- Click
to go to the Service Development perspective.
The list of employees with min salary greater than 10000 is displayed in the Results view.