@Test public void onMessage() { sekcillKafkaConsumer.onMessage(new ConsumerRecord("1", 1, 0L, "key", "1")); verify(seckillExecutor, only()).dealSeckill(anyLong(),any(),any()); }
@KafkaListener(topics = "goodsKill-kafka") public void onMessage(Object data) { if (data instanceof ConsumerRecord) { ConsumerRecord record = (ConsumerRecord) data; String userPhone = record.key().toString(); long seckillId = Long.parseLong((String) record.value()); seckillExecutor.dealSeckill(seckillId, userPhone, "秒杀场景四(kafka消息队列实现)"); } else { log.warn("未处理数据：{}", data.toString()); } }
SekcillKafkaConsumer { @KafkaListener(topics = "goodsKill-kafka") public void onMessage(Object data) { if (data instanceof ConsumerRecord) { ConsumerRecord record = (ConsumerRecord) data; String userPhone = record.key().toString(); long seckillId = Long.parseLong((String) record.value()); seckillExecutor.dealSeckill(seckillId, userPhone, "秒杀场景四(kafka消息队列实现)"); } else { log.warn("未处理数据：{}", data.toString()); } } }
SekcillKafkaConsumer { @KafkaListener(topics = "goodsKill-kafka") public void onMessage(Object data) { if (data instanceof ConsumerRecord) { ConsumerRecord record = (ConsumerRecord) data; String userPhone = record.key().toString(); long seckillId = Long.parseLong((String) record.value()); seckillExecutor.dealSeckill(seckillId, userPhone, "秒杀场景四(kafka消息队列实现)"); } else { log.warn("未处理数据：{}", data.toString()); } }  }
SekcillKafkaConsumer { @KafkaListener(topics = "goodsKill-kafka") public void onMessage(Object data) { if (data instanceof ConsumerRecord) { ConsumerRecord record = (ConsumerRecord) data; String userPhone = record.key().toString(); long seckillId = Long.parseLong((String) record.value()); seckillExecutor.dealSeckill(seckillId, userPhone, "秒杀场景四(kafka消息队列实现)"); } else { log.warn("未处理数据：{}", data.toString()); } }  @KafkaListener(topics = "goodsKill-kafka") void onMessage(Object data); @JmsListener(destination = "GOODSKILL_SENCE8") void processMessage(Message message); }
SekcillKafkaConsumer { @KafkaListener(topics = "goodsKill-kafka") public void onMessage(Object data) { if (data instanceof ConsumerRecord) { ConsumerRecord record = (ConsumerRecord) data; String userPhone = record.key().toString(); long seckillId = Long.parseLong((String) record.value()); seckillExecutor.dealSeckill(seckillId, userPhone, "秒杀场景四(kafka消息队列实现)"); } else { log.warn("未处理数据：{}", data.toString()); } }  @KafkaListener(topics = "goodsKill-kafka") void onMessage(Object data); @JmsListener(destination = "GOODSKILL_SENCE8") void processMessage(Message message);  }