Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lightbend Lagom and Akka: Unable to hit rest endpoint of lagom services

I am creating lagom simple application, with define one rest end point and hit end point using rest client postman. But In response I am getting, action not found error. I am integrate Akka with lagom, Following is my code:

Service:

trait TwitterSchedulerService extends Service {

  def doWork: ServiceCall[NotUsed, Done]

  override def descriptor: Descriptor = {
    import Service._
    named("scheduler").withCalls(
      call(doWork)
    )
  }
}

ServiceImpl:

class TwitterSchedulerServiceImpl(system: ActorSystem) extends TwitterSchedulerService {

  override def doWork = ServiceCall { _ =>
    Future {
      println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ")
      Done
    }
  }
}

Loader Configuration :

class TwitterLoader extends LagomApplicationLoader {

  override def load(context: LagomApplicationContext): LagomApplication =
    new TwitterApplication(context) {
      override def serviceLocator = NoServiceLocator
    }

}

object TwitterSerializerRegistry extends JsonSerializerRegistry {

  override val serializers = Vector(
    JsonSerializer[String]
  )
}

abstract class TwitterApplication(context: LagomApplicationContext) extends LagomApplication(context)
  with CassandraPersistenceComponents with AhcWSComponents {

  override lazy val lagomServer = LagomServer.forServices(
    bindService[TwitterSchedulerService].to(wire[TwitterSchedulerServiceImpl])
  )
  override lazy val jsonSerializerRegistry = TwitterSerializerRegistry
}

I am following lagom documentation http://www.lagomframework.com/documentation/1.3.x/scala/Akka.html. I want to know, why this error occur, event all rest points are defined???

like image 959
Harmeet Singh Taara Avatar asked Jan 04 '23 12:01

Harmeet Singh Taara


1 Answers

Your service is running at http://localhost:57211

http://localhost:9000 is running a Service Gateway server that acts as a reverse proxy to all of the services running in your project.

The Service Gateway can be configured to forward service calls onto your service, but it does not by default. You configure it by defining ACLs (access control lists) in your service descriptors.

Most commonly, you'll call withAutoAcl(true) to automatically forward all service call paths to your service:

trait TwitterSchedulerService extends Service {

  def doWork: ServiceCall[NotUsed, Done]

  override def descriptor: Descriptor = {
    import Service._
    named("scheduler").withCalls(
      call(doWork)
    ).withAutoAcl(true)
  }
}

If you want more control over which paths get forwarded from the Service Gateway to the back-end service, you can call withAcls to pass a list of explicit methods and path regular expressions that should be forwarded from the Service Gateway:

trait TwitterSchedulerService extends Service {

  def doWork: ServiceCall[NotUsed, Done]

  override def descriptor: Descriptor = {
    import Service._
    named("scheduler").withCalls(
      call(doWork)
    ).withAcls(
      ServiceAcl.forPathRegex("/doWork")
    )
  }
}

If you deploy to ConductR (part of the Lightbend Production Suite), these ACL configurations in your service descriptor are also used to generate ConductR ACL configuration.

like image 132
Tim Moore Avatar answered Jan 13 '23 03:01

Tim Moore