How to use Play-mini within Akka microkernel?

286 views
Skip to first unread message

Fedor Tokarev

unread,
Jun 25, 2012, 12:37:51 PM6/25/12
to akka...@googlegroups.com
I've read the blog post at letitcrash.com about Play-mini and Akka (http://letitcrash.com/post/17888436664/a-sample-application-showcasing-play-mini-and-akka) and just can't get my head around on how to use Play-mini inside Akka microkernel. Since there is no use of Global object, I need to turn on play-mini manually, right? The question is, how to do it?


PS I've already asked this question on Stack Overflow (http://stackoverflow.com/questions/11184583/how-to-use-play-mini-within-akka-microkernel). Since there is no answer yet, I decided to duplicate it here.

Patrik Nordwall

unread,
Jun 25, 2012, 4:20:58 PM6/25/12
to akka...@googlegroups.com
Play provides similar things, so for running a Play-mini app you don't need Akka microkernel.

You can start play/play-mini with a shell script containing something like this:

java -cp "${your_classpath}" -Dhttp.port=9000 play.core.server.NettyServer

If you have a reason to use the microkernel, I'm sure we can solve that also, it's easy to start Play programmatically.


On Mon, Jun 25, 2012 at 6:37 PM, Fedor Tokarev <ftok...@gmail.com> wrote:
I've read the blog post at letitcrash.com about Play-mini and Akka (http://letitcrash.com/post/17888436664/a-sample-application-showcasing-play-mini-and-akka) and just can't get my head around on how to use Play-mini inside Akka microkernel. Since there is no use of Global object, I need to turn on play-mini manually, right? The question is, how to do it?


PS I've already asked this question on Stack Overflow (http://stackoverflow.com/questions/11184583/how-to-use-play-mini-within-akka-microkernel). Since there is no answer yet, I decided to duplicate it here.

--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/94EtkUsZKXAJ.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.



--

Patrik Nordwall
Typesafe The software stack for applications that scale
Twitter: @patriknw


Fedor Tokarev

unread,
Jun 25, 2012, 11:13:04 PM6/25/12
to akka...@googlegroups.com
Patrik,
thanks for the response,

>
> If you have a reason to use the microkernel, I'm sure we can solve that
> also, it's easy to start Play programmatically.
>

That's exactly what I need -- start Play programmatically inside Akka
microkernel

Patrik Nordwall

unread,
Jun 26, 2012, 1:44:31 AM6/26/12
to akka...@googlegroups.com
You can start it from your boot class with:
play.core.server.NettyServer.main(Array())


In case you need to use a different name of the global you can use something similar to the following hack - hope that you don't need it.. Then you might need to do that before the microkernel is started and not in the boot class, i.e. you need to define your own main that does the initPlayGlobalName first and then starts the microkernel.

// this is a separate object from QueryGlobal because we need to run
// the System.setProperty hack below, before we construct the mini.Setup
object QueryMain {
  def main(args: Array[String]): Unit = {
    initPlayGlobalName()

    play.core.server.NettyServer.main(Array())
  }

  /**
   * Must be done as very first thing, before loading config.
   */
  def initPlayGlobalName() {
    if (System.getProperty("application.global") == null && System.getProperty("global") == null) {
      // can't use QueryGlobal.getClass.getName because it would run mini.Setup
      val name = "akka.atmos.analytics.http.QueryGlobal"
      // this is a hack because there's no NettyServer.createServer(GlobalSettings),
      // only the lookup by classpath
      // setting two config options to handle play 2.0 bug
      System.setProperty("application.global", name)
      System.setProperty("global", name)
      // be sure the config lib hadn't already loaded props
      require(ConfigFactory.systemProperties().getString("application.global") == name)
    }
  }
}

object QueryGlobal extends com.typesafe.play.mini.Setup(akka.atmos.analytics.http.Gateway)

 

--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.

Jonas Bonér

unread,
Jun 26, 2012, 3:55:32 AM6/26/12
to akka...@googlegroups.com
This should go in the docs.
Jonas Bonér
Phone: +46 733 777 123
Home: http://jonasboner.com
Twitter: @jboner

Jonas Bonér

unread,
Jun 26, 2012, 3:58:01 AM6/26/12
to akka...@googlegroups.com

phausel

unread,
Jun 26, 2012, 3:11:37 PM6/26/12
to akka...@googlegroups.com
FYI, I also responded here:
Peter
>>> For more options, visit this group at
>>> http://groups.google.com/group/akka-user?hl=en.
>>>
>>
>>
>>
>> --
>>
>> Patrik Nordwall
>> Typesafe -  The software stack for applications that scale
>> Twitter: @patriknw
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Akka User List" group.
>> To post to this group, send email to akka...@googlegroups.com.
>> To unsubscribe from this group, send email to

Fedor Tokarev

unread,
Jun 27, 2012, 2:39:22 PM6/27/12
to akka...@googlegroups.com
Thanks for help!

Patrik, I've added your answer to my Stack Overflow post.

Anyway, I've decided to go with Spray, since Play-mini is actually not
so mini and brings the whole Play framework as its dependency.
>> >>> akka-user+...@googlegroups.com.
>> >>> For more options, visit this group at
>> >>> http://groups.google.com/group/akka-user?hl=en.
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >>
>> >> Patrik Nordwall
>> >> Typesafe -  The software stack for applications that scale
>> >> Twitter: @patriknw
>> >>
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Akka User List" group.
>> >> To post to this group, send email to akka...@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> akka-user+...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/akka-user?hl=en.
>> >
>> >
>> >
>> > --
>> > Jonas Bonér
>> > Phone: +46 733 777 123
>> > Home: http://jonasboner.com
>> > Twitter: @jboner
>>
>>
>>
>> --
>> Jonas Bonér
>> Phone: +46 733 777 123
>> Home: http://jonasboner.com
>> Twitter: @jboner
>
> --
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/akka-user/-/OxyLkyi6lOIJ.
>
> To post to this group, send email to akka...@googlegroups.com.
> To unsubscribe from this group, send email to
> akka-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages