Configuring actor behavior using typesafe Config and HOCON

Configuring actor behavior using typesafe Config and HOCON

By : Tatsuo Ikeda
Date : November 18 2020, 11:13 AM
Hope that helps interesting case. If I understood you right, you want to configure Market actor mixing in some MatchingEngine type specified in config?
Some clarification: you can't simply mix in dynamic type. I mean if you move MatchingEngine type to config - it will be known only at runtime, when config is parsed. And at that time you'll not be able to instantiate new DoubleAuctionMarket(security) with ???SomeClassInstance???. But maybe you could replace inheritance with aggregation. Maybe an instance of MatchingEngine can be passed to Market as parameter?
code :
class Exchange extends Actor {

  val orderRoutingLogic = new OrderRoutingLogic()
  val matchingEngineClass = context.system.settings.config.getString("stocks.matching-engine")
  val matchingEngine = DynamicAccess.createInstance[MatchingEngine](matchingEngineClass)

  val router = {

    val marketsForSecurities = securities.foreach { security =>

      val marketForSecurity = context.actorOf(DoubleAuctionMarket.props(security, matchingEngine))
      orderRoutingLogic.addMarket(security, marketForSecurity)



Share : facebook icon twitter icon
Typesafe Config - reference.conf different behavior?

Typesafe Config - reference.conf different behavior?

By : user3404443
Date : March 29 2020, 07:55 AM
may help you . It seems that the bindaddress is of a different type because it shows up differently in logs.
In either case enable Akka full config printing on start with this setting in your config:
code :
log-config-on-start = on
Assigning config values with HOCON and C#

Assigning config values with HOCON and C#

By : user3755119
Date : March 29 2020, 07:55 AM
this will help Just like any other config format, HOCON is designed for static configuration. However you can attach multiple HOCON config strings as fallbacks, that means if searched config key won't be found in top level configuration, reader will use next fallback configuration in order to find a correct key-value. This is a recursive operation.
If you want to configure those values dynamically, you have two options.
Typesafe config HOCON - guidance for environment variable replacement of lists?

Typesafe config HOCON - guidance for environment variable replacement of lists?

By : Armin Radnia
Date : March 29 2020, 07:55 AM
around this issue If I read your Post (I don't see a real "question" in there) correct, you're trying to find a way to add different values to your CORS list, depending on which environment your app is running.
I would suggest to tackle this from another perspective: Create different configuration files which contain the values you want to customise and include the general application.conf file. In your deployment configuration, make play load your staged configuration instead of application.conf.
code :
javaOptions in Universal ++= Seq(
include "application.conf"
play.filters.cors {
      # whitelist all paths
      pathPrefixes = ["/"]
      allowedOrigins = [

play.filters.cors.allowedOrigins = [${?ORIGIN_1}] ${play.filters.cors.allowedOrigins}
play.filters.cors.allowedOrigins = [${?ORIGIN_2}] ${play.filters.cors.allowedOrigins}
How can I generate typesafe config (Hocon) file dynamically in scala (generate config file)

How can I generate typesafe config (Hocon) file dynamically in scala (generate config file)

By : Toni2013
Date : March 29 2020, 07:55 AM
Any of those help I'm not sure if I'm understanding your problem well...
But it seems to me, that you only need to format your Map as a HOCON-like String.
code :
import collection.JavaConverters._

def toHocon(map: java.util.Map[String, AnyRef]): String =
   .map { case (key, value) => s"$key : $value" }
   .mkString("block{\n\t", "\n\t", "\n}")
Load typesafe configs in HOCON format from custom locations at runtime

Load typesafe configs in HOCON format from custom locations at runtime

By : user3254086
Date : March 29 2020, 07:55 AM
I wish this helpful for you Store config in HDFS/S3/ADFS/Local file system, pass Configuration file path to the program as argument, read config file as input stream (or file) form the configuration file path.
code :
val confPath = args(0) //Configuration file path
val stream = Client.getObject(confPath) //Client -> HDFS/S3/ADFS/Local
val configString = Source.fromInputStream(stream.asInstanceOf[InputStream]).mkString
val config = ConfigFactory.parseString(configString)
Related Posts Related Posts :
  • Assign generic method to variable in Scala
  • General Finite State Machine (Transducer) in Scala
  • What is the usage of a final var in Scala
  • Define Generic Types with String
  • Why there is a ClassCastException when isInstanceOf returns true on a scala type with wildcard parameter?
  • How to reaload scala application after code change using actors and sbt
  • akka non-blocking BoundedMailbox
  • Why are constructor parameters made into members for case classes?
  • Higher order tail recursive function needs to terminate early
  • How can I reusably filter based on type in Scala?
  • Why does Scala sbt update every time I start it from command prompt?
  • Recommended Scala io library
  • Thread-safely transforming a value in a mutable map
  • Why does chaining match expressions does not compile?
  • Ebean not persisting foreign keys
  • Difference between def m(p: T forSome {type T} and def m1(p:Any), is there any ? Explanation needed based on Scala Langu
  • macro does not find out enclosing vals
  • Spark : how to run spark file from spark shell
  • Flattening a list of lists to a set with exceptions in scala
  • flatMap implementation in Scala
  • Confused about a few lines code in a scala official document page
  • How to input parameters when running bash command with Scala
  • Location header is lost if max-redirects > 1
  • Controller Spec is using FakeApplication, but can't load test configuration
  • Scala code analyzer targets case variable names that are identical to the outer matched varables - "suspicous shado
  • Why does authorize directive execute after the code it's supposed to protect?
  • Scala. Checking if a Type is Comparable
  • Does having a private constructor on a value class negate the benefits of a value class?
  • How to transform submitted json in Play 2.0?
  • Scala warning match may not be exhaustive
  • Pure not a member of objective Promise in PlayFramework
  • How to unmarshal POST params and JSON body in a single route?
  • Spark:How to use join method?
  • is client thread-safe in Twitter Finagle
  • Why is the method accepts only one argument?
  • Scala Play 2.3 Working with gCloud Storage - any libs to go async?
  • spray.io strange get/delete/detach directives behavior
  • SBT cannot resolve class declared in src/main/scala in a src/test/scala test class
  • Scala typeclass without function argument
  • Scalatra: Migrating Jersey Filters to Scalatra
  • Compilation error when using Scaldi
  • Scalac hanging in phase typer
  • how to have different source code when cross-compiling Scala with sbt? (changes in MurmurHash)
  • How to set different scalacOptions per Scala version when cross-compiling using Build.scala?
  • Possible Bug in JDBC?
  • Is there a Scala compiler flag to warn when tail recursion is applied without annotation?
  • scala case class put methods in companion object?
  • multiproject sbt doesn't generate file structure
  • Scala "multilevel" abstract class / abstract objects replacement
  • Scala, getting the type parameters of a KList as an HList
  • Why does Play refuse form reporting "Cannot resolve method apply with such signature: Missing arguments"?
  • How to split string with trailing empty strings in result?
  • Scala group by list of list and subtracts grouped values
  • Scala - Creating a function to produce Unary string or integer values
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org