1

HAPIを使用して、HL7v2 メッセージング用の単純なクライアントとサーバーを作成しています。クライアントとサーバーの両方が動作しているように見えますがINFO、確認メッセージを送信する際にソケットの早期終了に関するレベルの警告を発行しています。

サーバーは次のものを生成します。

2012-09-17 13:36:38,715 INFO  pool-1-thread-1 [MinLLPReader] End of input stream reached.
2012-09-17 13:36:38,718 INFO  pool-1-thread-1 [Receiver] Closing connection (no more messages available).

そして、クライアントの補足エラー:

2012-09-17 13:36:38,715 INFO  pool-1-thread-1 [MinLLPReader] SocketException on read() attempt.  Socket appears to have been closed: socket closed 
2012-09-17 13:36:38,716 INFO  pool-1-thread-1 [Receiver] Closing connection (no more messages available).

これらのメッセージが表示されないようにするにはどうすればよいですか?

確認応答を送信するサーバー コードは次のようになります。HL7v2 仕様の「興味深い」解釈のおかげで、考えられるすべてのメッセージ検証コンポーネントを無効にする必要があったことに注意してください。

// HAPI server component
final LowerLayerProtocol llp = LowerLayerProtocol.makeLLP();
final PipeParser parser = new PipeParser();
final SimpleServer server = new SimpleServer(12345, llp, parser, false);

// registers an admission message handler
server.registerApplication("ADT", "A01", new Application() {

    @Override
    public Message processMessage(final Message message) throws ApplicationException, HL7Exception {

        final PipeParser pipeParser = new PipeParser();
        pipeParser.setValidationContext(new NoValidation());
        final String encoded = pipeParser.encode(message);

        final AbstractMessage adtMessage = new ADT_A01();
        adtMessage.setValidationContext(new NoValidation());
        adtMessage.parse(encoded);

        return (ACK) DefaultApplication.makeACK(adtMessage);    
    }

    @Override
    public boolean canProcess(final Message message) {
        return true;
    }
});

// tell HAPI not to try to validate incoming messages
server.registerConnectionListener(new ConnectionListener() {    

    @Override
    public void connectionReceived(final Connection c) {
        c.getParser().setValidationContext(new NoValidation());
    }

    @Override
    public void connectionDiscarded(Connection c) {
        // nothing
    }
}); 

server.start();

そしてクライアント:

ConnectionHub hub = null;
Connection conn = null;

try {

    final ADT_A01 adtMessage = new ADT_A01();
    adtMessage.parse(message); // message content as a string

    hub = ConnectionHub.getInstance();
    final PipeParser connParser = new PipeParser();
    connParser.setValidationContext(new NoValidation());

    conn = hub.attach(host, port, connParser, MinLowerLayerProtocol.class);
    final Initiator init = conn.getInitiator();

    final Message response = init.sendAndReceive(adtMessage);
    final String responseString = connParser.encode(response);
    System.out.println("Received response:\n" + responseString);

}
finally {

    if (conn != null) {
        hub.discard(conn);
    }

    ConnectionHub.shutdown();
}
4

1 に答える 1

0

使用するロガーの実装がわからない...あなたが言及した2つのクラス(ca.uhn.hl7v2.app.Receiver、ca.uhn.hl7v2.llp.MinLLPReader)の場合、ログレベルをWARNに設定するだけで、メッセージが表示されます消える。

キリスト教徒

于 2012-09-30T18:57:07.427 に答える