|
@ -1,72 +0,0 @@
|
|
|
package com.yihu.hos.broker.common.camelrouter;
|
|
|
|
|
|
import org.apache.camel.Exchange;
|
|
|
import org.apache.camel.builder.RouteBuilder;
|
|
|
import org.bson.types.ObjectId;
|
|
|
import org.json.JSONArray;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
|
public class CenterMongoRouter extends RouteBuilder {
|
|
|
static public final String DESTINATION_NAME = "business-log";
|
|
|
|
|
|
@Override
|
|
|
public void configure() throws Exception {
|
|
|
// from("quartz://myGroup/myTimerName?cron=0 0 0 1 /1 * ?")
|
|
|
// .setBody().constant("{ \"flowType\": \"class\" }")
|
|
|
// .to("mongodb:mongo?database=runtime&collection=serviceFlow&operation=findOneByQuery")
|
|
|
// .split(simple("${body}"))
|
|
|
// .process(new Processor() {
|
|
|
// @Override
|
|
|
// public void process(Exchange exchange) throws Exception {
|
|
|
// addMongoInfo(exchange, "runtime", "serviceFlow");
|
|
|
// }
|
|
|
// }).to("bean:centerMongoService?method=log")
|
|
|
//
|
|
|
// .setBody().constant("{ \"tenant\": \"yichang\" }")
|
|
|
// .to("mongodb:mongo?database=runtime&collection=arbiterServer&operation=findOneByQuery")
|
|
|
// .split(simple("${body}"))
|
|
|
// .process(new Processor() {
|
|
|
// @Override
|
|
|
// public void process(Exchange exchange) throws Exception {
|
|
|
// addMongoInfo(exchange, "runtime", "arbiterServer");
|
|
|
// }
|
|
|
// }).to("bean:centerMongoService?method=log");
|
|
|
//
|
|
|
// .setBody().constant("{ \"flowType\": \"class\" }")
|
|
|
// .to("mongodb:mongo?database=runtime&collection=brokerServer&operation=findOneByQuery")
|
|
|
// .split(simple("${body}"))
|
|
|
// .process(new Processor() {
|
|
|
// @Override
|
|
|
// public void process(Exchange exchange) throws Exception {
|
|
|
// addMongoInfo(exchange, "runtime", "serviceFlow");
|
|
|
// }
|
|
|
// }).to("bean:centerMongoService?method=log")
|
|
|
//
|
|
|
// .setBody().constant("{ \"flowType\": \"class\" }")
|
|
|
// .to("mongodb:mongo?database=runtime&collection=serviceFlow&operation=findOneByQuery")
|
|
|
// .split(simple("${body}"))
|
|
|
// .process(new Processor() {
|
|
|
// @Override
|
|
|
// public void process(Exchange exchange) throws Exception {
|
|
|
// addMongoInfo(exchange, "runtime", "serviceFlow");
|
|
|
// }
|
|
|
// }).to("bean:centerMongoService?method=log");
|
|
|
}
|
|
|
|
|
|
public void addMongoInfo(Exchange exchange, String database, String collection) {
|
|
|
Map record = exchange.getIn().getBody(Map.class);
|
|
|
Map info = new HashMap();
|
|
|
info.put("database", database);
|
|
|
info.put("collection", collection);
|
|
|
ObjectId objectId = (ObjectId) record.get("_id");
|
|
|
record.put("_id", objectId.toString());
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
jsonArray.put(info);
|
|
|
jsonArray.put(record);
|
|
|
exchange.getIn().setBody(jsonArray);
|
|
|
}
|
|
|
}
|