Active MQ 传输 ObjectMessage 异常

Active MQ 传输 ObjectMessage 异常

复制代码
<bean id="targetConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">  
        <property name="brokerURL" value="tcp://localhost:61616"/>
        <!-- 如果传输的对象是Obeject 这里必须加上这句  否则会导致对象序列化失败 出现classnotfound异常  详细: http://activemq.apache.org/objectmessage.html -->
        <property name="trustAllPackages" value="true"/>
    </bean>  
复制代码

在消费者接受队消息时,出现异常

javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class com.guesslive.admin.common.mail.Mail! This class is not trusted to be serialized as ObjectMessage payload. Please take a look athttp://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.

然后根据提供的地址找了下原因,在 ActiveMQConnectionFactory 中加入参数 

<property name="trustAllPackages" value="true"/>

问题解决!

猜你喜欢

转载自blog.csdn.net/w405722907/article/details/80283359
今日推荐