zoukankan      html  css  js  c++  java
  • springboot~rabbitmq自己通过UI手动发布队列需要注意的地方

    springboot里发布队列消息

    为了兼容性和可读性更好,我们一般使用json字符串做为数据载体。

     public void decreaseCallMonitor(CallMonitorInfo callMonitorInfo) throws Exception {
        try {
          rabbitTemplate.convertAndSend(
              AmqpConfig.DATA_COLLECTION_EXCHANGE,
              AmqpConfig.CALLMONITOR_DECREASE_BINDING,
              objectMapper.writeValueAsString(callMonitorInfo)
          );
          logger.debug("Enter {},message:{}", "decreaseCallMonitor", callMonitorInfo.toString());
    
        } catch (Exception ex) {
          logger.error("MQ.decreaseCallMonitor.error", ex);
        }
      }
    

    springboot里订阅消息

      @RabbitHandler
      @RabbitListener(queues = AmqpConfig.CUSTOMER_TERMINATE_BINDING)
      public void customerTerminate(String data) {
        try {
          TerminateDTO terminateDTO = objectMapper.readValue(data, TerminateDTO.class);
          customerBusinessInfoMapper.updateCustomer_business_info(ImmutableMap.of(
              "status", EnumCustomerStatus.TERMINATE.getCode(),
              "customerId", terminateDTO.getCustomerId()
          ));
        } catch (Exception ex) {
          logger.error("解约同步异常", ex);
        }
      }
    

    通过UI15672手动发消息要注意的地方

    1. 添加properties,声明它是utf-8及文本类型
    content_encoding:utf-8
    content_type:text/plain
    
    1. json字符串需要压缩,把回车换行都去掉,否则会出错
    {"signSalespersonId":1001,"signSalesperson":"mq","signTime":null,"customerId":501806811767111700}
    

    以上两点注意好,手动发布队列就没有问题了!

  • 相关阅读:
    spring学习笔记__spring的单例多例模式
    spring学习笔记_spring入门
    Lambda表达式
    反射
    fatal error: call to undefined function imagettftext
    阿里云 centos 安装apache和php
    php 使用 极光推送 类
    php socket解决方案
    身份证号码 15位和18位 验证
    php memcache扩展 出现错误dyld: Symbol not found: _mmc_queue_free
  • 原文地址:https://www.cnblogs.com/lori/p/9805575.html
Copyright © 2011-2022 走看看