Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 1.57 KB

key-blocking.adoc

File metadata and controls

38 lines (31 loc) · 1.57 KB

Key Blocking

Introduction

Decaton supports defining a list of keys that you want to skip when processing task. The list can be dynamic. It means that you can add or remove keys from the list on the fly.

When to use

When you want to skip tasks based on their keys, you can consider using this feature.

Example

Suppose you want to create blacklists to protect your service. For example, your service needs to analyze request logs.

You found requests from a particular IP address always sent with strange payload.

If you are using IP address as a message key then you can apply this feature to blacklist that address. The request from this IP address will be ignored.

Usage

You can use CONFIG_IGNORE_KEYS to set list of key that you want to ignore. Just like other properties, you can set it through SubscriptionBuilder#properties, as shown in the following example:

IgnoreKeysMain.java
...
SubscriptionBuilder.newBuilder("ignore-key-processor")
                   .properties(
                           StaticPropertySupplier.of( // (1)
                                   Property.ofStatic(
                                           CONFIG_IGNORE_KEYS,
                                           Arrays.asList("key1", "key2")
                                   )))
...
  1. In this example we use StaticPropertySupplier to set static list. As mentioned at the very beginning, the list can be dynamic. Please refer to Dynamic property configuration for more information.