【发布时间】:2018-09-29 06:01:31
【问题描述】:
Servicemix 专家需要一些帮助。
我在 apache servicemix 中部署了一个 Web 服务。我从部署在同一台机器上的 tomcat 上的 Web 应用程序中获得的这个 Web 服务。我想将自定义消息从 Web 服务发送到 activemq:queue。
网络服务代码:
@Path("/cdlService/")
public class TestService {
private BundleContext bundleContext;
@GET
@Path("/startProcess/{user}/{isbn}")
@Produces("application/xml")
public String startProcess(@PathParam("user") long userId, @PathParam("isbn") String isbn){
System.out.println("id : " + userId + " , isbn : " + isbn);
CamelContext camelContext = new DefaultCamelContext();
try {
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
System.out.println("in process method");
System.out.println(exchange.getExchangeId() + " : " + exchange.getFromRouteId() + " : " + exchange.isFailed());
}
}).to("activemq:queue:testQueue");
}
});
camelContext.setTracing(true);
camelContext.start();
} catch (Exception e1) {
e1.printStackTrace();
}finally{
if(camelContext != null){
try {
camelContext.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
return "started";
}
}
我想将 userId 和 isbn 从 Web 服务发送到测试队列。该网络服务使用 apache cxf 框架实现。
下面是我的 beans.xml,它位于 resources/META-INF/spring
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd">
<jaxrs:server id="testService" address="/test">
<jaxrs:serviceBeans>
<ref bean="testSvc"/>
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="testSvc" class="com.qait.cdl.web.service.TestService"/>
</beans>
我已通过 maven-bundle-plugin 将上面的示例应用程序部署为 servicemix 中的捆绑包。当我点击上面的网络服务时,它给了我以下错误:
org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[activemq:queue:testQueue] <<< in route: Route(route1)[[From[direct:start]] -> [process[com.qait.cdl.... because of Failed to resolve endpoint: activemq://queue:testQueue due to: No component found with scheme: activemq
【问题讨论】:
标签: web-services cxf apache-karaf osgi-bundle apache-servicemix