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
- Set the user name and password in the example environment:
Operating System |
Step |
Windows |
- Edit the set_example_env.bat script
- Set the ADAPTER_EXAMPLE_USERNAME and ADAPTER_EXAMPLE_PASSWORD
variables to the desired user name/password combination.
- If SSL is enabled, set
ADAPTER_EXAMPLE_CLUSTER_NODE_PROTOCOL to esps. If it is
disabled, set it to esp.
|
UNIX |
- Edit the set_example_env.sh script
- Set the ADAPTER_EXAMPLE_USERNAME and ADAPTER_EXAMPLE_PASSWORD
variables to the desired user name/password combination.
- If SSL is enabled, set
ADAPTER_EXAMPLE_CLUSTER_NODE_PROTOCOL to esps. If it is
disabled, set it to esp.
|
- Start SAP Event Stream Processor.
Operating System |
Step |
Windows |
Open a command window:- Start the cluster:
start_server_cluster.bat
- Add project to the cluster, and start it on the cluster:
start_project.bat
|
UNIX |
Open a terminal window: - Start the
cluster:
./start_server_cluster.sh
- Start the project on the cluster:
./start_project.sh
|
- 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
|
- 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
|
- 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
|
- 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
|
- 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.