camel-bindy - How do I define if there are no body records during unmarshaling and marshaling

by 이성규   Last Updated May 16, 2019 00:26 AM

I have some records in files. There are header, body, and footer. In the some case, the file has all three type records. but, the file has only header and footer in another case.

I want to parse these file by using same data format.

Data Defined. (body)

@FixedLengthRecord(header=KRHeader.class, footer=KRTrailer.class)
public class KRFixedFormat implements Serializable {
    private static final long serialVersionUID = 1L;

    @DataField(pos=1, length=1, trim=true)
    private String sType; 
    ....

Data Defined. (header)

@FixedLengthRecord(length=39, paddingChar=' ')
public class KRHeader implements Serializable {
    private static final long serialVersionUID = 1L;

    @DataField(pos=1, length=1, trim=true, defaultValue="H")
    private String sType; 
    ....

Data Defined. (Footer)

@FixedLengthRecord(length=44, paddingChar=' ')
public class KRTrailer implements Serializable {
private static final long serialVersionUID = 1L;

@DataField(pos=1, length=1, trim=true, defaultValue="T")
private char sType;
    ....

If the file with only header and footer is cooming, application has generated exception like blow.

java.lang.IllegalArgumentException: No records have been defined in the file
at org.apache.camel.dataformat.bindy.fixed.BindyFixedLengthDataFormat.unmarshal(BindyFixedLengthDataFormat.java:250) ~[camel-bindy-2.23.1.jar:2.23.1]
at org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:69) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) ~[camel-core-2.23.1.jar:2.23.1]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) ~[camel-core-2.23.1.jar:2.23.1]

How do we implement to meet our business requirement?



Answers 1


Thank you for claus’ support. I will wait for implementation.

이성규
이성규
May 16, 2019 00:24 AM

Related Questions


Updated November 03, 2017 10:26 AM

Updated July 15, 2019 01:26 AM

Updated September 25, 2018 07:26 AM