0
votes

My use case is notification service implementation in our project.

We have used spring with jms and its working fine with rest services. Able to send message to queue from one application and receive a message from queue in another application using JMSTemplate's convertAndSend(), convertAndReceive() functions.

Now I want to do this using spring integration's java dsl approach. We did a sample by using Jms's inboundGateway() and outboundGateway() in single application with ActiveMQ.

How to use spring integration's java dsl in different application for only sending/receiving messages?

Here is my code,

@Bean
public IntegrationFlow jmsInboundFlow() {
    return IntegrationFlows
            .from(Jms.inboundGateway(this.connectionFactory)
                    .destination("pan.outbound"))
            .transform((String s) -> s.toUpperCase())
            .channel("in-bound-request-channel")
            .get();
}

@Bean
public IntegrationFlow jmsOutboundGatewayFlow() {
    return IntegrationFlows.from("out-bound-request-channel")
            .handle(Jms.outboundGateway(this.connectionFactory)
                        .requestDestination("pan.outbound"))
            .log()
            .bridge()
            .get();
}

@MessagingGateway
interface EchoGateway {

    @Gateway(requestChannel = "out-bound-request-channel")
    String send(String message);

}
1
Perhaps this Spring Boot is helpful: spring.io/guides/gs/messaging-jmswwerner
Thanks @wwerner. We did that way only. We have to do with spring integration way.Alexpandiyan Chokkan
If you have it working in a single application, exactly what is preventing you from splitting it up into 2 applications? It should be simple.Gary Russell
@GaryRussell Please look @ my source and it's working fine. But it works as a single flow. I am able to access the outbound through gateway using rest service. How will access inbound alone?Alexpandiyan Chokkan

1 Answers

1
votes

You have only to split configuration - JMS inbound adapter in one application and JMS outbound in second. The way is exactly the same as in one application ? (Maybe I missed some information?)