springBoot+activemq实现对象传输

前半段:

https://blog.csdn.net/qq_27721169/article/details/80524543

生产者:

@Override
    public void send(ManagerBcLog msg) {
        this.jmsMessagingTemplate.convertAndSend(this.queue, msg);
    }


    @Override
    public void sendBcLog(ManagerBcLog log, Boolean isBlockChain) {
        managerBcLogService.add(log);
        System.out.println("看看是不是开启上链:" + isBlockChain);
        if (isBlockChain) {
            send(log);
        }
    }

消费者:

 @Override
    @JmsListener(destination = "blockChain.queue")
    public void receiveQueue(ManagerBcLog managerBcLog) {
        System.out.println("回掉成功了");
        BlockChainBack blockChainBack = blockhainReturn(managerBcLog);
        System.out.println(blockChainBack.getMessage());
        
    }

配置:

@Configuration
public class QueueConfig {

    @Bean
    public Queue queue() {
        return new ActiveMQQueue("blockChain.queue");
    }

    @Autowired
    private ActiveMQConnectionFactory connectionFactory;

    @Bean
    public QueueProducerService queueProducerService() {
        return new QueueProducerServiceImpl();
    }

    @Bean
    public QueueConsumerService queueConsumerService() {
        return new QueueConsumerServiceImpl();
    }

    @Bean
    public JmsMessagingTemplate jmsMessagingTemplate() {
        JmsMessagingTemplate jmsMessagingTemplate = new JmsMessagingTemplate(connectionFactory);
        jmsMessagingTemplate.setMessageConverter(new SimpleMessageConverter());
        return jmsMessagingTemplate;
    }

}

properties:

 

spring.activemq.packages.trust-all=true

 

你可能感兴趣的:(插件,java后台)