【发布时间】:2016-04-20 11:22:49
【问题描述】:
我正在尝试建立一个标题为堆栈的项目,我们使用的 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: 错误 创建类中定义的名称为“jmsListenerContainerFactory”的bean 路径资源 [org/springframework/boot/autoconfigure/jms/JmsAnnotationDrivenConfiguration.class]: 通过工厂方法实例化 Bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:失败 实例化 [org.springframework.jms.config.DefaultJmsListenerContainerFactory]: 工厂方法“jmsListenerContainerFactory”抛出异常;嵌套的 例外是 java.lang.NoSuchMethodError: org.springframework.jms.config.DefaultJmsListenerContainerFactory.setAutoStartup(Z)V
在此先表示感谢,并对任何有问题的错误表示歉意。
【问题讨论】:
-
你试过camel spring boot包吗?这很简单,请查看 github.com/vivek-dhayalan/camel_cxfrs_spring_boot_java_dsl 以获取带有弹簧靴的示例,如果有帮助请告诉我。
-
一个很好的例子 Vivek 一起使用 spring boot 和 Camel - 我喜欢这样。
-
我试过了,但不符合我的需要。但这是一个很好的例子。
标签: spring-boot jms apache-camel activemq