How to create a Camel HL7 Listener

You may also like...

13 Responses

  1. Marcus Young says:

    Just interested in your thoughts regarding multiple message types being received and processed by a single channel. To explain I have two applications; one processes ADT the other ORU. It occurred to me that these could be combined into a single application that listens on a single port. Is this reasonable or is there an advantage keeping the processing separate and hence running in (in my case) different threads? In fact I am currently loading the messages into a FIFO buffer to manage any bursting, so I have two FIFO buffers; one for ORU and one for ADT

    • Ignacio Suay says:

      If I were you I would use one single application. If you have more than one application that will be more difficult maintain. In this case, I would use Apache Camel + ActimeMQ. Using Camel you could have different business logic for different messages, I have written a couple of post about camel, but I strongly recommend you read “Camel in Action” it is a very good book, and very easy to follow. On the other hand, you could use ActiveMQ to manage your queues, it is very useful to manage any bursting and provides reliable messaging.
      I hope it helps.

  2. Marcus Young says:

    Thank you for your advice. I am using Camel, but I will have a look at ActiveMQ.

  3. R Sen says:

    I am able to code a listener following your approach. However, although my listener works when tested from the localhost it fails when I have the test running on a machine and sending HL7 message to the listener on a different machine. The error message I get is ‘connection refused’ – However, when run a basic TCP client it can connect to that machine/port. I am not sure what is the problem. Any insight might help.

    • Ignacio Suay says:

      Please could you show me how do you specify the ip destination in your test and in your camel config file?
      Try using instead of localhost, I think that should fix your problem.

  4. Deepa says:

    I used ur complete code, but my listener doesn’t work. I am using my localhost for IP destination. I tried using as well as my ip of my machine but it doesn’t work. I am getting the exception:
    Caused by: org.apache.mina.common.RuntimeIOException: Failed to get the session.
    at org.apache.camel.component.mina.MinaProducer.openConnection(
    at org.apache.camel.component.mina.MinaProducer.doProcess(
    at org.apache.camel.component.mina.MinaProducer.process(
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(
    at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(
    at org.apache.camel.processor.UnitOfWorkProcessor.process(
    at org.apache.camel.util.AsyncProcessorHelper.process(
    at org.apache.camel.processor.DelegateAsyncProcessor.process(
    at org.apache.camel.processor.UnitOfWorkProducer.process(
    at org.apache.camel.impl.ProducerCache$2.doInProducer(
    at org.apache.camel.impl.ProducerCache$2.doInProducer(
    at org.apache.camel.impl.ProducerCache.doInProducer(
    at org.apache.camel.impl.ProducerCache.sendExchange(
    at org.apache.camel.impl.ProducerCache.send(
    at org.apache.camel.impl.DefaultProducerTemplate.send(
    at org.apache.camel.impl.DefaultProducerTemplate.sendBody(
    … 31 more
    Caused by: Connection refused: no further information

    • Ignacio Suay says:

      Hi Deepa,

      You will need first to run: “mvn camel:run” in a different terminal to initialize the camel and spring context. The camel:run goal of the Camel Maven Plugin is used to run your Camel Spring configurations in a forked JVM from Maven.

      So you will need to keep the session open, and then you will be able to run the tests.

      Please try this approach and let me know how did it go.

  5. Ganesh says:

    I use your complete code, I am getting the below error while running the mvn camel:run command.
    [ERROR] Failed to execute goal org.apache.camel:camel-maven-plugin:2.10.6:run (default-cli) on project Camel-Hl7-listener: null: MojoExecutionException: InvocationTarget
    Exception: Could not resolve bean definition resource pattern [META-INF/spring/*.xml]; nested exception is class path resource [META-INF/s
    pring/] cannot be resolved to URL because it does not exist -> [Help 1]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1]

    • Ignacio Suay says:

      Hi Ganesh,

      I have just tried to clone the project again in a clean machine and I am not getting any error when I run “mvn camel:run”. Could you please check that the code is exactly the same as in the project please?

  6. Marcus says:

    Just curious – in your example above, how would I change the RespondAck ID Generator:
    ctx.getParserConfiguration().setIdGenerator(new FileBasedHiLoGenerator())

    but where would I get the HapiContext ctx – or for that matter set it?
    or should it be like this:

    public class RespondACK {
    public Message process(Message in) throws Exception {

    HapiContext ctx = new DefaultHapiContext();
    ctx.getParserConfiguration().setIdGenerator(new FileBasedHiLoGenerator());

    Message out = in.generateACK();
    return out;

  7. Chidambaram says:

    This may not be relevant to the post, but thought someone would have an idea here. Is there Camel component available for DICOM protocol. I don’t see any in official website. If anyone knows about it please let me know.

Leave a Reply

Your email address will not be published. Required fields are marked *