camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthias L√ľneberg <matthias.lueneb...@googlemail.com>
Subject Re: Camel Scala DSL and IntelliJ
Date Tue, 12 Feb 2013 10:41:38 GMT
Hi,

thanks for the help Henryk. I use sbt for my scala development.

Joe, last time I just checked if the Route compiles and starts properly. For me it did.
Now I did a small simple project on my own using camel 2.10.1, scala 2.9.2 and sbt.

The following code worked for me:

package it.lueneberg

import org.apache.camel.impl.DefaultCamelContext
import org.apache.camel.scala.dsl.builder.RouteBuilder
import org.apache.camel.LoggingLevel


object ExampleTest extends App {

  override def main(args: Array[String]) {

    val camelContext = new DefaultCamelContext()

    camelContext.addRoutes(new RouteBuilder() {
      "file://in/".id("fileRoute").log(LoggingLevel.DEBUG,"Moved '${file:name}' to output
dir!").to("file://out_camel/")
    })

    camelContext.start()

    Thread.sleep(10000)

    camelContext.stop()

  }
}

Here is the log output:

info] Running it.lueneberg.ExampleTest 
[                      run-main] DefaultCamelContext            INFO  Apache Camel 2.10.1
(CamelContext: camel-1) is starting
[                      run-main] ManagementStrategyFactory      INFO  JMX enabled.
[                      run-main] DefaultTypeConverter           INFO  Loaded 176 type converters
[                      run-main] DefaultCamelContext            INFO  Route: fileRoute started
and consuming from: Endpoint[file://in/]
[                      run-main] ultManagementLifecycleStrategy INFO  StatisticsLevel at All
so enabling load performance statistics
[                      run-main] DefaultCamelContext            INFO  Total 1 routes, of which
1 is started.
[                      run-main] DefaultCamelContext            INFO  Apache Camel 2.10.1
(CamelContext: camel-1) started in 0.250 seconds
[amel-1) thread #0 - file://in/] fileRoute                      DEBUG Moved 'somefile.txt'
to output dir!
[                      run-main] DefaultCamelContext            INFO  Apache Camel 2.10.1
(CamelContext: camel-1) is shutting down
[                      run-main] DefaultShutdownStrategy        INFO  Starting to graceful
shutdown 1 routes (timeout 300 seconds)
[el-1) thread #2 - ShutdownTask] DefaultShutdownStrategy        INFO  Route: fileRoute shutdown
complete, was consuming from: Endpoint[file://in/]
[                      run-main] DefaultShutdownStrategy        INFO  Graceful shutdown of
1 routes completed in 0 seconds
[                      run-main] DefaultTypeConverter           INFO  TypeConverterRegistry
utilization[attempts=8, hits=8, misses=0, failures=0] mappings[total=176, misses=0]
[                      run-main] DefaultCamelContext            INFO  Apache Camel 2.10.1
(CamelContext: camel-1) is shutdown in 0.007 seconds. Uptime 10.259 seconds.

Another guess from me is to check the import section of your Route to really import the scala
dsl stuff.

If you your endpoint is like "from("file:test.xml")" camel searches in the root of your project
for "test.xml". If it finds nothing than it creates a dir with the given name (testet on Mac
osx). I usually work with folders (see "in" / "out_camel").

I hope this will help you. If you have any question don't hesitate to ask.

Matthias

Am 12.02.2013 um 11:12 schrieb Henryk Konsek <hekonsek@gmail.com>:

>> I'm just trying a simple Scala DSL using intelli.
> 
> Just a little suggestion from me. If you plan to play around with
> Scala DSL, create small Maven project and always verify Scala errors
> generated by IntelliJ by executing 'mvn clean compile'. IntelliJ Scala
> plugin sometimes gets confused for some reason and produces false
> compilation errors. Maven always tells you the compilation truth :) .
> 
> -- 
> Henryk Konsek
> http://henryk-konsek.blogspot.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message