First off, I would like to congratulate and thank each and every person who 
worked on the HAPI project, it is a phenomenally powerful library, awesome 
enough for me to decide to code a massive hospital ADT system around it.  My 
project is really 2 separate projects : a web project for users to interact 
with the database (create patients, orders, etc) and a standalone java app 
which is used as a connection / messaging service to different HL7 interfaces.  
I am currently using the ConnectionListener interface for the usage (billing, 
inventory of a dispensing system) servers my service is running, something like 
this :

@Override
    public void connectionReceived(Connection theC)
    {
        connectionEntity.setStatus("Connected");
        connectionService.update(connectionEntity);

        logEntryService.logInfo(LogEntry.CONNECTIVITY, "Usage connection for " 
+ intfc.getName() + "  received from " + theC.getRemoteAddress().toString());
    }

    @Override
    public void connectionDiscarded(Connection theC)
    {
        connectionEntity.setStatus("Listening");
        connectionService.update(connectionEntity);

        logEntryService.logWarning(LogEntry.CONNECTIVITY, "Lost usage 
connection for " + intfc.getName() + " from " + 
theC.getRemoteAddress().toString());
    }

This allows me to know, immediately, when a connection is established or lost 
and allows me to do all sorts of things in real time.  I also have a bunch of 
client connections and I was unable to find an equivalent interface to notify 
me when the server side of my client connections goes down.  I resorted to 
using monitor threads that check the result of the isOpen() method on my 
Connection objects every few seconds and, while it certainly does the trick, I 
was wondering if there was something more real time I could use.  I did try to 
implement ConnectionListener on my HL7ClientConnection objects but the 
connectionDiscarded method is not fired when the server side goes down.  In my 
IDE logs, I see the following being logged by HAPI when I stop the server my 
client connections are talking to :

2018-01-20 11:11:02.609  INFO 14536 --- [ hapi-worker-40] 
ca.uhn.hl7v2.llp.MllpDecoderState        : End of input stream reached.
2018-01-20 11:11:02.609  INFO 14536 --- [ hapi-worker-40] 
ca.uhn.hl7v2.llp.MllpDecoderState        : SocketException on read() attempt.  
Socket appears to have been closed: End of input stream reached before message 
starts
2018-01-20 11:11:02.609  INFO 14536 --- [ hapi-worker-40] 
ca.uhn.hl7v2.app.Receiver                : SocketException: closing Connection 
from 192.168.0.175:2001, will no longer read messages with this Receiver: End 
of input stream reached before message starts
2018-01-20 11:11:30.582  INFO 14536 --- [nitoring Thread] 
ca.uhn.hl7v2.app.ConnectionHub           : Discarding connection which appears 
to be closed. Remote addr: /192.168.0.175

Can I somehow intercept / harness those exceptions in real time to avoid 
needing monitor threads?

Thanks!

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Hl7api-devel mailing list
Hl7api-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hl7api-devel

Reply via email to