Question

I need to implement something like this:

<from uri="direct:pewpew" />
<doMegaWork status="Busy" message="Don't push on me!">
<to uri="direct:next"/>

I still did not find the same problem (much less a solution) on Google. Maybe someone knows how to do this?

Was it helpful?

Solution

Custom tags and/or namespaces are not (yet) supported by Camel (and perhaps it will never be?).

I see following different solutions to encapsulate reusable processing steps:

  • Write a separate reusable route. I guess this is the simplest solution and the standard way to do it.
  • Write a processor/bean/service that encapsulates the whole processing.
  • Include a full context into your route using the Camel context component. First, you add a Camel context to the registry:

    registry.bind("accounts", myAccountContext);
    

    Then you use the context in your route:

    <from uri="accounts:invoice"/>
    
  • Write a component as described here.

OTHER TIPS

Camel is a domain specific language - "Concise Application Message Exchange Language".

The idea is not to extend it with custom language elements, that's handled centrally in the core. The idea is to extend it by processors, components, beans and so forth.

The reason is pretty similar to why you don't extend Java with a keyword, say megawork{ ... }. Keywords or XML tags are part of the core language.

Other than that, it's probably rather complex technically to introduce custom elements, as the XML DSL is part of a schema that has to be updated with extensions an so forth.

That said - you can always fork Camel and build your own set of DSL methods, but you will have to maintain that copy yourself. Unless the DSL entries does not fit in the general case and are contributed back to (and approved by) the Camel Community.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top