Synapse vs Camel
I had the opportunity of listening to my friend Bruce Snyder talk about Apache Camel during his talks on ActiveMQ/ServiceMix at the Colorado Software Summit 07. There was also some discussion on Camel on the Apache Synapse mailing list recently. I thought of replying to the thread comparing the two based on it’s routing and mediation aspects. In the process I decided to write a blog post instead. If I have misunderstood any Camel feature/architectural detail, please let me know and I will post a correction. Note this is not an in depth analysis, neither a verdict on either project. Readers should do their own research and come to conclusions.
- Both Synapse and Camel have similar intents as Integration, Mediation and Routing Engines.
- Synapse also positions itself as an ESB, treating your entire network as the bus.
- Camel/ServiceMix is advertised as an ESB.
- Both have routing,transformation,mediation,enrichment,validation, logging ..etc.
- Initially Synapse was more focused on Web Services mediation. Since then, it has moved out of the Web Services umbrella and is trying to position itself as a general purpose integration/mediation/routing engine.
- Synapse by design have a proper abstraction layer where you can adapt (implement) Synapse on top of any Environment. It is one of the least known aspects about Synapse. Most folks assume Synapse can only work on top of Axis2. I have implemented the Synapse environment interface inside the Apache Qpid broker to leverage its mediation/routing capabilities.
- Camel on the other hand was designed to work on different environments from the begining. Camel can be used inside ServiceMix, ActiveMQ etc.
I haven’t experimented enough with Camel to compare performance, flexibility,extensibility or robustness with Synapse. Perhaps that would be an interesting topic to touch sometime later
- The Synapse messaging model is based on SOAP. The current implementation of Synapse is powered by Axis2 and takes any type of non SOAP message and creates a fictitious SOAP message and pumps it through the Synapse engine.
- Camel has a neutral messaging model which I think is nice.
- However you can implement your own Synapse MessageContext as well. I have created an AMQP based messaging model for Synapse for my work on embedding Synapse as an AMQP Exchange.
- Synapse could also use generics to make it’s messaging model neutral. (I hope to make a proposal to this effect after my AMQP work).
Synapse Configuration vs Camel Context
- Both use very similar models for representing a runtime instance of the rules/endpoints/registry ..etc.
- Synapse has a XML based DSL for configuration.
- Camel has a java and XML based DSL for configuration. You can use Spring to configure the Camel Context as well.
- You can also use Synapse programatically all though we haven’t provided a clear API as such to the user community. I think such an API would be a valuable addition to Synapse.
- There is support for configuring Axis2 with Spring, so I assume you can do the same for Synapse very soon (if not already).
- Both supports the concept of a Registry. The registry mechanism is pluggable in both projects.
Synapse Mediators vs Camel Processors
- A Synapse mediator, mediates a message as it passes through. It could be a transformation,validation, logging, audit ..etc.
- You can chain mediators into sequences and combine different sequences to create a processing engine.
- Camel processors does more or less the same.
- In both Synapse and Camel you can write you own mediator by implementing the Mediator or Processor interfaces respectively.
Synapse Script Mediator vs Camel Predicates/Expressions
Again they both provide pluggable scripting support. Not much to be said there.
- Both represents endpoints via URIs.
- Camel and Synapse supports more or less the same set of transports with the following exceptions.
- Camel has additional support for JBI,MINA, XMPP.
- Synapse supports Non blocking HTTP, AMQP (native not via JMS).
James Strachenanswered : “Camel supports non blocking HTTP too”
- In Synapse you could switch transport. Ex incoming is JMS and outgoing is HTTP (does Camel have similar support?).
James Strachen answered : “you can use Camel to do protocol switching from any protocol to any protocol with whatever EIP patterns in between (e.g. Message Translator etc).”
- Axis2 has support for XMPP, so if you really want to you could leverage that in Synapse.
Enterprise Integration Patterns
- Camel has support/good documentation for Enterprise Integration Patterns (based on Gregor Hopes book).
- All though Synapse doesn’t directly say so, you can easily do the same. In fact it does have some built in support similar to Camel for some patterns while other patterns can be done with a little bit of work. I may in the future compile an article on how to do so with Synapse.
- Camel has a programmable API as described above and I quite like it. It would be nice if Synapse can do something similar.
- Camel can be used inside ServiceMix, ActiveMQ ..etc. I have managed to embed Synapse inside an AMQP broker albeit with some code changes.
- It would be nice if you could embed the mediation engine in Synapse in other projects in a trivial way and also provide some documentation on it.
- One nice thing about Synapse is that it can be deployed as a module inside Axis2 or as war file inside Tomcat. Couldn’t find any documentation on easy Camel integration with Apache CFX
James Strachen answered : “its trivial to deploy Camel inside any Spring or WAR application or as an OSGi bundle, working great with Spring Dynamic Modules”
WS-* QoS Support
- Synapse has Built in support for WS-* QoS features (adding/removing security, reliability ..etc) when running on top of Axis2.
- Does Camel have a similar strategy with it’s Apache CXF support? ( I couldn’t find any information in the Camel site about this)
James Strachen answered : yes Camel has a similar WS-* strategy; using CXF to support the SOAP/WS-* protocols on any endpoint
Throttling/Load balancing/Policy based access and failover support for endpoints
- Synapse has good support for applying throttling , failover support and load balancing to endpoints.
- Synapse also can apply policies to enforce restrictions for better manage your endpoints.
- Not sure if Camel has any support for this area.
James Strachen answered : “yes Camel has support for load balancing, throttling, resequencing etc. See http://activemq.apache.org/camel/enterprise-integration-patterns.html”
- Synapse allows mediator state to be replicated across the cluster.This is based on the Axis2 clustering support.
- This is nice when you want to implement stateful mediators, like a session mediator.
- Again haven’t come across any documentation in Camel on this area.
James Strachen answered : “for stateful replication, we rely on ActiveMQ’s Message Groups feature or using EJB3”
- Synapse can covert from one message format to another via built in support for POX, SOAP and JMS.
- Camel provides a Type Converter interface (and some default implementations) to convert message payloads from one type to another when routing.
- Similarly in Synapse, for other payload types you could write a custom mediator to do the job.
- Also using the transport switching mechanism you can do some trivial things like converting a Qpid/AMQP message to an ActiveMQ message using the JMS transport. Sort of like a message bridge.
Both projects seems interesting and has some overlapping features, but different direction/focus and thought process behind them. IMHO it is nice to have choices in open source. Each community can learn from each other and strive to provide a better experience to the end user.