Show TOC

Example: Using the SpPersistentSubscribeSource ComponentLocate this document in the navigation structure

The SpPersistentSubscribeSource component subscribes to the Server using persistent subscribe (stores subscribed records until it processes them, and then deletes them).

Prerequisites

The cluster database stores configuration information. Ensure that the cluster is running, so that the adapter can interact with the projects on the cluster.

Context

To implement this, a log stream (Stream1_log) and truncate stream (TruncateStream1) are created for stream "Stream1". Stream1_log stores the data and TruncateStream1 has two columns: primary key and sequence number. See the model.ccl in the bin folder for more details.

Incoming records are transferred to Stream1_log with an additional sequenceNumber column. Once records are processed from Stream1_log, the last sequence number is published to TruncateStream1. All records with sequence numbers smaller than or equal to the published sequence number are then deleted from the Stream1_log.

Procedure

  1. Set the user name and password in the example environment:
    Operating System Step
    Windows
    1. Edit the set_example_env.bat script
    2. Set the ADAPTER_EXAMPLE_USERNAME and ADAPTER_EXAMPLE_PASSWORD variables to the desired user name/password combination.
    3. If SSL is enabled, set ADAPTER_EXAMPLE_CLUSTER_NODE_PROTOCOL to esps. If it is disabled, set it to esp.
    UNIX
    1. Edit the set_example_env.sh script
    2. Set the ADAPTER_EXAMPLE_USERNAME and ADAPTER_EXAMPLE_PASSWORD variables to the desired user name/password combination.
    3. If SSL is enabled, set ADAPTER_EXAMPLE_CLUSTER_NODE_PROTOCOL to esps. If it is disabled, set it to esp.
  2. Start SAP Event Stream Processor.
    Operating System Step
    Windows Open a command window:
    1. Start the cluster:

      start_server_cluster.bat

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

      start_project.bat

    UNIX Open a terminal window:
    1. Start the cluster:

      ./start_server_cluster.sh

    2. Start the project on the cluster:

      ./start_project.sh

  3. Start streamingsubscribe to subscribe to Stream1 of the project running on the cluster above.
    Operating System Step
    UNIX Open a terminal window and enter:

    ./streamingsubscribe-Stream1.sh

    Windows Open a command window and enter:

    streamingsubscribe-Stream1.bat

  4. Subscribe to the log stream, Stream1_Log.
    Operating System Step
    UNIX Open a terminal window and enter:

    ./streamingsubscribe-Stream1_log.sh

    Windows Open a command window and enter:

    streamingsubscribe-Stream1_log.bat

  5. Subscribe to the log stream, Truncate_stream1.
    Operating System Step
    UNIX Open a terminal window and enter:

    ./streamingsubscribe-TruncateStream1.sh

    Windows Open a command window and enter:

    streamingsubscribe-TruncateStream1.bat

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

    ./asapToFile.sh

    Windows Open a command window and enter:

    asapToFile.bat

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

    ./streamingupload.sh

    Windows Open a command window and enter:

    streamingupload.bat

    SpPersistentSubscribeSource subscribes to the Server and Stream1_log, and passes these records to FileSink, which writes these records to the out.txt file. All the subscription script files show the respective subscriptions.