Example of RabbitMQ with RPC in Spring Integration - spring

After make a search about different ways to implement it, im stuck.
What im looking for is to realize this example (https://www.rabbitmq.com/tutorials/tutorial-six-spring-amqp.html) with Spring Integration.
I had found interesting post as this (Spring integration with Rabbit AMQP for "Client Sends Message -> Server Receives & returns msg on return queue --> Client get correlated msg") but didn't help me with what i need.
My case mill be a system where a client call the "convertSendAndReceive" method and a server (basede on Spring Integration) will response.
Thanks

According to your explanation it sounds like Outbound Gateway on the Client side and Inbound Gateway on the Server side pair is what you need.
Spring Integration AMQP support provides those implementations for you with built-in correlation functionality: https://docs.spring.io/spring-integration/docs/5.0.0.RELEASE/reference/html/amqp.html

Related

REST API command with event driven choreography

I'm trying to design a system in an event-driven architecture style, trying also to expose REST API to send commands/queries. I decided to use Kafka as a message broker.
The choreography I'm trying to design is the following:
The part that is very obscure to me is how to implement event joins:
billing-service should start creating the user only when it receives the user creation event (1) and the account has been created (2)
api-gateway should return the result to the client only when both account and billing service have finished their processing (2 and 3)
I know I could use other protocols on the client side (e.g. WebSockets) but I prefer not doing that because I will need to expose such API to 3rd party. I could also do an async client call and poll to check if the request has been completed but it appears very complex to manage.
What is the suggested way of implementing such an interaction?
p.s. I'm using Spring Boot and Spring Cloud Stream.
Request/reply messaging on the client side is possible with spring-cloud-stream, but it's a bit involved because it wasn't designed for that, it's intended for unidirectional stream processing.
You would be better off using spring-kafka (ReplyingKafkaTemplate) or spring-integration-kafka (Outbound Gateway) for request/reply on the client side.
On the service side you can use a #StreamListener (spring-cloud-stream) or a #KafkaListener or a spring-integration inbound-gateway.

Jax-rs and amqp zipkin integration

I've been roaming the depths of the internet but I find myself unsatisfied by the examples I've found so far. Can someone point me or, show me, a good starting point to integrate zipkin tracing with jaxrs clients and amqp clients?
My scenario is quite simple and I'd expect this task to be trivial tbh. We have a micro services based architecture and it's time we start tracing our requests and have global perspective of our inter service dependencies and what the requests actually look like (we do have metrics but I want more!) . The communication is done via jax-rs auto generated clients and we use rabbit template for messaging.
I've seen brave integrations with jaxrs but they are a bit simplistic. My zipkin server is a spring boot mini app using stream-rabbit, so zipkin data is sent using rabbitmq.
Thanks in advance.
After some discussion with Marcin Grzejszczak and Adrien Cole (zipkin and sleuth creators/active developers) I ended up creating a Jersey filter that acts as bridge between sleuth and brave. Regarding AMQP integration, added a new #StreamListener with a conditional for zipkin format spans (using headers). Sending messages to the sleuth exchange with zipkin format will then be valid and consumed by the listener. For javascript (zipkin-js), I ended up creating a new AMQP Logger that sends zipkin spans to a determined exchange. If someone ends up reading this and needs more detail, you're welcome to reach out to me.

Spring boot + Spring Integration Websocket adapter + Tibco JMS Server

I am working to build an application (Server side) which should pick message from tibco jms queue and then post that to a url at which the Client (written in angular js) will listen, and also from client when some actions are taken then the server should listen to those actions and perform respective actions.
I can read from tibco jms queue and can place it to a spring integration channel.
My question here is that, can this be build using spring integration websocket adaptors (inbound & outbound) ? If yes then can someone help me with some references for sending to the client and receiving from the client adaptor configurations ?
All the info about Spring Integration Websocket module is in the Reference Manual.
You also can take a look to a couple samples:
Simple plain Websockets
Chat based on STOMP protocol

Stomp + Spring + ZeroMQ for real-time

I need to implement a real-time scenario via web sockets and ZeroMQ queue.
SockJS with Stomp in the client side
Spring MVC / Integration with #EnableWebSocketMessageBroker
Remote messaging queue with ZeroMQ
At this moement, I could connect client and Spring via web sockets but I need to add the magic of remote queues.
ZeroMQ is available from 2 remote URLs (one for publishing and another one for subscribing).
My question is: How can I implement ZeroMQ in order to stay listening subscribed URL or the publishing URL?
Additionally, this type of functionality is conceptually similar to Spring Integration Outbound Gateways which stay listening for the response. Is it possible to implement ZeroMQ via Spring integration?
Thank you
We have an open JIRA issue to add ZeroMQ support to Spring Integration.
But nothing is implemented yet; contributions are welcome!.

Spring AMQP request-response across 2 web applications

I would like an example/sample code of 2 simple spring web/java applications where I need to send messages from the 1 and the 2nd application must receive the messages and respond back. I looked at few that had request/response in the same application but unable to separate them. I'm new to Amqp & RabbitMQ. Any help or direction would be greatly appreciated.
Thanks
See the stock trading sample, request reply messaging (client side) and MessageListenerAdapter which automatically handles request/reply on the server side (where your service is a POJO).

Resources