Skip to content

Latest commit

 

History

History
86 lines (63 loc) · 2.98 KB

File metadata and controls

86 lines (63 loc) · 2.98 KB
description
This page provides the technical details of the Message Filtering policy

Message Filtering

{% hint style="warning" %} This feature requires Gravitee's Enterprise Edition. {% endhint %}

Overview

The message-filtering policy enables the API publisher to create and enforce a filter that controls which messages are streamed to the subscriber/consumer, given a defined set of criteria.

Functional and implementation information for the message-filtering policy is organized into the following sections:

Examples

{% hint style="warning" %} This policy can be applied to v4 message APIs. It cannot be applied to v2 APIs or v4 proxy APIs. {% endhint %}

{% tabs %} {% tab title="Message API example" %} If this is my message:

{
    "productId": "1234",
    "value": "any value"
}

I will be able to filter any messages according to subscriptions metadata productId by configuring the policy as follows:

 {
    "name": "Products filter",
    "description": "Filter messages based on subscription product id",
    "enabled": true,
    "policy": "message-filtering",
    "configuration": {
        "filter": "#jsonPath(#message.content, '$.productId') == '#subscription.metadata.productId'"
    }
}

{% endtab %} {% endtabs %}

Configuration

Sample policy configuration:

{% code title="Sample Configuration" %}

{
  "name": "Message filtering",
  "description": "Apply filter to messages",
  "enabled": true,
  "policy": "message-filtering",
  "configuration": {
    "filter": "{#jsonPath(#message.content, '$.feature') == #subscription.metadata.feature}"
  }
}

{% endcode %}

Phases

The phases checked below are supported by the message-filtering policy:

v2 PhasesCompatible?v4 PhasesCompatible?
onRequestfalseonRequestfalse
onResponsefalseonResponsefalse
onRequestContentfalseonMessageRequesttrue
onResponseContentfalseonMessageResponsetrue

Options

You can configure the message-filtering policy with the following options:

PropertyRequiredDescriptionTypeDefault
filtertrueThe filter's rulestring-

Changelogs

{% @github-files/github-code-block url="https://github.com/gravitee-io/gravitee-policy-message-filtering/blob/master/CHANGELOG.md" %}