I have an active MQ factory in a Spring Boot app, type ActiveMQConnectionFactory
.
Right after instantiating it I set the trusted packages to just java.lang
since I want to be able to send/receive just Strings via JMS in my app.
See also here:
SpringBoot + ActiveMQ - How to set trusted packages?
https://stackoverflow.com/a/36622567/2300597
@Bean(name="jmsConnectionFactory")
public ConnectionFactory getJMSConnectionFactory(){
_factory = new ActiveMQConnectionFactory(active_MQ_BrokerURL);
ActiveMQConnectionFactory fct = ((ActiveMQConnectionFactory)_factory);
fct.setTrustAllPackages(false);
fct.setTrustedPackages(Arrays.asList("java.lang"));
return _factory;
}
And yet I am able to send other objects (not from package java.lang
)?!
I don't get an Exception
of some sort when sending them.
Why is that? What am I doing wrong?
NOTE: I am using org.springframework.jms.core.JmsTemplate
to send the messages
(in case that matters). The template is linked to that factory.
public void sendObjectMessage(final Serializable msg) {
try {
this.jmsTemplate.send(this.queue, new MessageCreator() {
public Message createMessage(final Session session) throws JMSException {
return session.createObjectMessage(msg);
}
});
logger.info("Success sending Object MQ message [{}]", msg);
} catch (Exception e) {
logger.error("Error sending Object MQ message [{}]", msg, e);
}
}