Package ca.uhn.hl7v2.app
Class ActiveConnection
java.lang.Object
ca.uhn.hl7v2.app.ActiveConnection
- All Implemented Interfaces:
Connection,Closeable,AutoCloseable
A TCP/IP connection to a remote HL7 server.
- Author:
- Bryan Tripp
-
Constructor Summary
ConstructorsConstructorDescriptionActiveConnection(Parser parser, LowerLayerProtocol llp, Socket bidirectional) Creates a new instance of Connection, with inbound and outbound communication on a single port.ActiveConnection(Parser parser, LowerLayerProtocol llp, Socket inbound, Socket outbound) Creates a new instance of Connection, with inbound communication on one port and outbound on another.ActiveConnection(Parser parser, LowerLayerProtocol llp, Socket inbound, Socket outbound, ExecutorService executorService) Creates a new instance of Connection, with inbound communication on one port and outbound on another.ActiveConnection(Parser parser, LowerLayerProtocol llp, Socket bidirectional, ExecutorService executorService) ActiveConnection(Parser parser, LowerLayerProtocol llp, Socket bidirectional, ExecutorService executorService, boolean acceptAllMsg) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidactivate()Start the receiver thread(s)voidclose()Stops running Receiver threads and closes open socketsprotected HL7WriterReturns the HL7Writer through which responses to inbound messages should be sent.Returns the Initiator associated with this connectionReturns the address of the remote host to which this Connection is connected.Returns the remote port on the remote host to which this Connection is connected.ca.uhn.hl7v2.app.ResponderReturns the Responder associated with this connectionprotected HL7WriterReturns the HL7Writer through which unsolicited outbound messages should be sent.booleanisOpen()Returns true if this connection is openprotected booleanisRecipientWaiting(String ackID, String message) Given the ack ID (MSA-2) of a message, notifies a waiting consumer thread about a received response.booleanisSecure()voidsetReceiverParserExeptionHandler(Receiver.ReceiverParserExceptionHandler parserExeptionHandler) Register the parser exception handler for each of the receiverstoString()waitForResponse(String messageID, long timeout) Reserves a future incoming message by ack ID.
-
Constructor Details
-
ActiveConnection
public ActiveConnection(Parser parser, LowerLayerProtocol llp, Socket bidirectional) throws LLPException, IOException Creates a new instance of Connection, with inbound and outbound communication on a single port.- Throws:
LLPExceptionIOException
-
ActiveConnection
public ActiveConnection(Parser parser, LowerLayerProtocol llp, Socket bidirectional, ExecutorService executorService) throws LLPException, IOException - Throws:
LLPExceptionIOException
-
ActiveConnection
public ActiveConnection(Parser parser, LowerLayerProtocol llp, Socket bidirectional, ExecutorService executorService, boolean acceptAllMsg) throws LLPException, IOException - Throws:
LLPExceptionIOException
-
ActiveConnection
public ActiveConnection(Parser parser, LowerLayerProtocol llp, Socket inbound, Socket outbound) throws LLPException, IOException Creates a new instance of Connection, with inbound communication on one port and outbound on another.- Throws:
LLPExceptionIOException
-
ActiveConnection
public ActiveConnection(Parser parser, LowerLayerProtocol llp, Socket inbound, Socket outbound, ExecutorService executorService) throws LLPException, IOException Creates a new instance of Connection, with inbound communication on one port and outbound on another.- Throws:
LLPExceptionIOException
-
-
Method Details
-
setReceiverParserExeptionHandler
public void setReceiverParserExeptionHandler(Receiver.ReceiverParserExceptionHandler parserExeptionHandler) Register the parser exception handler for each of the receivers -
activate
Start the receiver thread(s)- Specified by:
activatein interfaceConnection
-
getExecutorService
- Specified by:
getExecutorServicein interfaceConnection
-
getRemoteAddress
Returns the address of the remote host to which this Connection is connected. If separate inbound and outbound sockets are used, the address of the outbound socket is returned (the addresses should normally be the same, but this isn't checked).- Specified by:
getRemoteAddressin interfaceConnection- See Also:
-
getRemotePort
Returns the remote port on the remote host to which this Connection is connected. If separate inbound and outbound sockets are used, the port of the outbound socket is returned.- Specified by:
getRemotePortin interfaceConnection- See Also:
-
getInitiator
Returns the Initiator associated with this connection- Specified by:
getInitiatorin interfaceConnection- Returns:
-
getResponder
Returns the Responder associated with this connection -
isSecure
-
getSendWriter
Returns the HL7Writer through which unsolicited outbound messages should be sent. -
getAckWriter
Returns the HL7Writer through which responses to inbound messages should be sent. -
getParser
-
toString
-
waitForResponse
protected Future<String> waitForResponse(String messageID, long timeout) throws InterruptedException Reserves a future incoming message by ack ID. When the incoming message with the given ack ID arrives, the message will be returned.- Throws:
InterruptedException
-
isRecipientWaiting
Given the ack ID (MSA-2) of a message, notifies a waiting consumer thread about a received response. -
close
Stops running Receiver threads and closes open sockets- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isOpen
Description copied from interface:ConnectionReturns true if this connection is open- Specified by:
isOpenin interfaceConnection- Returns:
- true if this connection is open
-
acceptAllMessages
-