I am running my broker but when I am pulling the message from queue getting following exception.
Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class demo.CollectorProcessInfo! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.
tried the solution given in folloing link. SpringBoot + ActiveMQ - How to set trusted packages?
also tried -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*
but not help.
Here is the code to pull the message
public QueueMessage pull(QUEUENAME queueName,
long timeOutInMilliSeconds) throws JMSException {
Connection connection = null;
Session session = null;
MessageConsumer consumer = null;
try{
ActiveMQJMSConnectionFactory factory = new ActiveMQJMSConnectionFactory();
connection = factory.getConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(queueName.toString());
consumer = session
.createConsumer(destination);
ObjectMessage receivedMessage = (ObjectMessage) consumer.receive(timeOutInMilliSeconds);
QueueMessage message = null;
if(receivedMessage != null){
message = (QueueMessage) receivedMessage.getObject();
}
else{
logger.debug("Received message is null on a timeout");
}
return message;
}
finally{
if(consumer!=null)
consumer.close();
if(session!=null)
session.close();
if(connection!=null)
connection.close();
}
}