gpt4 book ai didi

java - 如何修复 HAPI 早期连接关闭警告?

转载 作者:行者123 更新时间:2023-12-01 05:07:46 24 4
gpt4 key购买 nike

我正在使用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();
}

最佳答案

不确定您使用哪种记录器实现...对于您提到的两个类(ca.uhn.hl7v2.app.Receiver、ca.uhn.hl7v2.llp.MinLLPReader),只需将日志级别设置为 WARN,消息就会消失。

基督教

关于java - 如何修复 HAPI 早期连接关闭警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12460390/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com