The problem was related to the MLLP message created and sent through mina2 listener. In camel, I defined the route in this way:
<route>
<from uri="mina2:tcp://localhost:2576?sync=true&codec=#hl7codecDebug&noReplyLogLevel=DEBUG" />
<to uri="file://HL7Messages?fileName=${file:name.noext}&fileExist=Append"/>
<log message="MINA2 DEBUG Message received" loggingLevel="INFO" />
</route>
The problem, basically was on camel-hl7 codec:
<bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
<property name="charset" value="UTF-8" />
</bean>
Of course I wasn't able to see actually the content of message so, I just added some debug output rows on HL7MLLPCodec classes to help me to understand what was the problem.
Now switching the codec from official apache to my debug version I'm able to see all bytes sent to mina2 before they're decoded and redirected to next route step.
Just to recap, (I'm quite sure I'll re-read this post again and again in the future), these are the bytes required to encapsulate an HL7 message:
startByte 0x0b The start byte spanning the HL7 payload.
endByte1 0x1c The first end byte spanning the HL7 payload.
endByte2 0x0d The 2nd end byte spanning the HL7 payload.
To start the camel context, I use this:
Main main = new Main();
main.setApplicationContext(new FileSystemXmlApplicationContext("src/test/resources/META-INF/spring/LOCALHOST-camel-context.xml"));
main.setDuration(-1);
main.run();
main is an instance of class org.apache.camel.spring.Main