change code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.release11;
|
||||
|
||||
import org.apache.camel.Exchange;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
@@ -25,10 +26,11 @@ public class DAO {
|
||||
return xml;
|
||||
}
|
||||
|
||||
public String getId(HashMap packageMap) throws InterruptedException {
|
||||
System.out.println(packageMap.get("id"));
|
||||
Thread.sleep(1000);
|
||||
return String.valueOf(packageMap.get("id"));
|
||||
public void getId(Exchange exchange) throws InterruptedException {
|
||||
|
||||
String tmp = exchange.getIn().getBody().toString();
|
||||
System.out.println(tmp);
|
||||
exchange.getIn().setBody("SELECT * FROM package WHERE material_id = 1");
|
||||
}
|
||||
|
||||
public void splitPackage(LinkedHashMap packageMap) {
|
||||
|
||||
@@ -55,9 +55,10 @@ public class Main {
|
||||
|
||||
from("activemq:queue:material")
|
||||
.split(body())
|
||||
.bean(myFunctions, "getId")
|
||||
.setBody(constant("SELECT * FROM package WHERE material_id = 1"))
|
||||
.to("jdbc:source")
|
||||
//.bean(myFunctions, "getId")
|
||||
.setHeader("id", constant("${body[id]}"))
|
||||
.setBody(constant("SELECT * FROM package WHERE material_id = :?id"))
|
||||
.to("jdbc:source?useHeadersAsParameters=true")
|
||||
.to("activemq:queue:materialPackage")
|
||||
.to("log:?level=INFO&showBody=true");
|
||||
|
||||
@@ -66,7 +67,7 @@ public class Main {
|
||||
|
||||
context.start();
|
||||
ProducerTemplate template = context.createProducerTemplate();
|
||||
template.sendBody("direct:start", "SELECT * FROM material LIMIT 1");
|
||||
template.sendBody("direct:start", "SELECT * FROM material");
|
||||
|
||||
Thread.sleep(1000);
|
||||
//template.setDefaultEndpointUri("activemq:queue:material");
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user