3

I currently have a set of ERP style web applications build on top spring 3. The application is deployed into tomcat 7.

The system developed some time ago without a cleanly defined architecture. Each Application has 3 parts (as sub projects). API: Defining Models and Interfaces, IMPL: The Service Layer, and the WEB.

Current layout of system is as below.

enter image description here

Financial API+IMPL is included to Inventory module for achieving transaction management. We previously tried to separate inventory and financial into different Web apps by using REST calls but faced issue with transaction management. What we are currently doing is @Autowiring the financial Impl directly to Inventory services. For instance, When a Sale invoice is made, both financial and inventory operations must be in the same transaction.

Now, as already expected, issues with this approach pops up. Inventory system is super heavy as needs to boot a duplicate Financial Layer.

I guess introducing a Messaging Middleware like HornetQ or ActiveMq would be the best thing to do here as below.

enter image description here

My questions are:

  1. How can I achieve centralized transaction management between Financial and Inventory?
  2. Is there a benefit here if I use a Java EE Server like jBoss?
  3. If I move one of the application into another jboss instance running in another server, Can I still have centralized transactions?
Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Firdous Amir
  • 1,297
  • 5
  • 21
  • 39
  • #firdous-amir, did you find any solution for the problem? – veysiertekin Mar 04 '15 at 19:36
  • Not specifically. There are many ways to solve this problem however I'm still waiting for the best approach. – Firdous Amir Mar 09 '15 at 01:08
  • Example: operation X on Inventory needs 2 inserts to Postgres. Code for one insert in in Inventory, code for second instert in is Financial. Operation X must be a transaction If Inventory calls Financial over REST it is not a transaction so REST is not solution. You included code from Financial to Inventory, it works but is heavy to boot. You want connect Inventory with Financial by ActiveMQ. But when Inventory in operation X will do insert to DB and send message to message queue, the transaction is completed. Second insert to DB is independent. Am I right that message queue is wrong idea? – michaldo Mar 14 '15 at 10:41
  • Not entirely. Quoting your 2nd and 3rd last sentences: The idea would be great if I can make the second insert part of the same originating transaction block by using some tool/library (XA? Atomikos?). Is human kind not there yet ? If its still a wrong idea, what's the right idea? BTW, "heavy to boot" is not just the reason. I'm building 2 more applications on top of inventory. and 2 more on top of the said 2. Hope you can think from there. – Firdous Amir Mar 14 '15 at 23:11
  • Typically the environment I dream will do: Operation X registers it's intention with a transaction coordinator sitting in some other place and starts transaction block, insert to inventory, send peer-to-peer synchonous message to MQ with reference to tx block and wait for the acknowledgement, financial get the tx reference and attaches it's insert into the same tx block and acknowledges, inventory get's it and asks the tx cordinator to commit everything. – Firdous Amir Mar 14 '15 at 23:28

0 Answers0