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???
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With