为了兼容性和可读性更好,我们一般使用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); } }
@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); } }
content_encoding:utf-8 content_type:text/plain
{"signSalespersonId":1001,"signSalesperson":"mq","signTime":null,"customerId":501806811767111700}
以上两点注意好,手动发布队列就没有问题了!