All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.spring.camel-context.xml Maven / Gradle / Ivy

There is a newer version: 2.19.5
Show newest version
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <!-- START SNIPPET: e1 -->
  <!-- this is the JDBC data source which uses an in-memory only Apache Derby database -->
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
    <property name="url" value="jdbc:derby:memory:orders;create=true"/>
    <property name="username" value=""/>
    <property name="password" value=""/>
  </bean>

  <!-- bean which creates/destroys the database table for this example -->
  <bean id="initDatabase" class="org.apache.camel.example.sql.DatabaseBean"
        init-method="create" destroy-method="destroy">
    <property name="dataSource" ref="dataSource"/>
  </bean>

  <!-- configure the Camel SQL component to use the JDBC data source -->
  <bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
    <property name="dataSource" ref="dataSource"/>
  </bean>
  <!-- END SNIPPET: e1 -->

  <!-- START SNIPPET: e2 -->
  <!-- order bean is our business logic bean that creates new orders -->
  <bean id="orderBean" class="org.apache.camel.example.sql.OrderBean"/>

  <!-- here is Camel configured with a number of routes -->
  <camelContext xmlns="http://camel.apache.org/schema/spring">

    <!-- use Camel property placeholder loaded from the given file -->
    <propertyPlaceholder id="placeholder" location="classpath:sql.properties"/>

    <!-- route that generate new orders and insert them in the database -->
    <route id="generateOrder-route">
      <from uri="timer:foo?period=5s"/>
      <transform>
        <method ref="orderBean" method="generateOrder"/>
      </transform>
      <to uri="sql:{{sql.insertOrder}}"/>
      <log message="Inserted new order ${body[id]}"/>
    </route>

    <!-- route that process the orders by picking up new rows from the database
         and when done processing then update the row to mark it as processed -->
    <route id="processOrder-route">
      <from uri="sql:{{sql.selectOrder}}?consumer.onConsume={{sql.markOrder}}"/>
      <to uri="bean:orderBean?method=processOrder"/>
      <log message="${body}"/>
    </route>

  </camelContext>
  <!-- END SNIPPET: e2 -->

</beans>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy