This is the 2nd article in this series, you can start with the 1st article if you need some context.
For the infrastructure, I began small.
- I launched an Ubuntu ec2 instance
- I installed a vnc server on it so i could access the desktop from a vnc client on my Mac – I plan to use this ec2 instance as my development machine
- I installed mirth – I’ll need this to generate valid hl7 messages that I will feed into spring xd’s big data pipeline
- I installed eclipse luna- to develop the spring integration modules that will be uploaded into spring xd.
My 1st use case is to create a hl7 feed and ingest it using spring xd, storing the messages in hdfs.
For the 1st development effort, I plan to create a mirth channel that reads hl7 from a database, sends it over tcp to a spring xd custom source module.
The mirth configuration is shown below
Source tab of the channel
Destination tab of the channel
For the spring xd to ingest the hl7, I have to create a custom source module as none of the out of the box modules will handle hl7 mllp protocol. This module will use a camel hl7 endpoint to accept messages from mirth and then place these messages on a spring integration channel.
The plan is to eventually upload this spring integration module into spring xd. 1st things 1st. In eclipse I created a spring boot project. The configuration class / application class looks as follows:
This being the 1st iteration , Ian writing to file just to make sure the data is coming in, ad sure enough after I run the code in eclipse and start my mirth channel, I have hl7 messages dropping into my folder . Neat!!
Spring boot/integration /camel source code iteration 1 of the inbound hl7 to a file destination:
package com.wchr.xd; import java.io.IOException; import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import static org.apache.camel.component.hl7.HL7.ack; import org.apache.camel.component.hl7.HL7MLLPNettyDecoderFactory; import org.apache.camel.component.hl7.HL7MLLPNettyEncoderFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @SpringBootApplication @Configuration public class Application extends RouteBuilder { @Autowired CamelContext camelContext; //private static CamelContext cmContext; public static void main(String[] args) throws IOException, InterruptedException { SpringApplication.run(Application.class, args); // cmContext = context.getBean(CamelContext.class); } @Bean public HL7MLLPNettyDecoderFactory hl7decoder(){ return new HL7MLLPNettyDecoderFactory(); } @Bean public HL7MLLPNettyEncoderFactory hl7encoder(){ return new HL7MLLPNettyEncoderFactory(); } @Override public void configure() throws Exception { // TODO Auto-generated method stub from("netty4:tcp://localhost:9000?sync=true&encoder=#hl7encoder&decoder=#hl7decoder") .to("file://inbound?autoCreate=true&fileName=${date:now:yyyyMMddHHmmss}.hl7") .transform(ack()); } }
snapshot of the inbound messages from my eclipse project