@Test public void onMessage() throws JMSException { Message message = mock(Message.class); Destination destination = mock(Destination.class); when(message.getJMSReplyTo()).thenReturn(destination); seckillActiveConsumer.onMessage(message); verify(seckillExecutor, times(1)).dealSeckill(eq(0L), isNull(), isNull()); verify(jmsTemplate, atLeastOnce()).send(eq(destination), isNotNull()); }
@Override public void onMessage(Message message) { log.debug("收到消息{}", message.toString()); long seckillId = 0; String userPhone = null; String note = null; try { seckillId = message.getLongProperty("seckillId"); userPhone = message.getStringProperty("userPhone"); note = message.getStringProperty("note"); } catch (JMSException e) { log.error(e.getMessage(), e); } seckillExecutor.dealSeckill(seckillId, userPhone, note); try { Destination jmsReplyTo = message.getJMSReplyTo(); if (jmsReplyTo != null) { jmsTemplate.send(jmsReplyTo, session -> { Message mes = session.createMessage(); mes.setJMSCorrelationID(message.getJMSCorrelationID()); mes.setStringProperty("message", "dealSuccess!"); return mes; }); } } catch (JMSException e) { log.warn(e.getMessage(), e); } }
SeckillActiveConsumer implements MessageListener { @Override public void onMessage(Message message) { log.debug("收到消息{}", message.toString()); long seckillId = 0; String userPhone = null; String note = null; try { seckillId = message.getLongProperty("seckillId"); userPhone = message.getStringProperty("userPhone"); note = message.getStringProperty("note"); } catch (JMSException e) { log.error(e.getMessage(), e); } seckillExecutor.dealSeckill(seckillId, userPhone, note); try { Destination jmsReplyTo = message.getJMSReplyTo(); if (jmsReplyTo != null) { jmsTemplate.send(jmsReplyTo, session -> { Message mes = session.createMessage(); mes.setJMSCorrelationID(message.getJMSCorrelationID()); mes.setStringProperty("message", "dealSuccess!"); return mes; }); } } catch (JMSException e) { log.warn(e.getMessage(), e); } } }
SeckillActiveConsumer implements MessageListener { @Override public void onMessage(Message message) { log.debug("收到消息{}", message.toString()); long seckillId = 0; String userPhone = null; String note = null; try { seckillId = message.getLongProperty("seckillId"); userPhone = message.getStringProperty("userPhone"); note = message.getStringProperty("note"); } catch (JMSException e) { log.error(e.getMessage(), e); } seckillExecutor.dealSeckill(seckillId, userPhone, note); try { Destination jmsReplyTo = message.getJMSReplyTo(); if (jmsReplyTo != null) { jmsTemplate.send(jmsReplyTo, session -> { Message mes = session.createMessage(); mes.setJMSCorrelationID(message.getJMSCorrelationID()); mes.setStringProperty("message", "dealSuccess!"); return mes; }); } } catch (JMSException e) { log.warn(e.getMessage(), e); } }  }
SeckillActiveConsumer implements MessageListener { @Override public void onMessage(Message message) { log.debug("收到消息{}", message.toString()); long seckillId = 0; String userPhone = null; String note = null; try { seckillId = message.getLongProperty("seckillId"); userPhone = message.getStringProperty("userPhone"); note = message.getStringProperty("note"); } catch (JMSException e) { log.error(e.getMessage(), e); } seckillExecutor.dealSeckill(seckillId, userPhone, note); try { Destination jmsReplyTo = message.getJMSReplyTo(); if (jmsReplyTo != null) { jmsTemplate.send(jmsReplyTo, session -> { Message mes = session.createMessage(); mes.setJMSCorrelationID(message.getJMSCorrelationID()); mes.setStringProperty("message", "dealSuccess!"); return mes; }); } } catch (JMSException e) { log.warn(e.getMessage(), e); } }  @Override void onMessage(Message message); }
SeckillActiveConsumer implements MessageListener { @Override public void onMessage(Message message) { log.debug("收到消息{}", message.toString()); long seckillId = 0; String userPhone = null; String note = null; try { seckillId = message.getLongProperty("seckillId"); userPhone = message.getStringProperty("userPhone"); note = message.getStringProperty("note"); } catch (JMSException e) { log.error(e.getMessage(), e); } seckillExecutor.dealSeckill(seckillId, userPhone, note); try { Destination jmsReplyTo = message.getJMSReplyTo(); if (jmsReplyTo != null) { jmsTemplate.send(jmsReplyTo, session -> { Message mes = session.createMessage(); mes.setJMSCorrelationID(message.getJMSCorrelationID()); mes.setStringProperty("message", "dealSuccess!"); return mes; }); } } catch (JMSException e) { log.warn(e.getMessage(), e); } }  @Override void onMessage(Message message);  }