Получение сообщений HL7 с использованием Netty4

Я работаю над проектом для получения сообщений HL7 через MLLP с использованием MINA2. Я использую Apache Camel. Это мой код:

import com.atlas.core.routes.BaseRoute;

public class SampleRoute extends BaseRoute {
    @Override
    public void runRoute() {
        from ("mina2:tcp://<ip>:<port>?textline=true&codec=#hL7MLLPCodec")
            .startupOrder(997)
            .multicast()
            .beanRef("respondACK", "processMessage")
            .end();
    }
}

В классе объявления бина у меня есть:

import com.atlas.core.bootstrap.AtlasCamelConfig;

@Configuration
public class HL7IntegrationConfiguration extends AtlasCamelConfig {
    @Bean
    public RespondACK respondACK() {
        return new RespondACK();
    }

    @Bean
    public HL7MLLPCodec hL7MLLPCodec() {
        HL7MLLPCodec hL7MLLPCodec = new HL7MLLPCodec();
        hL7MLLPCodec.setCharset("iso-8859-1");
        return hL7MLLPCodec;
    }
}

Вот код для получения сообщения от конечной точки:

String body = exchange.getIn().getBody(String.class);
System.out.println(body);

Когда я отправляю сообщения, используя веселье, чтобы снимать сообщения, это не работает. Это исключение, которое я получаю:

WARN  | -- | 2015-10-26 11:28:42,387 |org.apache.camel.component.mina2.Mina2Consumer$ReceiveHandler |  | Closing session as an exception was thrown from MINA
WARN  | -- | 2015-10-26 11:28:42,388 |org.apache.mina.core.filterchain.DefaultIoFilterChain |  | Unexpected exception from exceptionCaught handler.
org.apache.camel.CamelException: org.apache.mina.filter.codec.ProtocolEncoderException: ca.uhn.hl7v2.HL7Exception: Can't encode message: MSH-1 (field separator) is missing
    at org.apache.camel.component.mina2.Mina2Consumer$ReceiveHandler.exceptionCaught(Mina2Consumer.java:381) ~[camel-mina2-2.15.2.jar:2.15.2]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.exceptionCaught(DefaultIoFilterChain.java:824) ~[mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextExceptionCaught(DefaultIoFilterChain.java:590) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1100(DefaultIoFilterChain.java:48) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.exceptionCaught(DefaultIoFilterChain.java:933) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:93) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63) [mina-core-2.0.9.jar:na]
    at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:769) [mina-core-2.0.9.jar:na]
    at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:761) [mina-core-2.0.9.jar:na]
    at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:703) [mina-core-2.0.9.jar:na]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_65]
Caused by: org.apache.mina.filter.codec.ProtocolEncoderException: ca.uhn.hl7v2.HL7Exception: Can't encode message: MSH-1 (field separator) is missing
    at org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:337) ~[mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:625) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:48) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:953) [mina-core-2.0.9.jar:na]
    at org.apache.mina.filter.executor.ExecutorFilter.filterWrite(ExecutorFilter.java:613) ~[mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:625) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1500(DefaultIoFilterChain.java:48) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.filterWrite(DefaultIoFilterChain.java:953) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.filterWrite(DefaultIoFilterChain.java:877) ~[mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callPreviousFilterWrite(DefaultIoFilterChain.java:625) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireFilterWrite(DefaultIoFilterChain.java:618) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:502) ~[mina-core-2.0.9.jar:na]
    at org.apache.mina.core.session.AbstractIoSession.write(AbstractIoSession.java:447) ~[mina-core-2.0.9.jar:na]
    at org.apache.camel.component.mina2.Mina2Helper.writeBody(Mina2Helper.java:49) ~[camel-mina2-2.15.2.jar:2.15.2]
    at org.apache.camel.component.mina2.Mina2Consumer$ReceiveHandler.messageReceived(Mina2Consumer.java:431) ~[camel-mina2-2.15.2.jar:2.15.2]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:854) ~[mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:48) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:943) [mina-core-2.0.9.jar:na]
    at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:74) [mina-core-2.0.9.jar:na]
    ... 5 common frames omitted
Caused by: ca.uhn.hl7v2.HL7Exception: Can't encode message: MSH-1 (field separator) is missing
    at ca.uhn.hl7v2.parser.PipeParser.doEncode(PipeParser.java:627) ~[hapi-base-2.2.jar:na]
    at ca.uhn.hl7v2.parser.Parser.encode(Parser.java:276) ~[hapi-base-2.2.jar:na]
    at ca.uhn.hl7v2.parser.PipeParser.encode(PipeParser.java:1003) ~[hapi-base-2.2.jar:na]
    at ca.uhn.hl7v2.model.AbstractMessage.encode(AbstractMessage.java:207) ~[hapi-base-2.2.jar:na]
    at org.apache.camel.component.hl7.HL7MLLPEncoder.encode(HL7MLLPEncoder.java:54) ~[camel-hl7-2.15.2.jar:2.15.2]
    at org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:306) ~[mina-core-2.0.9.jar:na]
    ... 24 common frames omitted

Если у кого-то есть какие-либо решения, они будут очень признательны.

0 ответов

Другие вопросы по тегам