I was wondering about the difference between composition with mediator and composition with BPEL. I think we can do everything with BPEL so what is the benefit of Mediator??
You have many tools to use in a composite, and they may overlap for some cases. Mediator is particularly useful for content based routing of events, and as a listener for events. BPEL of course offers more possibilties for business logic and would generally be suited to defining process logic. A more complex SOA composite likely includes both components and others as well.
Mediator serves the purpose of a bus. It can be best utilized when used for routing. It can do routing based on many parameters and the best part is, the routing rules can be modified at runtime, thus giving the flexibility to choose the target at any point in time.
It is a good practice to create a Mediator in all Composites even if the Composite has a single BPEL Process. The Mediator will help take care of additional operations that could be added to this Service in future.
Anything that does not belong to a process has to be extracted out and put in the Mediator. For example, if the process needs the data in a certain format then that transformation can be done at the Mediator or the OSB but not in the BPEL.