• MQ 个人小结


    在PCS项目:

    talking 发送队列
    1.1 创建
    @Bean
    public Queue orderTakingQueue() {

    return createQueue(orderTakingQueueName);
    }

    1.2 绑定


    @Bean
    public Binding orderTakingQueueBinding(Queue orderTakingQueue, DirectExchange orderExchange) {
    return BindingBuilder.bind(orderTakingQueue).to(orderExchange).with(orderTakingQueueName);
    }

    1.3 发送
    public String getOrderTakingQueueName() {
    return orderTakingQueueName;
    }

    @Override
    public void sendOrderInfo(String orderInfo) {
    System.out.println("Send order info to MQ: " + orderInfo);
    rabbitTemplate.convertAndSend(mqConfig.getOrderExchangeName(), mqConfig.getOrderTakingQueueName(), orderInfo);
    }


    2.order 接受队列

    2.1 创建

    @Bean
    public Queue orderTakingQueue() {

    return createQueue(orderTakingQueueName);
    }

    2.2 绑定

    @Bean
    public Binding orderTakingQueueBinding(Queue orderTakingQueue, DirectExchange orderExchange) {
    Binding binding = BindingBuilder.bind(orderTakingQueue).to(orderExchange).with(orderTakingQueueName);
    return binding;
    }


    2.3 接受监听(方法)

    @Bean
    public SimpleMessageListenerContainer pkgQueueListenerContainer(ConnectionFactory connectionFactory,MessageReceiver messageReceiver)
    {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(connectionFactory);
    container.setQueueNames(orderTakingQueueName);
    container.setMessageListener(new MessageListenerAdapter(messageReceiver, "receiveOrderInfo"));
    container.setConcurrentConsumers(32);
    container.setPrefetchCount(20);
    return container;
    }

  • 相关阅读:
    Tomcat 配置 login 和 gas
    Mac系统终端命令行不执行命令 总出现command not found解决方法
    NodeJS入门---nodejs详细安装步骤
    Android UI 自动化-Android环境安装
    UI自动化-Chrome元素定位插件CreateXpath的安装及使用
    eclipse解决中文乱码
    pytest的allure的环境配置
    pytest基础简介及实践举例
    Appium 工作原理及 Desired Capabilities
    Appium_adb常用命令总结
  • 原文地址:https://www.cnblogs.com/chengjun/p/8795221.html
Copyright © 2020-2023  润新知