SpringBoot + ActiveMQ - How to set trusted packages?

后端 未结 6 924
既然无缘
既然无缘 2021-02-19 04:47

I\'m creating two springboot server & client applications communicating using JMS, and everything is working fine with the release 5.12.1 for activemq, but as s

6条回答
  •  情书的邮戳
    2021-02-19 05:38

    Method: public void setTrustedPackages(List trustedPackages)

    Description: add all packages which is used in send and receive Message object.

    Code : connectionFactory.setTrustedPackages(Arrays.asList("org.api","java.util"))

    Implementated Code:

    private static final String DEFAULT_BROKER_URL = "tcp://localhost:61616";
    
    private static final String RESPONSE_QUEUE = "api-response";
    
    @Bean
    public ActiveMQConnectionFactory connectionFactory(){
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
        connectionFactory.setBrokerURL(DEFAULT_BROKER_URL);
        connectionFactory.setTrustedPackages(Arrays.asList("org.api","java.util"));
        return connectionFactory;
    }
    
    @Bean
    public JmsTemplate jmsTemplate(){
        JmsTemplate template = new JmsTemplate();
        template.setConnectionFactory(connectionFactory());
        template.setDefaultDestinationName(RESPONSE_QUEUE);
        return template;
    }
    

提交回复
热议问题