# Motivation

There are many users who need to use tag messages. The implementation of
this part has also been discussed before:

https://lists.apache.org/list.html?*@pulsar.apache.org:lte=2y:Proposal%20for%20Consumer%20Filtering%20in%20Pulsar%20brokers

I suggest to plug-in the Dispatcher, so that users can not only develop tag
messages, but also customize their own delayed messages and other features.

Plug-in Dispatcher has no compatibility impact on existing Brokers.

# Modifications

   1.

   Add a configuration item `dispatcherProviderClassName`,the creation of
   an existing Dispatcher will be moved to DefaultDispatcherProvider, as the
   default class.
   2.

   Add a new Interface DispatcherProvider


public interface DispatcherProvider {



    // Use `DispatcherProvider` to create `Dispatcher`

    Dispatcher createDispatcher(Consumer consumer, Subscription
subscription);

    static DispatcherProvider createDispatcherProvider(ServiceConfiguration
serviceConfiguration) {

   // According to `dispatcherProviderClassName`, create Provider through
reflection

    }

}

We can get BrokerService from Subscription, and then Pulsar from
BrokerService, so the parameters of this interface must be sufficient.

DispatcherProvider will be created when the subscription is initialized:

```

DispatcherProvider.createDispatcherProvider(config);

```

When there is a Consumer subscription, we will create a Dispatcher:

dispatcher = dispatcherProvider.createDispatcher(consumer, this);

I opened a new PR:

https://github.com/apache/pulsar/pull/11948

Reply via email to