Spring Cloud Sleuth with RabbitTemplate - spring

I have a problem with spring cloud sleuth and rabbitTemplate. When i send post with my service and pulibsh message on rabbitmq using rabbitTemplate, my second service consume the message, but not respect same trace id generate on service 1. Exists any soluction for hold on the same trace?

Related

axon spring boot give serialization error with axon kafka

I'm using Axon Server with Kafka like an event store , and I get this error message and I don't know why!!??

Spring Integration with consumer and Nifi as dispatcher

we are developing a service that listens or consume message from RabbitMQ queue. The message is dispatch from Apache Nifi to the message queue (e.g. queue name is "workitems").
Now, I would like to see a code snippet using Spring Integration to listen and process this message dispatched in the queue (RabbitMQ) from Apache Nifi.
Thanks!
It sounds like you need AMQP Channel Adapter from Spring Integration: https://docs.spring.io/spring-integration/docs/5.3.0.M4/reference/html/amqp.html#amqp-inbound-channel-adapter
And here is a sample on the matter: https://github.com/spring-projects/spring-integration-samples/tree/master/basic/amqp

spring-boot-starter-amqp will works between micro services?

I am new to Spring amqp.
I have tried to send the messages by following: https://spring.io/guides/gs/messaging-rabbitmq/
I am able to send the messages within the micro services.
But unable to send the messages to another micro services ? Is it expected ?
If I want to send the messages between the micro services which dependency I should follow ?
Please help me here.
What you want is something like this (figure taken from a recent blog post of mine, which also shows more detailed code examples):
Here, as an example, CRUD-Events like "customer.created" or "order.deleted" are considered
Any microservice can act as an Event Producer and send events to an event exchange via RabbitTemplate, which is provided by Spring AMQP and can just be injected into any Spring Bean.
A cluster of instances of the same microservice share a queue.
The consuming microservices declare their queue and the binding between queue and event exchange by declaring #Beans of type Queue and Binding with the same attributes.
The binding defines which events will be received by each microservice cluster
All microservices must share the same event exchange by declaring a #Bean of type Exchange with the same exchange name.
In one service you would send the message and in an other receive it. In the example you now have both in 1 project. In the sending service you have the RabbitTemplate and in the other service the Receiver with the SimpleMessageListenerContainer and MessageListenerAdapter beans. Make sure that the binding, queue and exchange configuration are the same and the services are both connected to the same RabbitMQ server.

Use SimpMessagingTemplate without creating a web socket message broker Spring 4

Can I send a message to a message broker using SimpMessagingTemplate#convertAndSendToUser or SimpMessagingTemplate#convertAndSend methods without settings up a websocket message broker using #EnableWebSocketMessageBroker?
What I'm trying to do is utilise one websocket server to provide messaging for two application server instances(One spring 4 and one Spring 3). I created a one web server with Spring 4, Spring boot plus websocket message broker enabled.
Now I want two application servers to push messages to rabbitmq so it will broadcast them to clients subscribed to it.
First issue I faced is if there is no websockt message broker configuration available, SimpMessagingTemplate will not get autowired to application context. I couldn't get it injected without creating a websocket message board either.
Please help me to find out whether this is possible.
BTW I have a previous question unanswered related to this.
Well, After reading lots of documentation I found the answer myself. The key thing is this architecture is following.
In this architecture spring act as a gateway for communication between the message broker and client. Spring doesn't do anything(Other than when it necessary) but forward the request to the message broker(STOMP messages). The configuration kept on Spring defines couple of important things. One is the exchange and other were routing keys. Spring configuration gives us an abstract layer so we subscribe and push messages to message broker without a fuss.
SimpMessagingTemplate is the abstract layer which we use to communicate with message broker. Spring creates the bean using the given details. Well I couldn't create a instance of SimpMessagingTemplate manually. I have to update Spring 3 application to Spring 4 in order to use websockets.
Since Spring and message broker is decoupled, clustering the application instance doesn't make any effect on message broker. Spring will communicate to message broker only when it need to subscribe to a channel or when it need to publish a message to a channel. So if there is two instances subscribing to same channel it would be two queues binding the one exchange using same routing key. Messages published into a channel will be available to all subscribers(queues) because they all use same routing key. Refer to rabbitmq stop plugin documentation for more elaborative description.

Consuming Messages from Amazon SQS using Spring

i am using the Amazon SQS as Message Queue. I am investigating how it is possible to set up a Spring consumer within Tomcat that would consume messages. However i looked around and it seems to say that to deploy a Spring Message Driven Bean to consume messages from Queue in Tomcat, i would need TomcatEE / Tomcat + ActiveMQ.
At the same time i have also reviewed the following SQS-Spring driver and wonder if it is of much use. http://nevado.skyscreamer.org/quickstart.html
Could someone advise what is required to accomplish the above?
SimpleMessageListenerContainer can be used to start/stop listeners programatically.
simpleMessageListenerContainer.start("logical queue name")
Other than that you have two options. Using spring's QueueMessagingTemplate
Message<?> msg = ((QueueMessagingTemplate) template).receive("logical queue name");
this will requiere that no listeners are defined in the application for this queue.
Or use the spring cloud messaging annotation SQSListener
#SqsListener(value = "logical queue name")

Resources