Spring Integration with consumer and Nifi as dispatcher - spring

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

Related

Spring Integration Kafka : Inbound channel adapter vs message driven adapter

I am new to using spring integration kafka. I was reading the docs, and got confused between Inbound channel adapter and message driven channel adapters. Can some one explain the difference between them . Also does spring integration for kafka has some error handling mechanism like the one present in spring integration for amqp/rmq( using dlq).
PS : We are trying to move away from rabbit mq to kafka as source of messages in ithe spring integration framework
thanks,
The message-driven adapter is similar to the rabbitmq inbound adapter in that messages are "pushed" into your integration flow whenever records are available in the topic.
The inbound channel adapter uses the "pull" model, where you poll for messages on a schedule. There is an equivalent for RabbitMQ (since 5.0.1) but it's not currently configurable with XML.
some error handling mechanism
The SIK components are subclasses of the same classes as all other SI components, so the same facilities are generally available, yes.

Spring Integration - ActiveMQ to Kafka

I am currently trying to write an adapter which will consume messages from ActiveMQ and publish it to Kafka.
I am thinking of using spring integration to integrate these two messaging systems.
My problem is that my application will not maintain registry of the Models using which many applications will publish the records to activeMQ. I want to receive these javax jms message and want to perform some transformation like adding jmscorrelationId into kafka message.
ALso, another requirement is to send acknowledgement to active mq only when kafka send/publish is successfull.
Can ack be send back to activemq using spring integration?
Will spring integration be a good option?
Kindly note my tech architect is not in favor of using Camel/Mule. Also, he does not want to use Kafka Connect as i was planning to use Kafka connect source.
Please suggest.
The Spring Integration Kafka extension project has a sync mode for publishing, which will block the thread until Kafka confirms delivery (or throw an exception on a failure).
The JMS inbound gateway can be used to return a reply to a JMS queue.
You can add transformers (or whatever) in the flow to modify the message.

Is It possible if i have put message to ActiveMq jms and consume it from RabbitMq jms?

I am new to jms,
I have did poc of spring jms with ActiveMq. In which I am producing messages in queue and consume it using consumer and one poc in which I am using spring jms with rabbitmq with producer and consumer and have added plugin of jms in rabbit mq to use spring jms with rabbitmq.
Is it Possible if I put Produce message in active MQ and Consume that messages using spring jms rabbitmq consumer?
Is It possible if yes then How?
Thanks in advance.
ActiveMQ and RabbitMQ are two different brokers - why do you need (and why do you think it's possible) to send messages to one broker and receive them from another?
You would need another application to move the messages; it's not clear why you would want to do that.
Typically, you would need an adapter layer to move the JMS messages from one MQ to another (i.e., active MQ to Rabbitmq etc.).
You can look here for some notes (IBM specific) on JMS adapters, but the underlying concept is the same i.e., consuming from one MQ and producing the messages to another MQ.

Send Active MQ messages throught Camel that were sent to a AMQ topic while Camel was down

I have configured an Active MQ server that puts messages to a determined topic, in that moment a configured Camel server take this message and send it by a route to another server, the issue happens when Camel server is down and the Active MQ still continues putting messages in the topic and when Camel starts these past messages are not read by Camel, is there any way to configure Camel to start and read past messages from this Active MQ Server?
Its ActiveMQ / JMS questions. Take a look at durable topics
http://activemq.apache.org/how-do-durable-queues-and-topics-work.html

How to get properly all queue messages from RabbitMQ in Spring?

I am using Spring, Spring-Websocket, STOMP for my application, and RabbitMQ as broker. I need to log all messages going through RabbitMQ to Postgresql tables.
I know that I can write #MessageMapping in Spring and log there, but my problem is that some clients talk to RabbitMQ directly through MQTT protocol, and Spring does not support it yet (https://jira.spring.io/browse/SPR-12581). Moreover browser clients talk through Spring to RabbitMQ using STOMP protocol.
RabbitMQ allows to track all messages using Firehose tracer. How to properly listen to amq.rabbitmq.trace topic from Spring? Or do I need to write separate Java app as consumer?
The Spring AMQP is for you!
You bind some custom queue to to that amq.rabbitmq.trace with appropriate pattern (e.g. publish.#) and configure SimpleMessageListenerContainer to receive messages from that queue.
It can be done even with pretty simple config: #EnableRabbit and #RabbitListener on some POJO method. Anyway the Binding #Bean must be there to attache your queue to that exchange.

Resources