我对骆驼完全陌生。我正在尝试按照一个简单的示例说明如何使用休息服务。
UPDATE D SET
Quantity = S.Quantity
FROM
Staging AS S
INNER JOIN VendorMaster AS V ON S.Vendor = V.Vendor -- Fetch the VendorID from VendorMaster
INNER JOIN Data AS D ON
V.VendorID = D.VendorID AND
S.ProductName = D.ProductName
WHERE
S.Quantity <> D.Quantity -- Update only if there are differences
INSERT INTO Data (
VendorID,
ProductName,
Quantity)
SELECT
VendorID = V.VendorID,
ProductName = S.ProductName,
Quantity = S.Quantity
FROM
Staging AS S
INNER JOIN VendorMaster AS V ON S.Vendor = V.Vendor -- Fetch the VendorID from VendorMaster
WHERE
NOT EXISTS (
SELECT
'data not yet loaded'
FROM
Data AS D
WHERE
V.VendorID = D.VendorID AND
S.ProductName = D.ProductName)
运行此测试时,我得到
public class RestRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
getContext().getProperties().put("http.proxyHost", "myproxy");
getContext().getProperties().put("http.proxyPort","8080");
from("direct:restCall")
.to("log:DEBUG?showBody=true&showHeaders=true")
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.setHeader(Exchange.HTTP_BASE_URI, simple("http://restcountries.eu/rest/v2/alpha/${body}"))
.to("http://restcountries.eu/rest/v2/alpha/${body}")
.to("log:?level=INFO&showBody=true");
}
}
public class RestRouteTest extends CamelTestSupport {
@Override
public RouteBuilder createRouteBuilder() {
return new RestRoute();
}
@Test
public void test() {
String response = template.requestBody("direct:restCall","USA",String.class);
System.out.println("response : " + response);
assertNotNull(response);
}
}
似乎无法用期望的String代替$ {body}。 当我将参数“ USA”硬编码到URL中时,请求将按预期工作。 任何想法我的错误可能是什么? 谢谢。
答案 0 :(得分:2)
使用toD
进行动态
.toD("http://restcountries.eu/rest/v2/alpha/${body}")