Samples Tutorial

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Consuming Data via Streaming API

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:

 


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:

 


13.1 Stream results into a flat file

Objectives

In this exercise, you will:

Instructions

  1. Import new index page into your application
    1. Right-click CustomerPageFlow located in CustomerManagementWebApp.
    2. Choose Import.
    3. Navigate to <beahome>\weblogic81\samples\LiquidData\EvalGuide\Streaming.
    4. Select index.jsp as the page to be imported.
    5. Click on Import button.
    6. Open index.jsp in the streaming folder and verify that you have a new link called "Export All Data".
  2. Insert streaming function into your page flow
    1. Open CustomerPageFlowController.jpf located in CustomerManagementWebApp\ CustomerPageFlow
    2. Go to Source View.
    3. Add two additional methods into the page flow.
    4. Open Streaming.txt file located in <beahome>\weblogic81\samples\LiquidData\EvalGuide\Streaming.
    5. Copy and paste both functions found in Streaming.txt file immediately after method submitChanges() in the CustomerPageFlowController.jpf java page flow.
    6. Press four times the key combination of Alt + Enter keys to import missing packages or type the following in import section of page flow:
    7. import com.bea.ld.dsmediator.client.StreamingDataService;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import com.bea.ld.dsmediator.client.DataServiceFactory;
      import weblogic.jndi.Environment;
Note: If your application name is different from "Evaluation", locate "Evaluation" in newStreamingDataService method and rename it to reflect the name of your application.
    1. Save your changes.
  1. Start your CustomerPageFlowController.jpf
  2. Once the application is started, click the Export All Data link
  3. Verify that data is exported successfully by opening customerexport.txt, located in:
  4. <BEAHOME>\weblogic81\samples\domains\ldplatform

 


13.2 Consume data in streaming fashion

Objectives

In this exercise, you will:

Instructions

  1. Import a new folder into your application
    1. Right-click CustomerManagementWebApp located in your Evaluation application.
    2. Choose Import.
    3. Navigate to <beahome>\weblogic81\samples\LiquidData\EvalGuide.
    4. Select CustomerPageFlowStream folder to be imported.
    5. Click Import.
    6. Open CustomerPageFlowController.jpf file in Source View.
    7. Locate stream method and the following comments:
    8. //instantiate and initialize your streaming data service here
    9. Add the following code:
    10. com.bea.dsp.dsmediator.client.StreamingDataService sds = null;
          //instantiate and initialize your streaming data service here
          sds =    com.bea.dsp.dsmediator.client.DataServiceFactory.newStreamingDataService(getInitialContext(), "Evaluation", "ld:DataServices/CustomerManagement/CustomerProfile"); 
    11. The DataServiceFactory class contains a method to create a streaming data service.
    12. Replace stream = null with following code:
    13. 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


      Instantiating and Initializing Streaming Data

    14. 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.
    15. Figure 13-2 Data in Streaming Format


      Data in Streaming Format

 


Lesson Summary

In this lesson, you learned to:


  Back to Top       Previous  Next