Announcement Announcement Module
No announcement yet.
Spring Integration - Transaction management within different Services Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Integration - Transaction management within different Services

    Hi Guys,
    I am new to this Spring Integration and enterprise integration patterns and had to chance to go through this spring integration and I found it’s really helpful when come to loosely coupled module level interaction. We have a legacy java web application and we are planning to rewrite/ modify it to loosely coupled modules and there is a requirement to integrate our system with external systems when needed. But I have few concerns over transaction management.

    for an example we have following requirement. please have look at following image


    our system has4 modules. Each module is responsible for doing one specific task. Once Module1 finish its task we need to call Module2, Module3 and module4 to do their own tasks. But all these things should run with in one transaction. (each module has own persistence layer.) For the moment we have spring jdbc templates and we use spring transaction management to handle this scenario. But if we introduce spring integration to this, is there any way of preserving this one transaction functionality. It’s all about channels and passing control to end points.
    Can you guys please help me to figure it out the best way of doing this?

    Attached Files

  • #2

    I can suggest you to solve your task with XA Transaction Manager and single-thread process. It can be achieved via DirectChannel as entry-point for all your modules. But keep in mind: all your persistence layers should be XA-Resources too.
    However if you start to use Messaging I recommend changing your mind and forget about XA and single-thread flows.
    Please, read this book: and also take a look into this article:
    In two words: Messaging is a bit different sight to the programming model than procedure model and even OOP at all. Messaging tries to reflect real world, which is asynchronous by the nature's laws and doesn't work in XA and clusters.

    So, welcome to the new universe of programming!

    Artem Bilan


    • #3
      Hello Artem,

      Nice explanation. i just realized the world of messaging. Thanks you very much. So is there any way of passing the exception back to main module if there is an error in one of the sub modules. i just read about error channel. can we use error channel to propagate the error back to main module?



      • #4

        can we use error channel to propagate the error back to main module?
        So, as I described above you should decide for yourself: will it be single-thead process or you can split it into some asynchronous sub-porecesses.
        If it will be single-thread, the error-channel doesn't help you: the Exception will be thrown to the caller and it will be enough just to catch it in the main point.
        But if you sub-flows are async you can use "error-channel" header of the Message and you end-up with an ErrorMessage on this channel. But it will work if all your modules are in the same ApplicationContext.
        If you split your application to separate modules, which may work on diferent machines, you must use some other mechanism - like DLQ on Messagin Broker.