无法在 ActiveMQ 中设置拦截器/代理插件



我写了一个简单的身份验证/授权插件,我想注入到ActiveMQ中。 我希望它被称为onConnect和onSubscribe。 我已经在ActiveMQ网站上遵循了这些步骤,但是发生了一些事情。

1) 如果我在//beans/broker/plugins 中的默认 activemq.xml 文件中输入我的 bean 声明,我会收到一个验证错误,指出节点"bean"不允许在那里。

2)如果我将插件声明放在代理元素之外,它将注入元素,但它不会调用installPlugin()或钩子,大概是因为这是经纪人做的。

3) 如果我将默认 activemq.xml (http://activemq.apache.org/schema/core) 中的 XML 命名空间声明更改为上面列出的文档 (http://activemq.org/config/1.0) 中所述的声明以及正确的 URL,则会出现它找不到架构文档的错误。

唯一能想到的是,要么 5.6 中的更改没有反映在文档中,要么我做错了什么,要么我只是疯了。 这是 xml 文档的相关部分(减去与问题没有直接关系的几个节点)。

<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.org/config/1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
  <plugins>
     <bean id="tokenLoginPlugin" class="auth.TokenLoginPlugin">
       <property name="host" value="localhost" />
     </bean>
   </plugins>
</broker>

这将生成以下异常。

The matching wildcard is strict, but no declaration can be found for element 'broker'.

如果我使用默认 activemq.xml 文件中的 xmlns 声明,我会得到以下内容。

Invalid content was found starting with element 'bean'

可以看到这是一个验证错误,但似乎没有一个文档为我指明正确的方向。

想通了,虽然我以前试过,但没有奏效。 也许我上次搞砸了我的命名空间。 我更改了插件定义并将 Spring 命名空间添加到我的 Bean 声明中。

<plugins>
    <bean id="tokenLoginPlugin" class="auth.TokenLoginPlugin" xmlns="http://www.springframework.org/schema/beans">
        <property name="host" value="localhost" />
    </bean>
</plugins>

我的配置是:

<beans
  xmlns="http://www.springframework.org/schema/beans"
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<plugins>
     <bean  xmlns="http://www.springframework.org/schema/beans"  id="probePlugin" class="com.ProbePlugin"/>
</plugins>

</beans>

最新更新