当前位置: 首页 > 知识库问答 >
问题:

Camel ActiveMQ+Spring Boot未读取Spring ActiveMQ配置

徐智渊
2023-03-14
    null

如能提供任何协助,将不胜感激。我确实在stackoverflow上搜索了相关的问题,但没有给出我所面临的问题的解决方案

我在控制台上看到错误,这继续像60-70次尝试和计数。正如您所看到的,camel正在获取的代理URL,可能是spring在默认情况下配置的默认URL

Failed to connect to [tcp://localhost:61616] after: 10 attempt(s) continuing to retry.

以下是我当前的配置/代码:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
</parent>

<dependencyManagement>
    <dependencies>
        <!-- Spring Cloud is part of the project where I am configuring camel routes -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.SR5</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-boot-dependencies</artifactId>
            <version>2.19.2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>

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

    <!-- I have this as the same project works as a web app as well 
    and therefore I do not need the 
    camel.springboot.main-run-controller=true configuration to be set
    which is as per camel's spring boot documentation-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- Camel - start -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-camel</artifactId>
    </dependency>
    <!-- Camel - end -->

</dependencies>
spring:
  activemq:
    brokerUrl: tcp://my.company.host:[port] //This port is up and running
    user: user
    password: password

爪哇骆驼路线

package com.mycamel.route;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

@Component
public class SampleAmqCamelRouter extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("activemq:some.queue").to("log:com.mycamel.route?level=INFO&groupSize=10");
    }

}

共有1个答案

叶衡虑
2023-03-14

首先,您应该将spring-boot-starter-activeMQ依赖项添加到pom.xml中。然后,您可以使用它的自动配置功能,它将根据您在application.yml中指定的属性创建ConnectionFactory

之后,还必须配置Camel的ActiveMQComponent。如果您希望重用ConnectionFactory(由autoconfig创建),那么可以通过以下方法实现:

@Configuration
public class ActiveMQComponentConfig {

    @Bean(name = "activemq")
    public ActiveMQComponent createComponent(ConnectionFactory factory) {
        ActiveMQComponent activeMQComponent = new ActiveMQComponent();
        activeMQComponent.setConnectionFactory(factory);
        return activeMQComponent;
    }
}

您可以在Camel的ActiveMQ文档中找到更多信息。

 类似资料:
  • 我刚开始穿弹力靴。这就是我要解决的问题。我有一个application.yml文件,它具有以下属性: 我尝试使用以下代码访问KinesisSenderFeature的值: 以及 PropertySourcesPlaceHolderConfigureer bean定义为: 是的,我确实看到了: 将Yaml中的列表映射到Spring Boot中的对象列表 Spring boot YAML配置未读取所有

  • 我在我的windows机器上设置了Elk堆栈,其中包含以下内容: Elasticserach Logstash Kibana 我的logstash.conf 我的日志文件。日志(Apache日志) 当我运行logstash时。conf它在elasticsearch中创建以下索引: 上面的索引为空,无法从我的日志文件中获取任何数据。请帮忙?我对麋鹿很陌生。 当我使用以下方法查询索引logstash-

  • 本文向大家介绍详解springboot + profile(不同环境读取不同配置),包括了详解springboot + profile(不同环境读取不同配置)的使用技巧和注意事项,需要的朋友参考一下 具体做法: 不同环境的配置设置一个配置文件,例如:dev环境下的配置配置在application-dev.properties中;prod环境下的配置配置在application-prod.prope

  • 我试图在Spring Boot 1.5.1项目中设置并使用YAML as配置文件。 我的YAML文件如下所示: 读取hue.get用户()非常好。但是,hue.get场景()由于某种原因返回null。我的色调配置Java代码如下所示: 我也尝试用前缀来注释每个类,hue.scenes.sunstatus、scenes.sunstatus和sunstate的格式都是如此。 此外,我还尝试使用@Val

  • 使用nacos做为springboot的配置中心,我想用nacos做一个开关,读取nacos的配置信息,demo:false 。然后修改为demo:true,请问怎么使用springboot进行实现。

  • PropKit工具类用来读取外部键值对配置文件,PropKit可以极度方便地在系统任意时空使用,配置文件的格式如下: userName=james email=no-reply@jfinal.com devMode=true 如下是 PropKit 代码示例: PropKit.use("config.txt"); String userName = PropKit.get("userName");

  • 在SpringBoot中读取环境变量的最佳方法是什么? 在Java中,我使用了以下方法: 是否可以使用注释来实现?

  • 这肯定不总是一件好事,例如,未分配的内存可能会被取消映射。然而,一定有什么东西能让这一切奏效。我的一些假设: OSX不仅保证它的分配是16字节对齐的,而且还保证分配的“量程”是16字节的块。换句话说,分配5个字节实际上会分配16个字节。分配20个字节实际上将分配32个字节。 在编写asm时读取数组末尾本身并无害,因为这不是未定义的行为,只要它在范围内(在页面内?)。 实际原因是什么?