-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ignacio suay
committed
Oct 28, 2013
0 parents
commit a6b43eb
Showing
11 changed files
with
299 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
*.iml | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
*.iml | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>Camel-Hl7-listener</groupId> | ||
<artifactId>Camel-Hl7-listener</artifactId> | ||
<version>1.0</version> | ||
|
||
<properties> | ||
<camel.version>2.10.6</camel.version> | ||
<hapi.version.stable>1.2</hapi.version.stable> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- CAMEL --> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-core</artifactId> | ||
<version>${camel.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-spring</artifactId> | ||
<version>${camel.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-mina</artifactId> | ||
<version>${camel.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-test</artifactId> | ||
<version>${camel.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-hl7</artifactId> | ||
<version>${camel.version}</version> | ||
</dependency> | ||
|
||
<!-- HAPI --> | ||
<dependency> | ||
<groupId>ca.uhn.hapi</groupId> | ||
<artifactId>hapi-base</artifactId> | ||
<version>${hapi.version.stable}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ca.uhn.hapi</groupId> | ||
<artifactId>hapi-structures-v25</artifactId> | ||
<version>${hapi.version.stable}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>1.7.5</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>cglib</groupId> | ||
<artifactId>cglib-nodep</artifactId> | ||
<version>2.2.2</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.10</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<defaultGoal>install</defaultGoal> | ||
|
||
<resources> | ||
<resource> | ||
<directory>${project.basedir}/src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.5</source> | ||
<target>1.5</target> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- allows the route to be ran via 'mvn camel:run' --> | ||
<plugin> | ||
<groupId>org.apache.camel</groupId> | ||
<artifactId>camel-maven-plugin</artifactId> | ||
<version>${camel.version}</version> | ||
</plugin> | ||
|
||
<!--plugin> | ||
<groupId>org.apache.felix</groupId> | ||
<artifactId>maven-bundle-plugin</artifactId> | ||
<version>2.3.4</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<instructions> | ||
<Import-Package>*</Import-Package> | ||
</instructions> | ||
</configuration> | ||
</plugin--> | ||
|
||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package hl7Integration.camel; | ||
|
||
import ca.uhn.hl7v2.model.Message; | ||
|
||
public class RespondACK { | ||
|
||
public Message process(Message in) throws Exception { | ||
System.out.println(in.toString()); | ||
Message out = in.generateACK(); | ||
System.out.println(out.toString()); | ||
return out; | ||
|
||
} | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
src/main/java/hl7Integration/camel/configuration/ListenerConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package hl7Integration.camel.configuration; | ||
|
||
import hl7Integration.camel.RespondACK; | ||
import hl7Integration.camel.routes.in.InboundRouteBuilder; | ||
import org.apache.camel.component.hl7.HL7MLLPCodec; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
|
||
@Configuration | ||
public class ListenerConfiguration { | ||
|
||
@Bean | ||
public HL7MLLPCodec hl7codec() { | ||
|
||
HL7MLLPCodec theBean = new HL7MLLPCodec(); | ||
theBean.setCharset("ISO-8859-1"); | ||
theBean.setValidate(false); | ||
|
||
return theBean; | ||
} | ||
|
||
@Bean | ||
public RespondACK RespondACK() { | ||
return new RespondACK(); | ||
} | ||
|
||
@Bean | ||
public InboundRouteBuilder InboundRouteBuilder() { | ||
return new InboundRouteBuilder(); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/hl7Integration/camel/routes/in/InboundRouteBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package hl7Integration.camel.routes.in; | ||
|
||
import org.apache.camel.spring.SpringRouteBuilder; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class InboundRouteBuilder extends SpringRouteBuilder | ||
{ | ||
private static final Logger log = LoggerFactory.getLogger(InboundRouteBuilder.class); | ||
|
||
@Override | ||
public void configure() throws Exception { | ||
|
||
from("hl7listener") | ||
.routeId("route_hl7listener") | ||
.startupOrder(997) | ||
.unmarshal() | ||
.hl7(false) | ||
.to("bean:RespondACK?method=process") | ||
.end(); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
|
||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:camel="http://camel.apache.org/schema/spring" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://camel.apache.org/schema/spring | ||
http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> | ||
|
||
<!-- enable Spring @Component scan --> | ||
<context:component-scan base-package="hl7Integration.camel.routes.in"/> | ||
|
||
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"> | ||
<property name="location" value="classpath:hl7integration/configuration/endpoint.properties"/> | ||
</bean> | ||
|
||
|
||
<camelContext xmlns="http://camel.apache.org/schema/spring" id="camelContext"> | ||
|
||
<contextScan/> | ||
<!-- You need to configure your socket in the endpoint.properties file --> | ||
<camel:endpoint id="hl7listener" | ||
uri="mina:tcp://{{endpoint.server}}:{{endpoint.port}}?sync=true&codec=#hl7codec" /> | ||
|
||
</camelContext> | ||
|
||
<context:annotation-config/> | ||
<bean class="hl7Integration.camel.configuration.ListenerConfiguration"/> | ||
|
||
</beans> |
3 changes: 3 additions & 0 deletions
3
src/main/resources/hl7integration/configuration/endpoint.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#endpoint configuration | ||
endpoint.server=localhost | ||
endpoint.port=4444 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# The logging properties used during tests.. | ||
# | ||
log4j.rootLogger=INFO, out | ||
|
||
log4j.logger.org.apache.activemq.spring=INFO | ||
log4j.logger.org.apache.activemq.broker.TransportConnection=INFO | ||
|
||
log4j.logger.org.apache.camel.impl.converter=INFO | ||
log4j.logger.org.apache.camel.management=INFO | ||
log4j.logger.org.apache.camel.impl.DefaultPackageScanClassResolver=INFO | ||
log4j.logger.org.springframework=ERROR | ||
|
||
#log4j.logger.org.apache.camel=DEBUG | ||
|
||
|
||
# CONSOLE appender not used by default | ||
log4j.appender.out=org.apache.log4j.ConsoleAppender | ||
log4j.appender.out.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package hl7Integration.test; | ||
|
||
import org.apache.camel.component.hl7.HL7MLLPCodec; | ||
import org.apache.camel.impl.JndiRegistry; | ||
import org.apache.camel.test.junit4.CamelTestSupport; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: suay | ||
* Date: 10/28/13 | ||
* Time: 3:52 PM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
public class TestListener extends CamelTestSupport { | ||
|
||
|
||
/** | ||
* This method sends an HL7 message to the Listener and | ||
* receives and ACK confirmation message | ||
* @throws Exception | ||
*/ | ||
@Test | ||
public void testHl7Codec() throws Exception { | ||
|
||
String inMessage = "MSH|^~\\&|hl7Integration|hl7Integration|||||ADT^A01|||2.5|\r" + | ||
"EVN|A01|20130617154644\r" + | ||
"PID|1|465 306 5961||407623|Wood^Patrick^^^MR||19700101|1|||High Street^^Oxford^^Ox1 4DP~George St^^Oxford^^Ox1 5AP|||||||"; | ||
|
||
String out = (String) template.requestBody("mina:tcp://localhost:4444?sync=true&codec=#hl7codec", inMessage); | ||
|
||
System.out.println(out); | ||
|
||
} | ||
|
||
protected JndiRegistry createRegistry() throws Exception { | ||
JndiRegistry jndi = super.createRegistry(); | ||
jndi.bind("hl7codec", new HL7MLLPCodec()); | ||
return jndi; | ||
} | ||
} |