@Test public void processMessage() { ValueOperations valueOperations = mock(ValueOperations.class); Seckill value = new Seckill(); value.setNumber(1); when(redisService.getSeckill(anyLong())).thenReturn(value); when(redisTemplate.opsForValue()).thenReturn(valueOperations); when(valueOperations.increment(any())).thenReturn(1L); Message message = mock(Message.class); sekcillKafkaConsumer.processMessage(message); verify(activeMqMessageSender, only()).sendSeckillSuccessTopic(anyLong(), isNull()); verify(seckillMapper, only()).updateById(any()); }
@JmsListener(destination = "GOODSKILL_SENCE8") public void processMessage(Message message) { log.debug("收到消息{}", message); 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); } dealSeckill(seckillId, userPhone, note); }
SekcillKafkaConsumer { @JmsListener(destination = "GOODSKILL_SENCE8") public void processMessage(Message message) { log.debug("收到消息{}", message); 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); } dealSeckill(seckillId, userPhone, note); } }
SekcillKafkaConsumer { @JmsListener(destination = "GOODSKILL_SENCE8") public void processMessage(Message message) { log.debug("收到消息{}", message); 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); } dealSeckill(seckillId, userPhone, note); }  }
SekcillKafkaConsumer { @JmsListener(destination = "GOODSKILL_SENCE8") public void processMessage(Message message) { log.debug("收到消息{}", message); 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); } dealSeckill(seckillId, userPhone, note); }  @KafkaListener(topics = "goodsKill-kafka") void onMessage(Object data); @JmsListener(destination = "GOODSKILL_SENCE8") void processMessage(Message message); }
SekcillKafkaConsumer { @JmsListener(destination = "GOODSKILL_SENCE8") public void processMessage(Message message) { log.debug("收到消息{}", message); 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); } dealSeckill(seckillId, userPhone, note); }  @KafkaListener(topics = "goodsKill-kafka") void onMessage(Object data); @JmsListener(destination = "GOODSKILL_SENCE8") void processMessage(Message message);  }