Inboud gateway:
If it's a MessagingGateway injected into your code, you can simply start your transaction at the gateway and, since all channels are direct, the entire flow will run in the same transaction. Simply annotate your gateway method with @Transactional
and add
or @EnableTransactionManagement
to your context (and a transaction manager).
Or you can start your transaction even earlier if you want other stuff in the transaction...
@Transactional
public void foo() {
...
Object reply = myGateway.exchange(Object foo);
...
}
Just be sure to invoke foo()
from another bean so that the class containing foo()
is wrapped in a transaction proxy (by @EnableTransactionManagement or
).
If it's a gateway such as an http inbound gateway, add an @Transaction
al gateway after the inbound gateway to start the transaction. (Add a service-activator that ref
s a
that exchanges Message>
and is annotated with @Transactional
).