2

I have Scala IDE already setup because I used it for Coursera course "Functional Programming Principles in Scala" by Martin Odersky.

Now i want to use Akka framework in the same IDE.

Is there any Scala IDE Akka plugin available which i can import directly?

I tried to reference all the akka provided jars in a new Scala Project. I am able to run the basic akka example this way.

But when I try to work with Dispatchers, the code is not compiling.

object TestActor {
    val dispatcher = Dispatchers.newExecutorBasedEventDrivenWorkStealingDispatcher("pool")
               .setCorePoolSize(100)
               .setMaxPoolSize(100)
               .build
}

I am trying to use Akka 2.0.2 on Scala 2.9

What is the surest way to configure and run akka 2.0.2 or 2.0.4 in Scala IDE?

Jonathan
  • 20,053
  • 6
  • 63
  • 70
weima
  • 4,653
  • 6
  • 34
  • 55
  • What's the error you get? What do your imports look like? – James Moore Nov 27 '12 at 14:32
  • for the above code, i get error: ` newExecutorBasedEventDrivenWorkStealingDispatcher is not a member of object akka.dispatch.Dispatchers` – weima Nov 27 '12 at 14:40
  • Imports: import akka.actor._ import akka.actor.Actor import akka.actor.Actor._ import akka.dispatch._ import akka.dispatch.Dispatchers – weima Nov 27 '12 at 14:41
  • Have you tried actually running this code or compiling it manually from command line? Last time I was using Scala IDE (about half a year ago) it was full of bugs, threw random errors, messed up imports etc. So I wouldn't be surprised if the IDE was responsible for this. – ghik Nov 27 '12 at 16:28
  • 1
    When I was choosing my preferred Scala development platform I stumbled upon a lot of comments like this (Scala IDE still full of bugs) with the consequence that I almost did not try Scala IDE. Just to encourage others: Today I'm absolutely delighted by Scala IDE and it works perfectly. Okay, almost ;). But "full of bugs" is imho not justified. – bluenote10 Nov 27 '12 at 17:02
  • FWIW, I use IntelliJ with the Scala plugin every day with no issues. – Larsenal Nov 27 '12 at 17:03
  • This worked very well for me: http://stackoverflow.com/questions/12612287/setting-up-akka-with-eclipse – Plasty Grove Nov 29 '12 at 00:00

3 Answers3

3

You're mixing up Akka 1.x APIs (Dispatcher.newXXX) with Akka 2.0 APIs. Please refer to the reference documentation: http://doc.akka.io/docs/akka/2.0.4/

Viktor Klang
  • 26,479
  • 7
  • 51
  • 68
0

For setting up a quick and dirty Akka 2.0.2 project in IntelliJ, I've had the best luck using Maven. My guess is you could probably get Scala IDE to use Maven to pull in the dependencies using something like what I show below. My pom.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <name>myProject</name>
    <groupId>myProject</groupId>
    <artifactId>myProject</artifactId>
    <packaging>jar</packaging>
    <version>0.1</version>
    <url>http://example.com</url>

    <dependencies>
        <dependency>
            <groupId>com.typesafe.akka</groupId>
            <artifactId>akka-actor</artifactId>
            <version>2.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.9.0-1</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>typesafe</id>
            <name>Typesafe Repository</name>
            <url>http://repo.typesafe.com/typesafe/releases/</url>
        </repository>
    </repositories>
</project>
Larsenal
  • 49,878
  • 43
  • 152
  • 220
  • is it enough that i put all the akka 2.0.4 jars on the Scala IDE project Build Path? will it work as 'akka' framework? i am not sure where to put the `application.conf` file. which class reads the `.conf` file? where does it look for the `.conf` file? – weima Nov 28 '12 at 08:40
  • If it builds, you're probably in good shape. The location of the `*.conf` files is guided by conventions but can be passed in as a parameter. Check the Akka docs and/or ask a specific question along those lines. – Larsenal Nov 28 '12 at 08:56
0

Here is the surest way.

I was in the same situation as you - I just finished the coursera class, had the integrated Scala IDE set up, want to explore Akka. Here is what I found.

Go to Installing the Typesafe Stack. Follow the instructions for setting up scala, sbt, giter8 etc. for your machine. Go to Getting Started With Akka (Scala). This will take you through how to use the Typesafe templates to get an Akka project set up just like you were used to in the coursera class. Pay special attention to "Setting up The Scala IDE for Eclipse (optional)". Adding that, you will have a Scala project, with all the Akka dependencies installed, ready to develop in Eclipse. You'll feel right at home.

rr_cook
  • 136
  • 4