Example: Using the JDBCLookupPipe Component

AsapSource reads data from Event Stream Processor and passes it to the JDBC lookup pipe. If required, the JDBC lookup pipe modifies the values of the 'charfield' column by using 'replaceValue1', and passes that data to FileSource, which then outputs that data to the file out.txt file.

  1. Create a table and then create data into the table. For example, for a DB2 database, run the createTable_DB2.sql script.
    Modify this script to use it for any other databases.
  2. Update the DB properties in the JdbcLookupPipe.props file to point to the required database instance.
  3. Update the JdbcLookupPipe.bat or JdbcLookupPipe.sh script, and add JDBC driver JARs in the class path.
  4. Start Event Stream Processor.
    Operating System Step
    UNIX Open a terminal window:
    1. Start the example cluster:

      start_server_cluster.sh

    2. Start the project on the cluster:

      start_project.sh

    Windows Open a command window:
    1. Start the example cluster:

      start_server_cluster.bat

    2. Add project to the cluster, and start it on the cluster:

      start_project.bat

  5. Start esp_subscriber to subscribe to the project that is running on the cluster.
    Operating System Step
    UNIX Open a terminal window and enter:

    ./esp-subscribe.sh

    Windows Open a command window and enter:

    esp-subscribe.bat

  6. Start the AsapSource, FileSink, and JDBCLookupPipe components.
    Operating System Step
    UNIX Open a terminal window and enter:

    ./JdbcLookupPipe.sh

    Windows Open a command window and enter:

    JdbcLookupPipe.bat

  7. Upload data to the Server.
    Operating System Step
    UNIX Open a terminal window and enter:

    ./esp_upload.sh

    Windows Open a command window and enter:

    esp_upload.bat

    AsapSource reads this data (records) and passes it on to JDBCLookupPipe, which modifies the records according to data available and reference data from the database tables. JDBCLookupPipe then passes that data to FileSink, which then writes the records to file.
    • Table "test1" contains data "col1='AttributeKey'" and "col2='replaceValue1'". 'KeyDbCol1' is col1 in the props file, therefore, col1 column contains attribute keys.
    • These attribute keys are present in the incoming record column 'textfield'.
    • To replace the 'charfield' column value of a record to 'replaceValue1', include 'AttributeKey' as a value in 'textfield' column of a record
    See the esp_insert.txt file for more details. Records that do not have 'AttributeKey' as the 'textfield' column value are not modified.
  8. See contents of the out.txt file.
    Charfield data for some of the records is updated to 'replaceValue1' value.
Related reference
JDBCLookupPipe Properties