Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveMQ send ObjectMessage

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

like image 858
aelve Avatar asked Dec 04 '22 01:12

aelve


2 Answers

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

like image 171
Raheel Avatar answered Feb 01 '23 16:02

Raheel


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

like image 20
XYz Amos Avatar answered Feb 01 '23 18:02

XYz Amos