It depends; if you are invoking the SI flow from Java, simply start the transaction before invoking the flow.
If you are using external integration (e.g. inbound http gateway), or you want to start the transaction further down the flow, simply introduce a transactional gateway into your flow...
Code:
public interface TransactionalGateway {
@Transactional
public MyResponseType sendInTx(MyRequestType requestPayload);
}
Code:
<!-- Start a database transaction NOW -->
<int:service-activator input-channel="my.inbound"
ref="inbound.tx.gateway" method="sendInTx"/>
<int:gateway id="inbound.tx.gateway"
service-interface="my.package.TransactionalGateway"
default-request-channel="my.tx.inbound"/>
If your downstream flow doesn't return a response, just return void in the Tx Gateway.
This will only work with downstream direct channels. Also, if you add an error-channel on the gateway (which works like a catch block), and you don't thrown an exception from the error flow, the transaction will be committed.