HL7 client
John DeStefano
jdestef at harthosp.org
Thu Apr 15 11:11:22 EDT 2010
Hi,
We are working on HL7 connectivity for the JBoss ESB. We have implemented a
simple frame based server in netty to receive HL7 messages using MLLP
protocol. We are working on the client side now. The client initiates a
session with the server and sends an HL7 formatted message to the server.
The server responds with an ACK message which indicates that the message was
received and a code tells the status of the message.
Out issue is around how to synchronize the sending of the message with the
receiving of an ACK. Currently we send a message as follows:
// Sends message
lastWriteFuture =
channel.write(message.getBody().get(Body.DEFAULT_LOCATION));
// wait for it t complete
completed =
lastWriteFuture.awaitUninterruptibly(responseReceiveTimeoutMillis);
If the send completed ok the we wait for the response:
while (true) {
if (!channel.isConnected()) {
throw new Exception("ACK channel has been closed.");
}
// Read the ChannelLocal variable.
// This is where we put the ack message.
// See HL7ClientUpStreamHandler
// If the clientACK is not null put it in the message
// Remove the channel from the ChannelLocal variable
// and wait for the next one
String ack = ClientAckState.clientACK.get(channel);
if (ack != null) {
ClientAckState.clientACK.remove(channel);
message.getBody().add(ackLocation, ack);
break;
}
}
In the SimpleChannelUpStreamHandler we put the received ACK in a
ChannelLocal variable:
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
if (e.getMessage() instanceof String) {
ClientAckState.clientACK.set(e.getChannel(), (String) e.getMessage());
}
}
Is this the right way to handle the synchronization of sending a message and
wating for the reply?
Thanks
--
View this message in context: http://n2.nabble.com/HL7-client-tp4908092p4908092.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list