gpt4 book ai didi

spring-boot - Apache-camel 与 spring-boot

转载 作者:行者123 更新时间:2023-12-05 05:24:25 24 4
gpt4 key购买 nike

我正在尝试建立一个标题为堆栈的项目,我们使用的 JMS 是 ActiveMQ。所以,这是我正在做的配置:

@SpringBootApplication

public class Application {

private static Logger logger = Logger.getLogger(Application.class);

@Value("${broker.component.name}")
private String brokerComponetName;
@Value("${broker.dead.letter.queue}")
private String brokerDeadLetterQueue;
@Value("${broker.in.queue}")
private String brokerInQueue;
@Value("${broker.out.queue}")
private String brokerOutQueue;
@Value("${broker.url}")
private String brokerUrl;
@Value("${broker.user}")
private String brokerUser;
@Value("${broker.password}")
private String brokerPassword;

public static void main(String[] args) throws Exception {
logger.info("starting loader");
SpringApplication.run(Application.class, args);
}

@Bean
public SpringCamelContext camelContext(ApplicationContext applicationContext) throws Exception {

SpringCamelContext camelContext = new SpringCamelContext(applicationContext);

camelContext.addComponent(brokerComponetName, JmsComponent.jmsComponent(connectionFactory()));

camelContext.addRoutes(new RouteBuilder() {
public void configure() throws ConfigurationException {
errorHandler(deadLetterChannel(brokerDeadLetterQueue)
.onRedelivery(new FailureProcessor())
.useOriginalMessage()
.maximumRedeliveries(5)
.redeliveryDelay(5000)
.retryAttemptedLogLevel(LoggingLevel.INFO));

from(brokerInQueue)
.process(new MessageProcessor())
.to(brokerOutQueue);
}
});

return camelContext;
}

@Bean
public ConnectionFactory connectionFactory() throws ConfigurationException {
System.out.println("BROKER URL: " + brokerUrl);
return new ActiveMQConnectionFactory(brokerUser,
brokerPassword, brokerUrl);
}

我已经尝试将@EnableJms 添加到应用程序,但没有成功。堆栈错误如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsListenerContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/jms/JmsAnnotationDrivenConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.jms.config.DefaultJmsListenerContainerFactory]: Factory method 'jmsListenerContainerFactory' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.jms.config.DefaultJmsListenerContainerFactory.setAutoStartup(Z)V

提前致谢,对于任何错误,我们深表歉意。

最佳答案

显然这是 spring boot 1.3.3 的一个错误:DefaultJmsListenerContainerFactory 不包含所需的方法。尝试升级到 spring boot 1.4.0(尽管目前还不是 RELEASE 版本)。这应该可以解决该错误。

关于spring-boot - Apache-camel 与 spring-boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34801365/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com