使用 HL7 v2 文件后,我试图将它们编组为 HAPI HL7 对象。路线示例将是:
from("file:C:\\routes\\in").unmarshal(new HL7DataFormat()).log("Success!");
不幸的是,我得到了例外:
ca.uhn.hl7v2.parser.EncodingNotSupportedException: Determine encoding for message. The following is the first 50 chars of the message for reference, although this may not be where the issue is: MSH|^~\&|...
我发现每条被解析的消息前面都有 \u000B 符号,这导致解析器无法找到“MSH”标头。
当然,我可以通过简单的字符串操作来修复它,例如:
from("file:C:\\routes\\in")
.convertBodyTo(String.class)
.transform().simple("${in.body.trim()}")
.unmarshal(new HL7DataFormat())
.log("Success!");
但在我看来,这不是最好的解决方案。我发现,如果使用 MLLP 协议,相同的符号在消息的前面,HL7 编解码器应该处理它。http://camel.apache.org/hl7.html
问题: 是否可以使用 HL7Codec 之类的文件或 FTP 组件来处理转换为字符串/解析?