You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ramon Buckland <ra...@thebuckland.com> on 2008/12/10 10:43:57 UTC

Design of a new component

Hi

I have a new component (foo) that I am about to start writing.

The component works by producing new mesages to a seperate route, based on
the message it receives, and then it responds once complete.

bar:    -->      foo:                      1. (*bar: sends a message to
foo:)*
                    foo: --> x to baz:   *2. (foo: produces x new messages)*
bar:   <--       foo:                      3. (foo: foo responds)

So .. an example of this route (in my head looks like)

from("bar:abc)
            .to("foo:component?routeTo=baz:defg")

from("baz:defg")
           .to(....)

Is there a better way to design this up ?


(What is this pattern called ?)
Just some thoughts.

regards

Re: Design of a new component

Posted by James Strachan <ja...@gmail.com>.
2008/12/10 Ramon Buckland <ra...@thebuckland.com>:
> Hi
>
> I have a new component (foo) that I am about to start writing.
>
> The component works by producing new mesages to a seperate route, based on
> the message it receives, and then it responds once complete.
>
> bar:    -->      foo:                      1. (*bar: sends a message to
> foo:)*
>                    foo: --> x to baz:   *2. (foo: produces x new messages)*
> bar:   <--       foo:                      3. (foo: foo responds)
>
> So .. an example of this route (in my head looks like)
>
> from("bar:abc)
>            .to("foo:component?routeTo=baz:defg")
>
> from("baz:defg")
>           .to(....)

Yeah that looks good to me.  If there's not that much configuration in
foo other than the routeTo URI, you could use a URI format more like

to("foo:baz:defg")

i.e. use the rest of the URI after the "foo:' scheme to denote the
routeTo URI. No biggie though


> Is there a better way to design this up ?

There are certainly times when things are a little grey and could be a
transformer/bean, endpoint or new pattern :).

e.g. you could write foo as a bean

public class Foo {

  @Produces(uri="baz:defg")
  ProducerTemplate template;

  public Object foo(@Body String xml) {
      for (Object m : x) {
        template.sendBody(m);
      }
      return someOutput;
  }
}

If in doubt having things as a component/endpoint tends to be a
slightly preferable; as folks can then use URIs to wire up the
endpoints - particularly if you find that you need multiple inputs and
outputs into it. i.e. you wanna use the DSL to route messages into
something and out of something.

But in these grey areas it often just comes down to personal preference.

Ideally I guess we should be able to take that bean above - and treat
it from the DSL as an endpoint (which I think would kinda work right
now). e.g. if Foo were registered as "foo" in spring you could just
route to uri "foo" in the DSL

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/