【问题标题】:Failed to create route due to: No component found with scheme: activemq未能创建路由,原因是:未找到具有方案的组件:activemq
【发布时间】: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";

    }


}

我想将 userIdisbn 从 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


    【解决方案1】:

    您正在混合 CXF 独立和 Camel,但没有加入这两种技术。 您可以使用 Camel 完全编写服务(通过使用 camel-rest 或 camel-cxf 组件从端点更改)。 要使 Camel 向您发送消息,您需要添加依赖项 org.apache.activemq:activemq-camel:5.10.0

    另一方面,您可以使用 spring-jms 项目和 Spring JMSTemplate 将消息发送到 activemq,而不是使用 Camel。见http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/jms.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-13
      • 2021-02-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多