Here's a patch against the current trunk that adds this support.
Using a modified version of the send and receive example with a new
build is easy:
HL7Service server = context.newServer(4567, false, true); //
port, tls, accept all
My server is now able to receive these unsolicited ACKs
Tom
On 02/08/17 10:34, Jens Villadsen wrote:
Unsolicited ACK's are a bit weird to receive. While I can agree that
it would be nice if the behavior was configurable, it is currently not
the case (as you found out). I guess the case where it makes sense
would be in the case where your opposing system is supporting enhanced
acknowledgements, which HAPI does not really support (the case where
an acknowledgement is sent to you first as a transport ack, and then
an application ack). HAPI only supports a single ack to each message.
On 2 August 2017 at 11:09, Tom Chiverton <t...@extravision.com
<mailto:t...@extravision.com>> wrote:
I'm receiving this message from another server (I don't know why).
We're building an interface between our app and a HL7 server, and
the first step is just getting the HL7 messages off the wire and
storing them.
The Reciever implementation is making a hard coded policy decision
that my application that's using it does not want to know about
some HL7 messages.
This should be configurable, at the very least ?
I've had a rough delve through the code, and it seems because
Reciever isn't an interface, you have to replace whole chunks of
other classes as well - I think I ended up with over a half dozen
cloned classes in my package because thing's were private or
package and so I couldn't extend them easily.
Maybe it would be easier to have a setting (in HapiContext) about
what to do with them ?
Tom
On 02/08/17 10:02, Jens Villadsen wrote:
Why would you send an unexpected ACK back to the server?
On 31 July 2017 at 17:00, Tom Chiverton <t...@extravision.com
<mailto:t...@extravision.com>> wrote:
*AH HA*.
There's a 3 year old bug with HAPI [1] where it throws away
messages if they are unexpected replies.
I don't see a way to replace the Receiver instance in use by
SimpleServer ?
Tom
[1]
https://sourceforge.net/p/hl7api/feature-requests/88/?limit=25
<https://sourceforge.net/p/hl7api/feature-requests/88/?limit=25>
On 31/07/17 14:51, Tom Chiverton wrote:
Hi,
Sorry I wasn't clear, but further down my
RecivingApplication implementation I do have that :
public Message processMessage(Message theMessage,
Map<String, Object> theMetadata) throws
ReceivingApplicationException, HL7Exception {
String encodedMessage = new
DefaultHapiContext().getPipeParser().encode(theMessage);
System.out.println("Received message:\n" +
encodedMessage + "\n\n");
}
This never outputs.
Tom
On 31/07/17 14:46, Jens Villadsen wrote:
Take a look at the example found at
http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/SendAndReceiveAMessage.html
<http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/SendAndReceiveAMessage.html>
and
http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/ExampleReceiverApplication.html
<http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/ExampleReceiverApplication.html>
What you probably would like to look at is the "processMessage"
On 31 July 2017 at 12:05, Tom Chiverton <t...@extravision.com
<mailto:t...@extravision.com>> wrote:
Given
public class EvReceiverApplication implements
ReceivingApplication {
public boolean canProcess(Message theIn) {
System.out.println("Received message: canProcess true");
return true;
}
....
I never see this output when a message is received. So
it's like the receiver is not registered ?
I am doing
HL7Service server = context.newServer(port, useTls);
ReceivingApplication handler = new EvReceiverApplication();
server.registerApplication("*", "*", handler);
server.startAndWait();
Tom
On 31/07/17 10:24, Tom Chiverton wrote:
I have used
http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/SendAndReceiveAMessage.html
<http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/SendAndReceiveAMessage.html>
to build a simple app that should listen for all
messages, and echo them to the console (
server.registerApplication("*", "*", handler); ).
However, although I get a line from the
connectionReceived method, and none from an output I
added to the exceptionHandler, I do not get anything
from my processMessage() code.
Java 1.8 on Ubuntu Server, with the latest HAPI
library. I can confirm I am getting a message
(admittedly it's MSA is "MSA|AA|245635223|Failure")
with a Wireshark packet capture.
Any ideas what could be up ?
--
*Tom Chiverton*
Lead Developer
e: t...@extravision.com <mailto:t...@extravision.com>
p: 0161 817 2922
t: @extravision <http://www.twitter.com/extravision>
w: www.extravision.com <http://www.extravision.com/>
Extravision - email worth seeing
<http://www.extravision.com/>
Registered in the UK at: First floor, Tomorrow,
MediaCityUK, Manchester, M50 2AB.
Company Reg No: 05017214 VAT: GB 824 5386 19
<tel:24%2053%2086%2019>
This e-mail is intended solely for the person to whom
it is addressed and may contain confidential or
privileged information.
Any views or opinions presented in this e-mail are
solely of the author and do not necessarily represent
those of Extravision Ltd.
______________________________________________________________________
This email has been scanned by the Symantec Email
Security.cloud service.
For more information please visit
http://www.symanteccloud.com
______________________________________________________________________
------------------------------------------------------------------------------
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
<mailto:Hl7api-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/hl7api-devel
<https://lists.sourceforge.net/lists/listinfo/hl7api-devel>
------------------------------------------------------------------------------
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
<mailto:Hl7api-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/hl7api-devel
<https://lists.sourceforge.net/lists/listinfo/hl7api-devel>
--
Med venlig hilsen / Kind regards
*Jens Kristian Villadsen*
cand.polyt
Stålhøjen 24
8240 Risskov
Denmark
Mobile +4523373806 <tel:23%2037%2038%2006>
jenskristianvillad...@gmail.com
<mailto:jenskristianvillad...@gmail.com>
______________________________________________________________________
This email has been scanned by the Symantec Email
Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
______________________________________________________________________
This email has been scanned by the Symantec Email
Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
------------------------------------------------------------------------------
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
<mailto:Hl7api-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/hl7api-devel
<https://lists.sourceforge.net/lists/listinfo/hl7api-devel>
------------------------------------------------------------------------------
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
<mailto:Hl7api-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/hl7api-devel
<https://lists.sourceforge.net/lists/listinfo/hl7api-devel>
--
Med venlig hilsen / Kind regards
*Jens Kristian Villadsen*
cand.polyt
Stålhøjen 24
8240 Risskov
Denmark
Mobile +4523373806 <tel:23%2037%2038%2006>
jenskristianvillad...@gmail.com
<mailto:jenskristianvillad...@gmail.com>
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud
service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
------------------------------------------------------------------------------
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
<mailto:Hl7api-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/hl7api-devel
<https://lists.sourceforge.net/lists/listinfo/hl7api-devel>
--
Med venlig hilsen / Kind regards
*Jens Kristian Villadsen*
cand.polyt
Stålhøjen 24
8240 Risskov
Denmark
Mobile +4523373806
jenskristianvillad...@gmail.com <mailto:jenskristianvillad...@gmail.com>
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
Index: src/main/java/ca/uhn/hl7v2/DefaultHapiContext.java
===================================================================
--- src/main/java/ca/uhn/hl7v2/DefaultHapiContext.java (revision 991)
+++ src/main/java/ca/uhn/hl7v2/DefaultHapiContext.java (working copy)
@@ -330,6 +330,10 @@
return new SimpleServer(this, port, tls);
}
+ public SimpleServer newServer(int port, boolean tls, boolean acceptAll) {
+ return new SimpleServer(this, port, tls, acceptAll);
+ }
+
public TwoPortService newServer(int port1, int port2, boolean tls) {
return new TwoPortService(this, port1, port2, tls);
}
Index: src/main/java/ca/uhn/hl7v2/HapiContext.java
===================================================================
--- src/main/java/ca/uhn/hl7v2/HapiContext.java (revision 991)
+++ src/main/java/ca/uhn/hl7v2/HapiContext.java (working copy)
@@ -291,6 +291,23 @@
HL7Service newServer(int port, boolean tls);
/**
+ * Construct a new HL7 Server which will listen for incoming connections
+ * and will pass all messages to the responders, even if the message control id is not
+ * known to the server
+ *
+ * @param port The port on which to listen for new connections
+ * @param tls Whether or not to use SSL/TLS
+ * @param acceptAll Whether or not to accept all messages
+ * @return HL7 service running on the configured port using the default parser and executor
+ * service instances provided by this interface. Note that the returned service <b>will not
+ * be started</b>, and must manually be started using {@link HL7Service#start()} or
+ * {@link HL7Service#startAndWait()}
+ * @see <a href="http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/SendAndReceiveAMessage.html">here</a> for an example of how to use this method
+ * @see #setSocketFactory(SocketFactory)
+ */
+ HL7Service newServer(int port, boolean tls, boolean acceptAll);
+
+ /**
* Construct a new HL7 Server which will listen for a pair of connections (one for
* incoming messages, one for outgoing)
*
Index: src/main/java/ca/uhn/hl7v2/HapiContextSupport.java
===================================================================
--- src/main/java/ca/uhn/hl7v2/HapiContextSupport.java (revision 991)
+++ src/main/java/ca/uhn/hl7v2/HapiContextSupport.java (working copy)
@@ -180,6 +180,10 @@
return context.newServer(port, tls);
}
+ public HL7Service newServer(int port, boolean tls, boolean acceptAll){
+ return context.newServer(port, tls, acceptAll);
+ }
+
public HL7Service newServer(int inboundPort, int outboundPort, boolean tls) {
return context.newServer(inboundPort, outboundPort, tls);
}
Index: src/main/java/ca/uhn/hl7v2/app/ActiveConnection.java
===================================================================
--- src/main/java/ca/uhn/hl7v2/app/ActiveConnection.java (revision 991)
+++ src/main/java/ca/uhn/hl7v2/app/ActiveConnection.java (working copy)
@@ -68,6 +68,7 @@
private List<Receiver> receivers;
private boolean open = true;
private ExecutorService executorService;
+ private boolean acceptAll = false;
/**
* Creates a new instance of Connection, with inbound and outbound
@@ -92,6 +93,14 @@
this.initiator = new ActiveInitiator(this);
}
+ public ActiveConnection(Parser parser, LowerLayerProtocol llp,
+ Socket bidirectional, ExecutorService executorService,
+ boolean acceptAllMsg)
+ throws LLPException, IOException {
+ this(parser, llp, bidirectional, executorService);
+ acceptAll = acceptAllMsg;
+ }
+
/**
* Creates a new instance of Connection, with inbound communication on one
* port and outbound on another.
@@ -263,4 +272,8 @@
return open;
}
+ public boolean acceptAllMessages(){
+ return acceptAll;
+ }
+
}
Index: src/main/java/ca/uhn/hl7v2/app/Receiver.java
===================================================================
--- src/main/java/ca/uhn/hl7v2/app/Receiver.java (revision 991)
+++ src/main/java/ca/uhn/hl7v2/app/Receiver.java (working copy)
@@ -103,7 +103,9 @@
log.debug("Unsolicited Message Received: {}", message);
getExecutorService().submit(new Grunt(conn, message));
} else {
- if (!conn.isRecipientWaiting(ackID, message)) {
+ if ( conn.acceptAllMessages() ){
+ getExecutorService().submit(new Grunt(conn, message));
+ }else if (!conn.isRecipientWaiting(ackID, message)) {
log.info("Unexpected Message Received. This message appears to be an acknowledgement (MSA-2 has a value) so it will be ignored: {}", message);
} else {
log.debug("Response Message Received: {}", message);
Index: src/main/java/ca/uhn/hl7v2/app/SimpleServer.java
===================================================================
--- src/main/java/ca/uhn/hl7v2/app/SimpleServer.java (revision 991)
+++ src/main/java/ca/uhn/hl7v2/app/SimpleServer.java (working copy)
@@ -85,6 +85,7 @@
private final BlockingQueue<AcceptedSocket> queue;
private AcceptorThread acceptor;
private HapiContext hapiContext;
+ private boolean acceptAllMsg = false;
/**
* Creates a new instance of SimpleServer that listens on the given port,
@@ -100,7 +101,7 @@
*/
public SimpleServer(int port, boolean tls) {
this(port, new MinLowerLayerProtocol(), new PipeParser(), tls);
- }
+ }
/**
* Creates a new instance of SimpleServer that listens on the given port.
@@ -147,6 +148,21 @@
}
/**
+ * Creates a new instance of SimpleServer that listens on a given server socket
+ * and will pass all messages to the responders, even if the message control id
+ * is not known to the server.
+ * SimpleServer will bind the socket when it is started, so the server socket
+ * must not already be bound.
+ *
+ * @since 2.4
+ * @throws IllegalStateException If serverSocket is already bound
+ */
+ public SimpleServer(HapiContext hapiContext, int port, boolean tls, boolean acceptAll) {
+ this(hapiContext, port, tls);
+ acceptAllMsg = acceptAll;
+ }
+
+ /**
* Prepare server by initializing the server socket
*
* @see ca.uhn.hl7v2.app.HL7Service#afterStartup()
@@ -182,7 +198,7 @@
log.info("Accepted connection from {}:{} on local port {}",
new Object[] { newSocket.socket.getInetAddress().getHostAddress(), newSocket.socket.getPort(), port });
ActiveConnection c = new ActiveConnection(getParser(), getLlp(), newSocket.socket,
- getExecutorService());
+ getExecutorService(), acceptAllMsg);
newConnection(c);
}
} catch (InterruptedException ie) {
------------------------------------------------------------------------------
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