2 Replies Latest reply on Jul 10, 2009 10:28 AM by ryanhos

    ContentBasedRouter vs ServiceInvoker

      I have a simple use case where the message contains one of several (java) types. I'd like to route to different services, depending on type.

      I looked at the ContentBasedRouter, but am tempted to just do an instanceOf in my action and route with a ServiceInvoker.

      Is there an advantage to one approach over the other? Using a ServiceInvoker looks much simpler in my case - no drools files, etc.

        • 1. Re: ContentBasedRouter vs ServiceInvoker

          Any thoughts? Does my question make sense?

          • 2. Re: ContentBasedRouter vs ServiceInvoker
            ryanhos

            It was a developer wiser than I who once said,

            "If you ever find yourself attempting to write:

            if (obj instanceof Foo)

            smack yourself and reexamine the design of your program."

            That being said, the rules engine (that is, the CBR) used in the simple manner you describe is just an expensive, glorified instanceof. It is only after the routing rules multiply and become more complex that you begin to realize the efficiencies that a rules engine can provide. If you expect to eventually encounter this complexity, go ahead and begin using the CBR today.