How can I delete messages from a SOW topic?
There are several ways to do this, depending on your needs.
-
Timed expiration. If your application can predict that a specific record, or set of records, is only valid for a certain period of time, you can use SOW expiration to automatically remove messages that are no longer valid.
-
Application message cleanup. If an event in your application, such as completing an order, indicates that the record is no longer valid, you can use the
sow_delete_by_data
method to delete the message from AMPS. -
Action configuration. You can create an action that deletes messages from the SOW. The action can be configured to run on a periodic schedule, or in response to a signal or event.
-
Administrative cleanup. You can also use the spark command line client application to delete messages from the sow, as shown below. This runs a
sow_delete
command from the spark client.Delete all messages from a SOW topic
$ ./spark sow_delete -proto amps -type <the-type> \
-server localhost:9003\
-topic Trades -filter '1=1' \`\`\`Delete all messages that match a filter from a SOW topic
$ ./spark sow_delete -proto amps -type <the-type> \
-server localhost:9003\
-topic Trades -filter "/55 = 'Transport.123'"Notice that if you do not provide a filter, spark will perform a SOW delete by data, and wait for messages (one per line) to use as the data for the delete.