-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Sleuth Correlating Messages #96
Comments
Try using the annotation based approach instead of direct calling of
messagetemplate. Then it should work.
|
Also here you have an example of usage of Spring Cloud Stream to make apps
talk to each other. This is the sender
https://github.com/spring-cloud-samples/brewery/blob/master/common/src/main/java/io/spring/cloud/samples/brewery/common/events/EventGateway.java.
and this is the receiver
https://github.com/spring-cloud-samples/brewery/blob/master/brewing/src/main/java/io/spring/cloud/samples/brewery/reporting/EventListener.java
.
|
The problem is interceptors which traces between services is not set in case of messaging. In your channel (DirectChannel) set following interceptor. In case you want to shift to ExecutorChannel in future, then along with above interceptor set this as well |
@gauravrmazra thank you for your feedback and support. That's highly appreciated. However the thing is we want users not to need to add any interceptors manually. We would like them use approaches that will set things automatically for them. My example is exactly showing that case. First enable binding (@englishbreeze - you'll have one binding on the sender and one on the receiver side - in this example I have both in one place) Then use the approaches mentioned in my comment below. Using Spring Cloud Stream is the suggested way of making applications talk to each other indirectly via messaging. |
@marcingrzejszczak Agreed. My experience was little different when I was evaluating this for Stomp messages. It took 2-3 days of effort for understanding that SimpMessagingTemplate(even created by Spring for you) doesn't have ChannelInterceptors injected. You need to extend AbstractWebSocketMessageBrokerConfigurer and overrider configureMessageBroker method and need to add interceptors yourself in brokerChannel of MessageBrokerRegistry. Long story short, at times you can't reply on what Spring sets up for you by default. User need to be aware of what part is missing and how they can relying on tracing if they are configuring components themselves. |
@gauravrmazra you are right but I guess what @englishbreeze was asking about is how to do things properly. 3b6b49f - I think that this proves that it's enough to register We can't support all possible scenarios of manual creation of things. But thanks for your support @gauravrmazra . We really appreciate it!! |
Thank you for the reply @marcingrzejszczak and @gauravrmazra . If I wanted to use AMQP to send messages from one service to another via some broker (e.g. RabbitMQ), how do I set it up such that spring sleuth will correlate the sender and the receiver. I tried @gauravrmazra 's suggestion of adding TraceChannelInterptor in my DirectChannel bean but it still does not correlate them together. |
@englishbreeze check out the brewery sample as I told you in the previous comments. First enable binding (@englishbreeze - you'll have one binding on the sender and one on the receiver side - in this example I have both in one place) This is the sender and this is the receiver IN your dependencies add https://github.com/spring-cloud-samples/brewery/blob/master/build.gradle#L118 and https://github.com/spring-cloud-samples/brewery/blob/master/build.gradle#L119 Can we close this issue and maybe move this discussion to https://gitter.im/spring-cloud/spring-cloud ? |
Thanks for your help @marcingrzejszczak . Do you know how to resolve this error? org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.Application]; nested exception is java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.sleuth.stream.SleuthStreamAutoConfiguration |
Hmm at the first glance it seems like a mismatch in versions of Spring, Spring Boot and Sleuth - can we close this issue and move to Gitter with further explanations? |
Yes |
Now that the span data is stored in a header it is safe to remove the slightly clunky propagation implentation that used a subclass. Also removed the Stomp* features because they were diverging from the mainstream integration support and no-one seems to understand why they are needed. If the original author of #96 can explain why they were needed we can ask for a new PR to re-instate a version that works with the new model.
TraceChannelInterceptor can't trace Stomp protocol based messages sent using Spring. It has different message headers[normal headers + native headers] than the usual JMS message. use case: STOMP messages are usually used to pass data over websocket or any message broker (JMS, ActiveMQ etc.) can also be used for it. e.g. https://spring.io/guides/gs/messaging-stomp-websocket/ |
There is nothing in Sleuth specific to JMS: it is all using the spring messaging APIs (which is the same as the STOMP support in Spring). So I don't really understand the issue yet. |
JMS and STOMP message use different message builder. They have different header accessors and different type of MessageHeaders. jms header accessor => IntegrationMessageHeaderAccessor |
Yes, but a) it's not JMS, it's Spring Integration and b) they both use the same core API for In any case can we stop discussing this here, in an unrelated, closed issue? |
Hi,
I have a service that sends messages to another service and would like to correlate them together. The problem is that Spring Sleuth does not correlate the two services together (i.e. Set the parent trace id of the receiver to the trace id of the sender) I'm using Spring Integration MessageChannel to send message from one service to another. Here is my channel configuration for the outbound channel:
sending the Message using this code:
MessagingTemplate template = new MessagingTemplate();
template.send(channel, new GenericMessage("blahblah"));
Here is my channel configuration for the input channel:
Can you guys let me know how I'm suppose to correlate the two services using Messaging?
The text was updated successfully, but these errors were encountered: