You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Christopher Piggott <cp...@gmail.com> on 2015/04/06 15:03:54 UTC

Multiple outputs from a custom component

I have been reading mailing lists and forums trying to figure this out but
haven't really come up with a clean solution.

I have a zigbee ZCL component I wrote for Camel that parses out a few
ZCL/ZDO messages.  One of them is an attributes report, which contains a
list of attributes, each with:

- A numeric ID indicating which parameter
- A one-byte type ID which tells you if the value is a float, int, string,
whatever
- A value, which could be of various types

To use these components I do something like this:

    from("seda:xbeeInput")
        .to("xbee://localhost")
        .to("zcl://localhost")
        .to("zclSplitter://localhost")
        .to(xmppUri);


The first four steps work great - the xbeeInput comes from the serial
port, sends the message to xbee decoding, and if that is successful it
parses it into a ZCL message containing some number of attributes.
The splitter is where I'm really having the problems.  I'd really like
it to be just another Endpoint/Component/something in the library so
that the user doesn't have to screw around configuring custom
splitters or beans.


I have tried a number of things to solve this, but I'm getting so far
deep in the weeds that I feel like I'm on the wrong track.


Does anybody have an example they can show me of a custom Producer (or
something more appropriate?) that can act like a cusom splitter,
replacing whatever Exchange comes in with a series of smaller
Exchanges?  I'm looking for something like:

    public class ZclSplitter exends DefaultProducer {

        public List<Exchange> process( Exchange originalExchange ) {

            ....

        }

    }


How is one supposed to accomplish this with a component?


--Chris