@Test public void testSyncSend() throws InterruptedException { int id = (int) (System.currentTimeMillis() / 1000); producer.syncSend(id); new CountDownLatch(1).await(); }
@Transactional public void syncSend(Integer id) throws InterruptedException { Demo11Message message = new Demo11Message(); message.setId(id); rabbitTemplate.convertAndSend(Demo11Message.EXCHANGE, Demo11Message.ROUTING_KEY, message); logger.info("[syncSend][发送编号：[{}] 发送成功]", id); Thread.sleep(10 * 1000L); }
Demo11Producer { @Transactional public void syncSend(Integer id) throws InterruptedException { Demo11Message message = new Demo11Message(); message.setId(id); rabbitTemplate.convertAndSend(Demo11Message.EXCHANGE, Demo11Message.ROUTING_KEY, message); logger.info("[syncSend][发送编号：[{}] 发送成功]", id); Thread.sleep(10 * 1000L); } }
Demo11Producer { @Transactional public void syncSend(Integer id) throws InterruptedException { Demo11Message message = new Demo11Message(); message.setId(id); rabbitTemplate.convertAndSend(Demo11Message.EXCHANGE, Demo11Message.ROUTING_KEY, message); logger.info("[syncSend][发送编号：[{}] 发送成功]", id); Thread.sleep(10 * 1000L); }  }
Demo11Producer { @Transactional public void syncSend(Integer id) throws InterruptedException { Demo11Message message = new Demo11Message(); message.setId(id); rabbitTemplate.convertAndSend(Demo11Message.EXCHANGE, Demo11Message.ROUTING_KEY, message); logger.info("[syncSend][发送编号：[{}] 发送成功]", id); Thread.sleep(10 * 1000L); }  @Transactional void syncSend(Integer id); }
Demo11Producer { @Transactional public void syncSend(Integer id) throws InterruptedException { Demo11Message message = new Demo11Message(); message.setId(id); rabbitTemplate.convertAndSend(Demo11Message.EXCHANGE, Demo11Message.ROUTING_KEY, message); logger.info("[syncSend][发送编号：[{}] 发送成功]", id); Thread.sleep(10 * 1000L); }  @Transactional void syncSend(Integer id);  }