ActiveMQ send ObjectMessage

时光怂恿深爱的人放手 提交于 2019-12-04 13:29:58

问题


I'm using ActiveMQ to implement a messaging system in my current project. I need to send and receive Java objects instead of simple text or binary messages. The Java object (my message object) implements the Serializable interface as required.

Recent versions of ActiveMQ added some security and I need to set a property with the allowed packages as described here, but I haven't managed to make it work. I'm not sure where that property needs to be added.

Error message:

This class is not allowed to be serialized. Add package with 'org.apache.activemq.SERIALIZABLE_PACKAGES' system property


回答1:


You need to either pass trusted packages in environment variable while running jar or you can do this programmatically by adding following line of code:

    System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","*");

I hope this will help




回答2:


In your ActiveMQ config,add connectionFactory.setTrustedPackages(Arrays.asList("java.lang","your packagename"));



来源:https://stackoverflow.com/questions/34283966/activemq-send-objectmessage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!