CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false); deprecated in camel-version 2.17.3

Ich bin mit Spring + Apache Camel Beispiel. In diesem Beispiel früher war ich mit camel-core version 2.15.1. Jetzt habe ich gerade aktualisiert, in Abhängigkeit von 2.17.3 Wenn ich aktualisiert Abhängigkeit sehe ich, dass unten Methode bekommt veraltet:

CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false);

Was ist der Ersatz-code für das ?

Bitte meinen code unten für Referenz:
CamelTimerFeedingActiveMqExample

public class CamelTimerFeedingActiveMqExample {
    public static final void main(String[] args) throws Exception {
        ApplicationContext appContext = new ClassPathXmlApplicationContext("timerFeedActiveMqApplicationContext.xml");
        CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false);
        try {
            camelContext.start();
            Thread.sleep(5000);
        } finally {
            camelContext.stop();
        }
    }
}

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

    <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="activemq:queue:numbers" />
            <to uri="log:com.javarticles?level=INFO&amp;groupInterval=10000" />
        </route>
    </camelContext> 
</beans>

timerFeedActiveMqApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

    <bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="vm://localhost?broker.persistent=false" />
    </bean>

    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
        <property name="connectionFactory" ref="connectionFactory" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route id="timerPingToInQueue">
            <from uri="timer:ping?period=1s" />
            <transform>
                <simple>Ping at ${date:now:yyyy-MM-dd HH:mm:ss}</simple>
            </transform>
            <to uri="activemq:queue:ping_queue" />
        </route>
        <route id="InQueueToConsole">
            <from uri="activemq:queue:ping_queue" />
            <to uri="stream:out" />
        </route>
    </camelContext>
</beans>

timerSelectQueryApplicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">

    <context:property-placeholder location="classpath:database.properties"/>

    <bean id="orderProcessor" class="com.javarticles.camel.components.OrderProcessor"/>

    <jdbc:initialize-database data-source="dataSource" enabled="true">
        <jdbc:script location="classpath:db-schema.sql" />
        <jdbc:script location="classpath:db-test-data.sql" />
    </jdbc:initialize-database>


    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${mysql.driver.class.name}" />
        <property name="url" value="${mysql.url}" />
        <property name="username" value="${mysql.username}" />
        <property name="password" value="${mysql.username}" />
    </bean>

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="timer://queryTimer?period=2s" />
            <setBody>
                <constant>
                    SELECT * FROM ORDERS WHERE STATUS='NEW' ORDER BY NAME
                </constant>
            </setBody>
            <to uri="jdbc:dataSource" />
            <split>
                <simple>${body}</simple>
                <to uri="bean:orderProcessor" />
            </split>
        </route>
    </camelContext>
</beans>

pom.xml

<properties>
        <!-- General Properties -->
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- Apache Camel -->
        <apache.camel.version>2.17.3</apache.camel.version>

        <!-- Spring Framework -->
        <spring.version>4.3.1.RELEASE</spring.version>

        <!-- MYSQL -->
        <mysql.version>5.1.39</mysql.version>

        <!-- Logging Framework -->
        <logback.version>1.1.7</logback.version>
        <jcl-over-slf4j.version>1.7.21</jcl-over-slf4j.version>

        <!-- Junit Framework -->
        <junit.version>4.12</junit.version>
    </properties>


    <dependencies>
        <!-- Spring Context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- Spring JDBC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- Camel core -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-core</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

        <!-- camel stream -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-stream</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

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

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

        <!-- camel JDBC -->
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jdbc</artifactId>
            <version>${apache.camel.version}</version>
        </dependency>

        <!-- MYSQL -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>

        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

Bild:
CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false); deprecated in camel-version 2.17.3

InformationsquelleAutor | 2016-09-02



One Reply
  1. 8

    Müssen Sie einfach in der unten verwenden. Fertig !

    public class CamelTimerSqlQueryExample {
        public static final void main(String[] args) throws Exception {
            ApplicationContext appContext = new ClassPathXmlApplicationContext("timerSelectQueryApplicationContext.xml");
            CamelContext camelContext = new SpringCamelContext(appContext) ;
            try {
                camelContext.start();
                Thread.sleep(5000);
            } finally {
                camelContext.stop();
            }
        }
    }
    • Ich suchte nach diesem für einige Zeit! danke!!!
    • Bitte akzeptieren/upvote die Antwort !

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.