Using webservices to connect front-end and back-end, a good idea?
This project r开发者_如何学JAVAuns the front-end web server on one JVM and the back-end on another. In order for the web to call any biz-logic methods in the back-end, it has to make that call over web services (JAX-WS).
I can understand that for parts of the application that will need to integrate with other systems, distributing a service through the use of webservices is a good idea, but I have yet to see a system where every biz-logic call is exposed as a webservice.
Performance? Transactions? In general a good idea?
I'm a big fan of the KISS principle (Keep It Simple Stupid). There would need to be a compelling reason to split the application between JVMs and create a WS interface layer. Possible reasons include the need to scale the presentation tier differently from the business tier. JVM tuning differences, such as a different garbage collection algorithm. Or the need for a DMZ.
If a compelling reason does not exist, separating adds unneeded complexity that will quite likely cause headaches from development to operations.
And the need to expose business logic to other applications does not represent a compelling reason to split the tiers between JVMs. The business logic can still be exposed via WS for external apps, while your presentation tier physically resides in the same JVM and references the business tier directly via the POJO implementation of the business service. While there would be a web service wrapper around the POJO implementation, exposing the business services as web services.
In general this approach is a good idea if your "backend" (I'd call them "services") are intended to be re-used by other applications.
Just a note though, web services is just the actual transport/message interface between the systems. There are plenty of other options here to handle the interface between the two - Java RMI, Spring remoting, REST, etc. A well designed services solution will be agnostic between which messaging technology you use (and should be able to support more than one).
Your idea of splitting the application is not so uncommon. When most of your services are intended to be reused, its a good idea to deploy them as a separate application and decoupling it so that other systems can access them easily. It will defiantly has some impact on performance but technically it should not have any impact on transactions(unless you need to have transactions across service calls where you can use WS-Reliability).
精彩评论