13.2. 将 Broker 配置为使用拦截器
创建拦截器后,您必须将代理配置为使用它。
先决条件
您必须创建一个拦截器类,并将其添加到代理的 Java 类路径中,然后才能将它配置为使用代理。您可以使用 BROKER_INSTANCE_DIR/lib 目录,因为它是类路径的一部分。
步骤
将代理配置为在
BROKER_INSTANCE_DIR/etc/broker.xml中添加配置来使用拦截器如果您的拦截器用于传入消息,将其
类名称添加到删除拦截器列表中。<configuration> <core> ... <remoting-incoming-interceptors> <class-name>org.example.MyIncomingInterceptor</class-name> </remoting-incoming-interceptors> ... </core> </configuration>如果您的拦截器用于传出消息,将其
类名称添加到删除拦截器列表中。<configuration> <core> ... <remoting-outgoing-interceptors> <class-name>org.example.MyOutgoingInterceptor</class-name> </remoting-outgoing-interceptors> </core> </configuration>