Package ca.uhn.hl7v2.app
Class ActiveInitiator
java.lang.Object
ca.uhn.hl7v2.app.ActiveInitiator
- All Implemented Interfaces:
Initiator
Performs the initiation role of a message exchange (i.e sender of the first message; analogous to the client in a client-server interaction), according to HL7's original mode processing rules.
The sendAndReceive(...) method blocks until either a response is
received with the matching message ID, or until a timeout period has passed.
The timeout defaults to 10000 ms (10 sec) but can be configured using
setTimeout(long, java.util.concurrent.TimeUnit) or globally by setting
the system property "ca.uhn.hl7v2.app.initiator.timeout" to an long value
representing the number of ms after which to time out.
At the time of writing, enhanced mode, two-phase reply, continuation messages, and batch processing are unsupported.
- Author:
- Bryan Tripp
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidTest harnesssendAndReceive(Message out) Sends a message to a responder system, receives the reply, and returns the reply as a Message object.voidsetTimeout(long timeout, TimeUnit timeUnit) Sets the timeout to wait for a response from the servervoidsetTimeoutMillis(int timeout) Sets the timeout to wait for a response from the server
-
Method Details
-
sendAndReceive
Sends a message to a responder system, receives the reply, and returns the reply as a Message object. This method is thread-safe - multiple threads can share an Initiator and call this method. Responses are returned to the calling thread on the basis of message ID.- Specified by:
sendAndReceivein interfaceInitiator- Parameters:
out- outgoing message- Returns:
- resposne message
- Throws:
HL7ExceptionLLPExceptionIOException
-
setTimeoutMillis
Sets the timeout to wait for a response from the server- Specified by:
setTimeoutMillisin interfaceInitiator- Parameters:
timeout- time in milliseconds
-
setTimeout
Sets the timeout to wait for a response from the server- Specified by:
setTimeoutin interfaceInitiator- Parameters:
timeout- time durationtimeUnit- time unit
-
main
Test harness
-