Streaming API allows developers to retrieve Aqualogic Data Services Platform (ALDSP) results in a streaming fashion.
Objectives
After completing this lesson, you will be able to:
Stream results returned from AquaLogic Data Services Platform into a flat file.
Test the results.
Overview
There are situations where you need to extract large amounts of data from operational systems using ALDSP. For those cases, ALDSP provides a data streaming API. Large data sets can be retrieved to application in a streaming fashion or be streamed directly to a file on server. All security enforcements previously defined will still be relevant in case of the streaming API.
When working with streaming API keep the following things in mind:
The ability to get results as streams will be only available on the Server; there will not be any client-server support for this API.
Only the Generic Data Service Interface is available for getting streaming results.
13.1 Stream results into a flat file
Objectives
In this exercise, you will:
Create a new function that streams CustomerProfile information into a flat file.
Import a new jsp file to access a streaming function.
Test streaming data into a file.
Instructions
Import new index page into your application
Right-click CustomerPageFlow located in CustomerManagementWebApp.
Choose Import.
Navigate to <beahome>\weblogic81\samples\LiquidData\EvalGuide\Streaming.
Select index.jsp as the page to be imported.
Click on Import button.
Open index.jsp in the streaming folder and verify that you have a new link called "Export All Data".
Insert streaming function into your page flow
Open CustomerPageFlowController.jpf located in CustomerManagementWebApp\ CustomerPageFlow
Go to Source View.
Add two additional methods into the page flow.
Open Streaming.txt file located in <beahome>\weblogic81\samples\LiquidData\EvalGuide\Streaming.
Copy and paste both functions found in Streaming.txt file immediately after method submitChanges() in the CustomerPageFlowController.jpf java page flow.
Press four times the key combination of Alt + Enter keys to import missing packages or type the following in import section of page flow:
If your application name is different from "Evaluation", locate "Evaluation" in newStreamingDataService method and rename it to reflect the name of your application.
Save your changes.
Start your CustomerPageFlowController.jpf
Once the application is started, click the Export All Data link
Verify that data is exported successfully by opening customerexport.txt, located in:
<BEAHOME>\weblogic81\samples\domains\ldplatform
13.2 Consume data in streaming fashion
Objectives
In this exercise, you will:
Import a new version of CustomerPageFlow.
Instantiate a new Streaming Data Service.
Retrieve results into XMLInputStream object by calling getCustomerProfile function.
Test fetching data from ALDSP in a streaming fashion.
Instructions
Import a new folder into your application
Right-click CustomerManagementWebApp located in your Evaluation application.
Choose Import.
Navigate to <beahome>\weblogic81\samples\LiquidData\EvalGuide.
Select CustomerPageFlowStream folder to be imported.
Click Import.
Open CustomerPageFlowController.jpf file in Source View.
Locate stream method and the following comments:
//instantiate and initialize your streaming data service here
The DataServiceFactory class contains a method to create a streaming data service.
Replace stream = null with following code:
stream = sds.invoke("getCustomerProfile", new String[]{"CUSTOMER3"});
For reference, your code should look similar to that shown below:
Figure 13-1 Instantiating and Initializing Streaming Data
Test running your CustomerPageFlowController.jpf. You can use CUSTOMER3 as a parameter to retrieve results. This time, data is fetched in streaming fashion as shown in Figure 13-2.
Figure 13-2 Data in Streaming Format
Lesson Summary
In this lesson, you learned to:
Stream results returned from AquaLogic Data Services Platform into a flat file.