0

I am working on the integration flow between two RabbitMQ message brokers.

My IntegrationFlow code is:

   @Bean
    public IntegrationFlow messageFlow() {
        return IntegrationFlows.from(stompInboundChannelAdapter())
                .transform(inBoundStompMsgTransformer::transform)
                .headerFilter("stomp_subscription","content-length")
                .handle(Amqp.outboundAdapter(outboundConfiguration.rabbitTemplate()))
                .log()
                .get();
    }

Inbound Adapter code is:

   @Bean
    public MessageChannel stompInputChannel() {
        return new DirectChannel();
    }

    @Bean
    public StompInboundChannelAdapter stompInboundChannelAdapter() {
        StompInboundChannelAdapter adapter = new StompInboundChannelAdapter(stompSessionManager(), "/queue/myQueue");
        adapter.setOutputChannel(stompInputChannel());
        adapter.setPayloadType(ByteString.class);
        return adapter;
    }

I am getting messages. The messages are getting transformed. However, the transformed messages are not reaching the other RabbitMQ

The rabbitTemplate code is:

  @Bean
    Binding binding(Queue queue, DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(routingkey);
    }

    @Bean
    public ConnectionFactory connectionFactory() {
        CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(host);
        cachingConnectionFactory.setUsername(username);
        cachingConnectionFactory.setUsername(password);
        return cachingConnectionFactory;
    }

    @Bean
    public AmqpTemplate rabbitTemplate() {
        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory());
        rabbitTemplate.setExchange(exchange);
        rabbitTemplate.setRoutingKey(routingkey);
        return rabbitTemplate;
    }

What is wrong with my IntegrationFlow?

Thanks,

Mahesh

Mahesh
  • 59
  • 1
  • 7
  • 1
    Your code looks like it should work (although you can't use `.log` after an outbound adapter - there's no reply message); try setting a breakpoint in template.doSend() and check that the exchange and routing key are correct; also check the binding is correct on the admin UI. If you can't figure it out, post your project someplace and I'll take a look. – Gary Russell Dec 07 '19 at 22:22
  • Do you have a RabbitAdmin bean? Or do you use Spring Boot? Is able to try an `ExpressingEvaluatingRequestHandlerAdvice` on the outbound AMQP endpoint to be sure what exception you get: https://docs.spring.io/spring-integration/docs/5.2.2.RELEASE/reference/html/messaging-endpoints.html#expression-advice? – Artem Bilan Dec 08 '19 at 02:23
  • @GaryRussell Thanks a lot. Deleted the queue, recreated it with proper binding and it worked. – Mahesh Dec 08 '19 at 02:41
  • This is my first POC. I would like to build on top it. Is it the ok to start integration flow from an inbound adapter? Most of the examples that i see on internet starts from a channel. Any suggestions or pointers to move in the right direction? – Mahesh Dec 08 '19 at 02:51
  • @Artem thanks for your response. I use Spring Boot. – Mahesh Dec 08 '19 at 02:52
  • 1
    Not sure why you have such a question since there is a factory to start the flow from inbound channel adapter. So, even if you haven’t seen samples in the Internet, it doesn’t mean that your solution is wrong. – Artem Bilan Dec 08 '19 at 02:54
  • @ArtemBilan thanks for your response. What you said is true. I will continue building and learn best practices along the way :) – Mahesh Dec 08 '19 at 03:27
  • I think this thread can be deleted as not relevant any more. – Artem Bilan Dec 09 '19 at 15:00
  • Yes. It can be. – Mahesh Dec 09 '19 at 15:31

0 Answers0