HL7 client

"Trustin Lee (이희승)" trustin at gmail.com
Wed Apr 28 04:24:09 EDT 2010


Hi John,

It seems like you are spinning in the loop, which is inefficient.  I'd
use BlockingQueue instead of ChannelLocal.  Please refer to the
FactorialClient example, which uses LinkedBlockingQueue:

    http://is.gd/bL5iX

HTH,
Trustin

John DeStefano wrote:
> 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
> 
> 

-- 
what we call human nature in actuality is human habit
http://gleamynode.net/


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100428/6e70f00b/attachment-0001.bin 


More information about the netty-users mailing list