Reputation: 3460
I'm currently configuring spring integration using spring-integration-dsl as follow
@Bean
public IntegrationFlow flow() {
return IntegrationFlows.from(inboundServer())
.transform(Transformers.objectToString())
.transform(...)
.route(...)
.transform(Transformers.toJson())
.channel(...)
.get();
}
@Bean
public PlatformTransactionManager transactionManager() {
....
}
I don't know how I can configure the flow to use the transaction manager I've configured.
Upvotes: 1
Views: 1310
Reputation: 121560
Actually, Spring Integration Java DSL supports all transaction features, which are available for the XML components.
Please, provide more info from where you want to start a transaction. And keep in mind that TX support is restricted to the Thread boundaries. So, you can start TX from the poller
or from the JMS(AMQP) Message Driven Channel Adapter.
Or use TransactionInterceptor
as an advice on any endpoint within the flow. But in this case the TX is restricted just only for the AbstractReplyProducingMessageHandler.handleRequestMessage
.
UPDATE
To start the TX for some part of flow isn't so standard task and it can be achieved as a unit of work
some transactional black box. For this purpose we have a component like Gateway
. So, you specify some interface, mark it with @MessagingGateway
, add @IntegrationComponentScan
alongside with @EnableConfiguration
and mark the method of that interface with @Transactional
. The requestChannel
of this gateway should send message to some separate flow with JDBC and Jackson conversion and wait for the result to continue in the main flow. The TX will be finished on the return from that gateway's method invocation.
And call that gateway as regular service-activator
from the .handle("myGateway", "getData")
Upvotes: 2