import javax.jms.Message;
import javax.jms.MessageListener;
import com.powere2e.platform.messaging.exception.*;
import com.powere2e.platform.v7.commons.log.*;
import com.powere2e.platform.v7.commons.Routerbase;
import com.powere2e.platform.v7.commons.model.*;
import static org.apache.camel.builder.xml.XPathBuilder.xpath;
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.processor.interceptor.*;
import org.apache.camel.builder.xml.*;
import org.apache.camel.component.file.*;
//import org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository;
//import org.springframework.orm.jpa.JpaTemplate;
//import org.apache.camel.processor.idempotent.FileIdempotentRepository;
import org.apache.camel.model.language.SimpleExpression;
public class MyRouteBuilder extends RouteBuilder {//extends Routerbase {
private Tracer tracer = new Tracer();
private MyTraceProcess myTraceProcess = new MyTraceProcess();
//private JpaMessageIdRepository jpaMessageIdRepository = new JpaMessageIdRepository();
MyTransform transform = new MyTransform();
//MyLog myLog = new MyLog();
Log myLog = new Log();
@Override
public void configure() throws Exception {
//super.configure();
/
tracer.setDestinationUri("direct:traced");
tracer.setLogLevel(LoggingLevel.INFO);
tracer.start();
tracer.setTraceOutExchanges(true);
//
DefaultTraceFormatter formatter = new DefaultTraceFormatter();
formatter.setShowOutBody(true);
formatter.setShowOutBodyType(true);
tracer.setFormatter(formatter);
//
getContext().addInterceptStrategy(tracer);
/**/
//
onException(EDINotFoundException.class).stop();
onException(EDI2SimpleXMLException.class)
.bean(myLog, "logEdi2SimpleXmlException")
.bean(transform, "setBodyByInEdiError")
.to("file:camel-out-inEdiError")
.bean(transform, "delHandledFile")
.stop();
///
onException(SimpleXML2PlatformXMLException.class)
.bean(myLog,"logSimpleXml2PlatformXmlException")
.bean(transform, "setBodyByOriginBodyError")
.to("file:camel-out-simpleXmlError")
.bean(transform, "delHandledFile")
.stop();
from("direct:traced").process(myTraceProcess);
///
//new JpaMessageIdRepository(lookup(JpaTemplate.class), PROCESSOR_NAME))
Consumer consumeObj=new Consumer();
from("file:camel-in-edi?include=.*//.txt&delay=300&delete=true")
//.idempotentConsumer(new SimpleExpression(), new FileIdempotentRepository())
//.idempotentConsumer(new FileIdempotentRepository())
//.idempotentConsumer(header("messageId"),new JpaMessageIdRepository(new JpaTemplate(), "IdempotentProcessor"))
.bean(myLog, "logInEdi")
.bean(transform, "edi2SimpleXml")
.bean(myLog, "logEdi2SimpleXml")
.to("file:camel-out-inEdiCorrect")
.bean(transform, "setBodyBySimpleXml")
.to("file:camel-out-simpleXmlAll")
.bean(transform, "SimpleXml2PlatformXml")
.bean(myLog, "logSimpleXml2PlatformXml")
.to("file:camel-out-Powere2eXmlAll")
.bean(consumeObj, "setContent")
//.to("vm://activemq:camel.timer")
//.to("activemq:topic:camel.timer")
.inOut()
.to("activemq:camel.timer?option=value&option=value& concurrentConsumers=100")
.threads(20)
//.bean(MyListener.class)
.stop()
.end();
/*
from("direct:start").idempotentConsumer(
header("messageId"),
jpaMessageIdRepository(lookup(JpaTemplate.class), PROCESSOR_NAME)
).to("mock:result");
*/
}
}
一个activemq例子
最新推荐文章于 2019-05-10 16:13:49 发布