Apache Camel: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
==Route==
<source lang="java">
package org.chorke.academia.java.mllp.engine.route;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.spring.SpringRouteBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.chorke.academia.java.mllp.engine.beans.listener.LabScheduleListener;
@Component
public class SchedulerRoute extends SpringRouteBuilder {
    private static Logger LOG = LoggerFactory.getLogger(SchedulerRoute.class);
   
    @Autowired
    LabScheduleListener schedulerListener;
    @Override
    public void configure() throws Exception {
        from("quartz2://lab/hl7v2/client/scheduler?cron=*/1+*+*+*+*+?&trigger.timeZone=+8 UTC").routeId("labSchedulerRoute")
        .process(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                LOG.debug("Keep your exchange business here");
            }
        })
        .threads(1, 10).multicast()
        .bean(this.schedulerListener).log("lab/hl7v2/client/scheduler");
    }
}
</source>
==Handler==
<source lang="java">
package org.chorke.academia.java.mllp.engine.beans.listener;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangeException;
import org.apache.camel.Handler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
public class LabScheduleListenerImpl implements LabScheduleListener {
    private static Logger LOG = LoggerFactory.getLogger(LabScheduleListenerImpl.class);
   
    @Handler
    @Override
    public void listen(@ExchangeException Exception exception, Exchange exchange) throws Exception {
        LOG.info("Keep your LAB schedule business here");
    }
}
</source>
==References==
==References==
{|
{|

Revision as of 18:04, 22 December 2020

Route

package org.chorke.academia.java.mllp.engine.route;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.spring.SpringRouteBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.chorke.academia.java.mllp.engine.beans.listener.LabScheduleListener;

@Component
public class SchedulerRoute extends SpringRouteBuilder {
    private static Logger LOG = LoggerFactory.getLogger(SchedulerRoute.class);
    
    @Autowired
    LabScheduleListener schedulerListener;

    @Override
    public void configure() throws Exception {
        from("quartz2://lab/hl7v2/client/scheduler?cron=*/1+*+*+*+*+?&trigger.timeZone=+8 UTC").routeId("labSchedulerRoute")
        .process(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                LOG.debug("Keep your exchange business here");
            }
        })
        .threads(1, 10).multicast()
        .bean(this.schedulerListener).log("lab/hl7v2/client/scheduler");
    }
}

Handler

package org.chorke.academia.java.mllp.engine.beans.listener;

import org.apache.camel.Exchange;
import org.apache.camel.ExchangeException;
import org.apache.camel.Handler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class LabScheduleListenerImpl implements LabScheduleListener {
    private static Logger LOG = LoggerFactory.getLogger(LabScheduleListenerImpl.class);
    
    @Handler
    @Override
    public void listen(@ExchangeException Exception exception, Exchange exchange) throws Exception {
        LOG.info("Keep your LAB schedule business here");
    }
}

References