1

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?

Chris Barlow
  • 3,274
  • 4
  • 31
  • 52
okAndrew
  • 41
  • 1
  • 6
  • 1
    Out of curiosity: What is the requirement behind extending the Camel XML language? – Ralf May 14 '14 at 15:04
  • I can't answer for your question, because I did not find some info about this on camel.apache.org too. Actually I need something like jsp custom tags. – okAndrew May 14 '14 at 15:39
  • 2
    You don't find anything because this is a strange thing to do. That's why I am asking what your requirement is. Maybe we can point out how to meet your requirement without extending the Camel XML language. Maybe [this link](http://stackoverflow.com/questions/3392402/how-do-i-extend-a-base-schema-with-custom-elements-while-remaining-open-to-chang) helps as well? – Ralf May 14 '14 at 15:42
  • To be honest, this is my task. If there are no good solution of this problem - I will try to circumvent it. Thanks for the help! – okAndrew May 14 '14 at 17:14

2 Answers2

2

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.

Peter Keller
  • 7,526
  • 2
  • 26
  • 29
0

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.

Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84