I'd like to know if it is possible to control transactions using Java Business Integration. For an instance, let's say I have a transaction that starts when I call a java method. This method calls a web service, that calls a legacy procedure (written in another language), where this transaction ends. Can I mark the points where I want to rollback if something wrong happens, using JBI, or even Web Services?
I think, your query can be split up into two parts:
Can I do web service transactions
The answer is Yes and No. Yes because, specifications are there and are at different stages of adoption and maturity. Let me provide you at least one link of interest: A comparison of Web services transaction protocols. I also said No because, the Transaction Managers and the libraries (.jar files available along with vendor's package) may support WS-TX again at verying levels, and hence it depends not only on your own domain but also on the domain of the foreign Web Service providers with which you want to interact with transactionally. So all of them are to be TX aware if your composed service has to be transactional.
Whether JBI supports Transactions
JBI provides enough clarity on the support of transactions. Let me reproduce something from the specification here:
Using JBI to compose services will often require the sharing of a transaction context between JBI engines/bindings. Such transactions can facilitate reliable operation of composed services. The unit of work in the NMR is a Message Exchange. This is also the unit of work when a transaction is being used. The NMR is considered to be transaction aware. If the NMR is told that the Message Exchange is being controlled by a transaction, the NMR will internally use the transaction, if required, and will pass the transaction context along with the Message Exchange.