activeMQ ObjectMessage對象安全設置

**Exception in thread "main" org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class SpringActivemq.ActivemqTest.Person! This class is not trusted to be serialized as ObjectMessage payload.

*原因:是ActiveMQ的ObjectMessage依賴於Java的序列化和反序列化,但是這個過程被認爲是不安全的。具體信息查看網址:
Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.

解決方法:
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>tcp://127.0.0.1:61617</value>
</property>
<!-- 添加信任包在到trustAllPackages -->
<property name="trustAllPackages" value="true"/> 

<property name="userName">
<value>admin</value>
</property>
<property name="password">
<value>admin</value>
</property>

</bean>

只需要把紅色部分加入到spring配置activeMQ中,便可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章