HL7 2.7 and Camel mina2

777 views Asked by At

Our customer changed the HL7 message format from 2.3 to 2.7 and I having some issue with new message format. Basically we was able to route message using mina2 protocols in this way:

<route>
<from uri="mina2:tcp://10.124.199.40:2575?sync=true&amp;codec=#hl7codec&amp;minaLogger=true" />
[...]
</route>

and it worked fine untile the upgrade of message standard. Indeed, changing the format from 2.3 to 2.7 it doesn't work, we get this DEBUG message:

 2014-01-13 10:15:57,361 DEBUG HL7MLLPDecoder [104]  - Start scanning buffer at position 0
 2014-01-13 10:15:57,361 WARN  HL7MLLPDecoder [122]  - Ignoring unexpected 1st end byte 28. Expected 2nd endpoint 
 2014-01-13 10:15:57,361 DEBUG HL7MLLPDecoder [56]  - No complete message in this packet

We are using HAPI as message parser and I'm afraid it should be the problem but, in this case, what I'm expecting is that Camel should be able to route the message though mina2 and, when we read HL7 message from our business classes catch an exception. But it doesn't, it seems that mina2 is not able to routes the message.

Any clue with that? Is it possible to capture the MLLP message before is parsed by mina2 just to be sure our customers are sending it in the right format?

I've also another question. I was trying to generate a very easy jUnit class to send a message to a String message but I don't know how to implement a MLLP message and, my question is: is it something that mina2 does (wrapping a String message to MLLP format) or something I've to do before send the HL7 message?

thanks, Andrea

1

There are 1 answers

0
Andrea Girardi On BEST ANSWER

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&amp;codec=#hl7codecDebug&amp;noReplyLogLevel=DEBUG" />
    <to uri="file://HL7Messages?fileName=${file:name.noext}&amp;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