2
votes

I'm trying to set up a project with the stack on title, the JMS that we're using is ActiveMQ. So, here is the configuration that I'm doing:

@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);
}

I already tried to add @EnableJms to Application with no success. The stack error is the follow:

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

Thank's in advanced and sorry about any mistake in question.

3
Have you tried with camel spring boot package? That's pretty easy please have a look at github.com/vivek-dhayalan/camel_cxfrs_spring_boot_java_dsl for sample with spring boot and let me know if it's helpful.Vivek Dhayalan
A nice example Vivek of using spring boot and Camel together - i like that.Claus Ibsen
I tried, but doesn't fit to my necessity. But it's a great example.Natan Deitch

3 Answers

1
votes

Apparently it's a bug of spring boot 1.3.3: DefaultJmsListenerContainerFactory does not contains the required method. Try to upgrade to spring boot 1.4.0 (in spite it is not in RELEASE version at the moment). That should solve the bug.

1
votes

I encountered the same Exception and read the answers here. Because I'm using Spring boot 1.5.1-RELEASE, I found the answers not to be applicable and continued my search. What I found to be the cause on my end was not properly reading the manual: http://camel.apache.org/activemq.html. The introduction states:

To use this component make sure you have the activemq.jar or activemq-core.jar on your classpath along with any Camel dependencies such as camel-core.jar, camel-spring.jar and camel-jms.jar.

So what solved the problem was 2 extra Maven entries.

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

I hope it helps someone.

0
votes

If somebody meet with this issue I found solution.

We need to downgrade version of spring-boot to 1.2.3.RELEASE, because camel-jms:2.16.2 uses spring components in version 4.1.9.