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.

Intent/Problem Space

  • 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

Messaging Model

  • 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.

Endpoints/Transports

  • 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.

Embedability

  • 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”

Clustering support

  • 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″

Payload Conversion

  • 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.

Summary
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.



7 Comments

  1. Great article! BTW a couple of corrections on the Camel side of things…

    * 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). e.g. from(“activemq:SomeQueue”).to(“ftp://somehost/somedir”);
    * Camel supports non blocking HTTP too BTW :)
    * its trivial to deploy Camel inside any Spring or WAR application or as an OSGi bundle, working great with Spring Dynamic Modules
    * yes Camel has a similar WS-* strategy; using CXF to support the SOAP/WS-* protocols on any endpoint. e.g. from(“soap:activemq:SomeQueue”).to(“soap:xmpp:localhost”) etc
    * yes Camel has support for load balancing, throttling, resequencing etc. See http://activemq.apache.org/camel/enterprise-integration-patterns.html
    * for stateful replication, we rely on ActiveMQ’s Message Groups feature or using EJB3
    * for payload conversion Camel has a large range of Data Formats as well as a sophisticated type conversion library

  2. BTW a massive difference between Synapse and Camel is that Camel has been designed from the ground up to work great inside a JMS broker or a JBI based ESB or a web services stack; so Camel has amazing JMS and JBI support.

  3. rajith wrote:

    James,

    Thanks for the comments. I appreciate it.
    I will update the article with the points you mentioned.

    Regards,

    Rajith

  4. Rajith,
    how are you? I just wanted to say this was a nice write-up – it is helpful to see a comparison from someone who has taken a look at both Camel and Synapse.

    Debbie

  5. William Henry wrote:

    Really useful comparison Rajith. IT would be worth updating every 6 months or so. :-) Or for major changes.

    William

  6. Dmitry wrote:

    We where unlucky ones to bring synapse 1.2 into production as a message router and file transfer mechanism.

    It is really hard to express our frustration and suffer we had and still having with it. We view Synapse project as a mistake from the beginning which shouldn’t be existing at the first place. WSO2 1.7.1 which we actually running is nothing more then a prove of concept.

    We had some cases message been lost _completely_, even in the archive folder, we had a case an archiving feature of VFS deleted all files it can from archive folder due to not obvious misconfiguration (trailing question mark in Uri string). Some exception during mediation eg. JMSSender not even fires a fault sequence resulting message just gone forever. It has no transactional support, once it gets the message off the queue you are on your on in the ocean alone with your luck.
    Smooks mediator is not working, authors admitted its a POC, failover endpoint will fail on JMSSender exception resulting message been not delivered. If proxy is off on sturtup, the receiving vfs transport will polls directory anyway resulting in complete unrecoverable loss of file due to the proxy service is “attempting to access an inactive service”. WebSphere JMS link suddenly stopped working with exception in BaseUtils.handleLegacyMessage resulting in unrecoverable loss of JMS message.
    Is short, it full of holes, very disanointing and nothing but a funny demo.

    In contrary Camel looks solid, powerful and compact but has no GUI. We hope to have time to migrate to Camel.

  7. Dmitry

    Please can you contact me. I’d really like to help resolve your issues and change your experience with Synapse.

    Paul Fremantle pzf@apache.org
    Apache Synapse