Pulsar plugin development

    This chapter describes what the entry filter is and shows how to use the entry filter.

    The entry filter is an extension point for implementing a custom message entry strategy. With an entry filter, you can decide whether to send messages to consumers (brokers can use the return values of entry filters to determine whether the messages need to be sent or discarded) or send messages to specific consumers.

    To implement features such as tagged messages or custom delayed messages, use subscriptionProperties, , and entry filters.

    How to use an entry filter?

    Follow the steps below:

    1. Create a Maven project.

    2. Implement the EntryFilter interface.

    Step 1: Create a Maven project

    For how to create a Maven project, see here.

    Step 2: Implement the EntryFilter interface

    1. Add a dependency for Pulsar broker in the pom.xml file to display. Otherwise, you can not find the EntryFilter interface.

    1. Implement the .

      • If the method returns ACCEPT or NULL, this message is sent to consumers.

      • If the method returns REJECT, this message is filtered out and it does not consume message permits.

      You can get entry metadata, subscriptions, and other information through .

    2. Describe a NAR file.

      Create an entry_filter.yml file in the resources/META-INF/services directory to describe a NAR file.

      1. # Entry filter name, which should be configured in the broker.conf file later
      2. name: entryFilter
      3. # Entry filter description
      4. # Implementation class name of entry filter

    Step 3: package implementation class of entry filter into a NAR file

    1. Add the compiled plugin of the NAR file to your pom.xml file.

    1. Generate a NAR file in the target directory.

      1. mvn clean install

    Step 4: configure and restart broker

    1. Configure the following parameters in the broker.conf file (or the standalone.conf file).

    1. You can see the following broker log if the plug-in is successfully loaded.

      1. Successfully loaded entry filter for name `{name of your entry filter}`