Java Code Examples for org.springframework.messaging.support.ExecutorSubscribableChannel#send()
The following examples show how to use
org.springframework.messaging.support.ExecutorSubscribableChannel#send() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TracingChannelInterceptorTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void subscriber_startsAndStopsConsumerAndProcessingSpan() { ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); channel.addInterceptor(executorSideOnly(this.interceptor)); List<Message<?>> messages = new ArrayList<>(); channel.subscribe(messages::add); channel.send(MessageBuilder.withPayload("foo").build()); assertThat(messages.get(0).getHeaders()).doesNotContainKeys("b3", "nativeHeaders"); assertThat(this.spans).extracting(MutableSpan::kind) .containsExactly(Span.Kind.CONSUMER, null); }
Example 2
Source File: TracingChannelInterceptorTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
/** * The subscriber consumes a message then synchronously processes it. Since we only * inject trace IDs on unprocessed messages, we remove IDs to prevent accidental * re-use of the same span. */ @Test public void subscriber_removesTraceIdsFromMessage() { ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); channel.addInterceptor(this.interceptor); List<Message<?>> messages = new ArrayList<>(); channel.subscribe(messages::add); channel.send(MessageBuilder.withPayload("foo").build()); assertThat(messages.get(0).getHeaders()).doesNotContainKeys("b3"); }
Example 3
Source File: TracingChannelInterceptorTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void subscriber_removesTraceIdsFromMessage_nativeHeaders() { ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); channel.addInterceptor(this.interceptor); List<Message<?>> messages = new ArrayList<>(); channel.subscribe(messages::add); channel.send(MessageBuilder.withPayload("foo").build()); assertThat((Map) messages.get(0).getHeaders().get(NATIVE_HEADERS)) .doesNotContainKeys("b3"); }
Example 4
Source File: TracingChannelInterceptorTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void integrated_sendAndSubscriber() { ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); channel.addInterceptor(this.interceptor); List<Message<?>> messages = new ArrayList<>(); channel.subscribe(messages::add); channel.send(MessageBuilder.withPayload("foo").build()); assertThat(this.spans).extracting(MutableSpan::kind) .containsExactly(Span.Kind.CONSUMER, null, Span.Kind.PRODUCER); }
Example 5
Source File: TracingChannelInterceptorTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_store_kafka_as_remote_service_name_when_kafka_header_is_present() { ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); channel.addInterceptor(this.interceptor); List<Message<?>> messages = new ArrayList<>(); channel.subscribe(messages::add); Map<String, Object> headers = new HashMap<>(); headers.put(KafkaHeaders.MESSAGE_KEY, "hello"); channel.send(MessageBuilder.createMessage("foo", new MessageHeaders(headers))); assertThat(this.spans).extracting(MutableSpan::remoteServiceName) .contains("kafka"); }
Example 6
Source File: TracingChannelInterceptorTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_store_rabbitmq_as_remote_service_name_when_rabbit_header_is_present() { ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); channel.addInterceptor(this.interceptor); List<Message<?>> messages = new ArrayList<>(); channel.subscribe(messages::add); Map<String, Object> headers = new HashMap<>(); headers.put(AmqpHeaders.RECEIVED_ROUTING_KEY, "hello"); channel.send(MessageBuilder.createMessage("foo", new MessageHeaders(headers))); assertThat(this.spans).extracting(MutableSpan::remoteServiceName) .contains("rabbitmq"); }
Example 7
Source File: TracingChannelInterceptorTest.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@Test public void should_store_broker_as_remote_service_name_when_no_special_headers_were_found() { ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); channel.addInterceptor(this.interceptor); List<Message<?>> messages = new ArrayList<>(); channel.subscribe(messages::add); Map<String, Object> headers = new HashMap<>(); channel.send(MessageBuilder.createMessage("foo", new MessageHeaders(headers))); assertThat(this.spans).extracting(MutableSpan::remoteServiceName) .containsOnly("broker", null); }