我有 2 个非常简单的 spring-cloud-stream 应用程序。消息生产者 Service3 通过 binder-kafka 向消费者 Service4 发送消息。
我使用 spring-cloud-sleuth 来追踪它们之间的跨度。但是 zipkin 服务器中只有 Service3 中的 span 可用。Service4 没有跨度显示。
服务3
dependencies { compile('org.springframework.boot:spring-boot-starter-web') compile('org.springframework.boot:spring-boot-starter-thymeleaf') compile('org.springframework.cloud:spring-cloud-starter-sleuth') // Marshal spans over a Spring cloud stream binder compile('org.springframework.cloud:spring-cloud-sleuth-stream') compile('org.springframework.cloud:spring-cloud-stream-binder-kafka') testCompile group: 'junit', name: 'junit', version: '4.11' } @SpringBootApplication public class Service3 { public static void main(String[] args) { SpringApplication.run(Service3.class, args); } } @Controller @EnableBinding(Source.class) public class WebController { @Autowired private Source source; @GetMapping("/srv4") private String getSrv4Info(){ String msg = "Hello Service 4"; this.source.output().send(MessageBuilder.withPayload(msg).build()); return "srv4"; } }
服务4
dependencies { compile('org.springframework.boot:spring-boot-starter-web') compile('org.springframework.cloud:spring-cloud-starter-sleuth') // Marshal spans over a Spring cloud stream binder compile('org.springframework.cloud:spring-cloud-sleuth-stream') compile('org.springframework.cloud:spring-cloud-sleuth-zipkin-stream') compile('org.springframework.cloud:spring-cloud-stream-binder-kafka') runtime('io.zipkin.java:zipkin-autoconfigure-ui') testCompile group: 'junit', name: 'junit', version: '4.11' } @SpringBootApplication @EnableZipkinStreamServer public class Service4 { public static void main(String[] args) { SpringApplication.run(Service4.class, args); } } @EnableBinding(Sink.class) public class MsgReceiver { @StreamListener(Sink.INPUT) private void listen(Message<String> msg){ System.out.println(msg.getPayload()); } }
我错过了什么?