簡體   English   中英

Apache 在 spring 引導應用程序中使用活動 MQ 隊列的駱駝路由

[英]Apache Camel Routing with Active MQ queue in a spring boot application

我對 spring-boot、apache 駱駝和ActiveMQ代理很陌生。 我正在嘗試創建一個應用程序,它將消息發送到我在本地使用 Camel 進行路由的隊列。

當我運行應用程序時,我收到錯誤:

ERROR org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[activemq:queue:myQueue] <<< in route: Route(route1)[[From[direct:firstRoute]] -> [SetBody[constant... because of Failed to resolve endpoint: activemq://queue:myQueue due to: No component found with scheme: activemq

聚甲醛:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-activemq</artifactId>
    </dependency>


   <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring-boot-starter</artifactId>
      <version>2.22.0</version>
   </dependency>
   <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
      <version>2.22.0</version>
   </dependency>

消息路由生成器:

public void configure() throws Exception {
    from("direct:firstRoute")
    .setBody(constant("Hello"))
    .to("activemq:queue:myQueue");
}

應用程序.yaml:

activemq:
    broker-url: tcp://localhost:61616
    user: meAd
    password: meAd

MainApp.java:

        package me.ad.myCamel;

        import org.apache.camel.CamelContext;
        import org.slf4j.Logger;
        import org.slf4j.LoggerFactory;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.boot.CommandLineRunner;
        import org.springframework.boot.SpringApplication;
        import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
        import org.springframework.boot.autoconfigure.SpringBootApplication;
        import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
        import org.springframework.cache.annotation.EnableCaching;
        import org.springframework.context.annotation.Bean;
        import org.springframework.context.annotation.EnableAspectJAutoProxy;

        import me.ad.myCamel.router.MessageRouteBuilder;

        @SpringBootApplication
        @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
        @EnableAspectJAutoProxy(proxyTargetClass = true)
        @EnableCaching
        public class MeAdApp implements CommandLineRunner {

          private static final Logger LOG = LoggerFactory.getLogger(MeAdApp.class);

          @Autowired
          private CamelContext camelContext;

          public static void main(String[] args) {
            try {
              SpringApplication.run(MeAdApp.class, args);
            } catch (Exception ex) {
              LOG.error(ex.getMessage(), ex);
            }
          }

          @Override
          public void run(String... args) throws Exception {
            LOG.info("Starting MeAdApp...");
          }

          @Bean
          public MsgRouteBuilder msgRouteBuilder() throws Exception {
            MsgRouteBuilder routeBuilder = new MsgRouteBuilder();
            camelContext.addRoutes(routeBuilder);
            return routeBuilder;
          }

        }

誰能指出我為什么會收到此錯誤的正確方向? 任何幫助是極大的贊賞。

需要在POM.xml文件中添加camel-activemq

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-activemq</artifactId>
    <version>3.2.0</version>
</dependency>

您的應用程序不知道組件 activemq。 要解決這個問題,您需要在 pom.xml 文件中添加 camel-activemq 的依賴項:

<properties>
        ...
        <activemq.version>3.1.0</activemq.version>
</properties>

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-activemq</artifactId>
    <version>${activemq.version}</version>
</dependency>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM