camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Johnson <>
Subject Re: Camel BeanIO catch and ignore InvalidRecordException
Date Wed, 04 May 2016 14:53:17 GMT
I'm not sure if this would work for your specific case but recently I
created an emitter that took a GenericFile from Camel, read the BeanIO
format in from the bundle, and then read record at a time.  I wasn't
looking to catch malformed records so the method throws any exceptions. The
init method has that odd looking check from the actual method called from
Camel because I'm in blueprint/OSGi and if I called the init from Blueprint
the classloader context wasn't right.   The way that is used in a Camel
routes is.  The reader is just sending those to the processQueue which I
inject into the bean with @EndpointInject.  In this case I use a SEDA queue
but you could use pretty much anything.  If you put a try catch around the
read you could have a second errorQueue that you send the results to.  I'm
not sure what you'd get exactly but it should put you on your way.

        <!-- Publish beans to the process queues based on input file -->
        <route id="process.ahs.paymentech.route">
            <from uri="{{batch.local.inbox}}" />
            <bean ref="beanProducer" method="publishBeans" />

    public void init() throws IOException {

        // create a StreamFactory
        factory = StreamFactory.newInstance();
    //The format in Blueprint is in the resources directory in Maven which
ends up in the root of the jar file.  I create a subfolder in resources for
my data formats.

        InputStream inStream = new"dataformats/my-format.xml"));



    public void publishBeans(GenericFile file) throws IOException
        if(!initialized) init();
        BeanReader in = factory.createReader("myFileFormat",
        Object o;

        while ((o = != null) {





On Wed, May 4, 2016 at 7:46 AM, hong5858 <> wrote:

> by catching the error records I meant to get a chance to write them to a
> file.
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message