Search in sources :

Example 1 with CamelBeanPostProcessor

use of org.apache.camel.spring.CamelBeanPostProcessor in project camel by apache.

the class JmsReconnectTest method testRequestReply.

/**
     * This test is disabled as the problem can currently not be reproduced using ActiveMQ.
     * TODO Find a way to recreate the problem with ActiveMQ and fully automate the test
     * @throws Exception
     */
@Ignore
@Test
public void testRequestReply() throws Exception {
    BrokerService broker = new BrokerService();
    broker.addConnector("tcp://localhost:61616");
    broker.setPersistent(false);
    broker.setTimeBeforePurgeTempDestinations(1000);
    broker.start();
    DefaultCamelContext context = new DefaultCamelContext();
    JmsComponent jmsComponent = new JmsComponent();
    /**
         * 
         */
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL("failover://(tcp://localhost:61616)?maxReconnectAttempts=1");
    /**
         * When using Tibco EMS the problem can be recreated. As the broker is
         * external it has to be stopped and started by hand.
         */
    // TibjmsConnectionFactory connectionFactory = new TibjmsConnectionFactory();
    // connectionFactory.setReconnAttemptCount(1);
    jmsComponent.setConnectionFactory(connectionFactory);
    jmsComponent.setRequestTimeout(1000);
    jmsComponent.setReceiveTimeout(1000);
    context.addComponent("jms", jmsComponent);
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("jms:testqueue").bean(new EchoServiceImpl());
            from("direct:test").to("jms:testqueue");
        }
    });
    CamelBeanPostProcessor processor = new CamelBeanPostProcessor();
    processor.setCamelContext(context);
    processor.postProcessBeforeInitialization(this, "this");
    context.start();
    String ret = proxy.echo("test");
    Assert.assertEquals("test", ret);
    broker.stop();
    /**
         * Wait long enough for the jms client to do a full reconnect. In the
         * Tibco EMS case this means that a Temporary Destination created before
         * is invalid now
         */
    Thread.sleep(5000);
    System.in.read();
    broker.start(true);
    /**
         * Before the fix to this issue this call will throw a spring UncategorizedJmsException
         * which contains an InvalidJmsDestination
         */
    String ret2 = proxy.echo("test");
    Assert.assertEquals("test", ret2);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) RouteBuilder(org.apache.camel.builder.RouteBuilder) JmsComponent(org.apache.camel.component.jms.JmsComponent) CamelBeanPostProcessor(org.apache.camel.spring.CamelBeanPostProcessor) BrokerService(org.apache.activemq.broker.BrokerService) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with CamelBeanPostProcessor

use of org.apache.camel.spring.CamelBeanPostProcessor in project camel by apache.

the class CamelAutoConfiguration method camelBeanPostProcessor.

/**
     * Camel post processor - required to support Camel annotations.
     */
@Bean
CamelBeanPostProcessor camelBeanPostProcessor(ApplicationContext applicationContext) {
    CamelBeanPostProcessor processor = new CamelBeanPostProcessor();
    processor.setApplicationContext(applicationContext);
    return processor;
}
Also used : CamelBeanPostProcessor(org.apache.camel.spring.CamelBeanPostProcessor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with CamelBeanPostProcessor

use of org.apache.camel.spring.CamelBeanPostProcessor in project camel by apache.

the class CamelSpringTestSupport method postProcessTest.

@Override
public void postProcessTest() throws Exception {
    super.postProcessTest();
    if (isCreateCamelContextPerClass()) {
        applicationContext = threadAppContext.get();
    }
    // use the bean post processor from camel-spring
    CamelBeanPostProcessor processor = new CamelBeanPostProcessor();
    processor.setApplicationContext(applicationContext);
    processor.setCamelContext(context);
    processor.postProcessBeforeInitialization(this, getClass().getName());
    processor.postProcessAfterInitialization(this, getClass().getName());
}
Also used : CamelBeanPostProcessor(org.apache.camel.spring.CamelBeanPostProcessor)

Example 4 with CamelBeanPostProcessor

use of org.apache.camel.spring.CamelBeanPostProcessor in project camel by apache.

the class CamelSpringTestSupport method postProcessTest.

/**
     * Lets post process this test instance to process any Camel annotations.
     * Note that using Spring Test or Guice is a more powerful approach.
     */
@Override
public void postProcessTest() throws Exception {
    super.postProcessTest();
    if (isCreateCamelContextPerClass()) {
        applicationContext = threadAppContext.get();
    }
    // use the bean post processor from camel-spring
    CamelBeanPostProcessor processor = new CamelBeanPostProcessor();
    processor.setApplicationContext(applicationContext);
    processor.setCamelContext(context);
    processor.postProcessBeforeInitialization(this, getClass().getName());
    processor.postProcessAfterInitialization(this, getClass().getName());
}
Also used : CamelBeanPostProcessor(org.apache.camel.spring.CamelBeanPostProcessor)

Example 5 with CamelBeanPostProcessor

use of org.apache.camel.spring.CamelBeanPostProcessor in project camel by apache.

the class CamelConfiguration method camelBeanPostProcessor.

/**
     * Camel post processor - required to support Camel annotations.
     */
@Bean
public CamelBeanPostProcessor camelBeanPostProcessor() throws Exception {
    CamelBeanPostProcessor answer = new CamelBeanPostProcessor();
    answer.setApplicationContext(getApplicationContext());
    // do not set CamelContext as we will lazy evaluate that later
    return answer;
}
Also used : CamelBeanPostProcessor(org.apache.camel.spring.CamelBeanPostProcessor) Bean(org.springframework.context.annotation.Bean)

Aggregations

CamelBeanPostProcessor (org.apache.camel.spring.CamelBeanPostProcessor)5 Bean (org.springframework.context.annotation.Bean)2 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)1 BrokerService (org.apache.activemq.broker.BrokerService)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 JmsComponent (org.apache.camel.component.jms.JmsComponent)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1