I have the below integration flow defined in my project
///
public IntegrationFlow acarsEventFlow() {
return IntegrationFlows
//.from(Jms.messageDrivenChannelAdapter(this.acarsMqListener)) //Get Message from MQ
.from(org.springframework.integration.jms.dsl.Jms.messageDrivenChannelAdapter(
org.springframework.integration.jms.dsl.Jms.container(this.acarsMqConnectionFactory, this.acarsQueue)
.transactionManager(transactionManager(this.acarsMqConnectionFactory))
.get()))
.wireTap(ACARS_WIRE_TAP_CHNL)
.transform(agmTransformer, "parseXMLMessage") //
.handle(acarsProcessor, "pushRawMessage") // (1)Call web service to push the message payload and if it fails then don't commit the transaction and rollback the message
.transform(agmTransformer, "populateSmi")
.filter(acarsFilter,"filterMessageOnSmi") //
.transform(agmTransformer, "populateImi") //
.filter(acarsFilter,"filterMessageOnSmiImi") //
.transform(acarsProcessor,"processEvent") //
.publishSubscribeChannel(pubSub -> pubSub
.subscribe(flow -> flow
.bridge(e -> e.order(Ordered.HIGHEST_PRECEDENCE))
.enrichHeaders(h -> h.headerExpression(KafkaHeaders.MESSAGE_KEY, "payload.flightNbr")) //Add flight number as key
.transform("payload.message") // publish the transformed message
.handle(Kafka.outboundChannelAdapter(kafkaTemplate).topic(acarsKafkaTopic))) //publish to kafka
.subscribe(flow -> flow
.channel(UPDATE_DATA_STORE_CHNL)))
.get();
}
///
I am getting a message from a MQ, started a transaction manager to ensure that message is rolled back unless it is processed. Now in one of the handle method # pushRawMessage() [please refer to the comment (1)Call web service to push the message payload in the above snippet] I need to call a webservice. Currently I am just calling the webservice from inside the handler - pushRawMessage(). Is it a good idea to introduce a Messaging Gateway to call the 3rd party web service? if we introduce a mEssaging Gateway then how can we ensure that the original message is rolled back when the webservice is down?