Static service locator configuration

290 views
Skip to first unread message

Tugdual Sarazin

unread,
Jan 16, 2017, 9:55:50 AM1/16/17
to Lagom Framework Users
Hello,

I can't configure a static service locator, I've read lot of posts about this subject but I didn't find a solution.

So, I've cloned the HelloWorld project removed the stream service and configured application.conf and HelloServiceModule.java like that:

application.conf
lagom.services {
  cas_native = "tcp://127.0.0.1:9042/cas_native"
}


HelloServiceModule.java
@Override
protected void configure() {
 bindServices
(serviceBinding(HelloService.class, HelloServiceImpl.class));

 
if (environment.isProd()) {
   bind
(ServiceLocator.class).to(ConfigurationServiceLocator.class);
 
}
}



It works with an implementation that doesn't use Cassandra.
@Override
public ServiceCall<NotUsed, String> hello2() {
 
return request -> CompletableFuture.completedFuture("Hello2");
}


But it doesn't with an implementation that use Cassandra.
@Override
public ServiceCall<NotUsed, String> hello() {
 
return request -> {
   
String id = "test";
   
PersistentEntityRef<HelloCommand> ref = persistentEntityRegistry.refFor(HelloWorld.class, id);
   
return ref.ask(new HelloCommand.Hello(id, Optional.empty()));
 
};
}

Error logs:
[error] helloservice - Exception in PathCallId{pathPattern='/hello'}
akka
.pattern.AskTimeoutException: Ask timed out on [Actor[akka://application/system/sharding/HelloWorld#-399919086]] after [5000 ms]. Sender[null] sent message of type "com.lightbend.lagom.javadsl.persistence.CommandEnvelope".
 at akka
.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:604)
 at akka
.actor.Scheduler$$anon$4.run(Scheduler.scala:126)
 at scala
.concurrent.Future$InternalCallbackExecutor$.unbatchedExecute(Future.scala:601)
 at scala
.concurrent.BatchingExecutor$class.execute(BatchingExecutor.scala:109)
 at scala
.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:599)
 at akka
.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(LightArrayRevolverScheduler.scala:331)
 at akka
.actor.LightArrayRevolverScheduler$$anon$4.executeBucket$1(LightArrayRevolverScheduler.scala:282)
 at akka
.actor.LightArrayRevolverScheduler$$anon$4.nextTick(LightArrayRevolverScheduler.scala:286)
 at akka
.actor.LightArrayRevolverScheduler$$anon$4.run(LightArrayRevolverScheduler.scala:238)
 at java
.lang.Thread.run(Thread.java:745)
[warn] a.c.s.ShardRegion - Trying to register to coordinator at [None], but no acknowledgement. Total [1] buffered messages.
[warn] a.c.s.ShardRegion - Trying to register to coordinator at [None], but no acknowledgement. Total [1] buffered messages.
[warn] a.c.s.ShardRegion - Trying to register to coordinator at [None], but no acknowledgement. Total [1] buffered messages.
[warn] a.c.s.ShardRegion - Trying to register to coordinator at [None], but no acknowledgement. Total [1] buffered messages.
[warn] a.c.s.ShardRegion - Trying to register to coordinator at [None], but no acknowledgement. Total [1] buffered messages.
...


Of course I've started a local Cassandra database (Cassandra 3.0.10).

Note: I've also tried with a zookeeper service locator, it doesn't work too but for others issues.

Thanks

James Roper

unread,
Jan 16, 2017, 7:21:54 PM1/16/17
to Tugdual Sarazin, Lagom Framework Users
Hi Tugdual,

The problem is most likely not related to Cassandra or your service locator, rather, it's most likely related to Akka cluster.  Persistent entities won't respond to any commands until an Akka cluster has successfully been formed.  Documentation on how to do this is here:


If you only have one node (then you really should rethink your deployment, since running with one node is not resilient) you can tell a Lagom node to form a cluster with itself by setting:

lagom.cluster.join-self = true

Regards,

James

--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/3c46333b-5400-4b0a-884a-a1aebe910f1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
James Roper
Software Engineer

Lightbend – Build reactive apps!
Twitter: @jroper

Tugdual Sarazin

unread,
Jan 17, 2017, 1:06:20 PM1/17/17
to James Roper, Lagom Framework Users
Hi James,

Thanks a lot, your configuration solved my problem.

An yes I know it's not resilient but for the moment my project is just a proof of concept. I'll move to a more resilient architecture in few weeks.

Regards,
Tugdual

To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framewo...@googlegroups.com.
To post to this group, send email to lagom-f...@googlegroups.com.



--
James Roper
Software Engineer

Lightbend – Build reactive apps!
Twitter: @jroper

--
You received this message because you are subscribed to a topic in the Google Groups "Lagom Framework Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lagom-framework/Dd1pzFiNt1E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lagom-framewo...@googlegroups.com.
To post to this group, send email to lagom-f...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/CABY0rKPnAeOKnsvYheF0qqrLpLrLDPzXzc9s9tLDbsGsMEzwbg%40mail.gmail.com.
Message has been deleted

Ignasi Marimon-Clos i Sunyol

unread,
Apr 9, 2018, 6:06:57 AM4/9/18
to Aseem Sharma, Lagom Framework Users [deprecated]

On Wed, Apr 4, 2018 at 12:07 PM, Aseem Sharma <aseem.s...@gmail.com> wrote:
Hello,

Even I am observing the same issue as described by Tugdual while trying my hands on Hello World using sbt as described here https://www.lagomframework.com/documentation/1.4.x/java/GettingStartedSbt.html.
Kindly note that I have slightly modified the Hello World source code to carry out certain task which seems to be taking more than 5 seconds to complete (the rest of the framework is untouched).
I am also using a single node setup to understand the Lagom framework (kind of POC) and do not have liberty to add any more nodes at this point.

Question: Is there any way to increase the timeout to say 5 minutes? Can you please provide the exact details?

Following is the exact error message for your kind reference:
{
  "name": "akka.pattern.AskTimeoutException: Ask timed out on [Actor[akka://hello-impl-application/system/sharding/HelloEntity#-66507475]] after [5000 ms]. Sender[null] sent message of type \"com.lightbend.lagom.javadsl.persistence.CommandEnvelope\".",
  "detail": "akka.pattern.AskTimeoutException: Ask timed out on [Actor[akka://hello-impl-application/system/sharding/HelloEntity#-66507475]] after [5000 ms]. Sender[null] sent message of type \"com.lightbend.lagom.javadsl.persistence.CommandEnvelope\".\n\tat akka.pattern.PromiseActorRef$.$anonfun$defaultOnTimeout$1(AskSupport.scala:595)\n\tat akka.pattern.PromiseActorRef$.$anonfun$apply$1(AskSupport.scala:605)\n\tat akka.actor.Scheduler$$anon$4.run(Scheduler.scala:140)\n\tat scala.concurrent.Future$InternalCallbackExecutor$.unbatchedExecute(Future.scala:866)\n\tat scala.concurrent.BatchingExecutor.execute(BatchingExecutor.scala:109)\n\tat scala.concurrent.BatchingExecutor.execute$(BatchingExecutor.scala:103)\n\tat scala.concurrent.Future$InternalCallbackExecutor$.execute(Future.scala:864)\n\tat akka.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(LightArrayRevolverScheduler.scala:328)\n\tat akka.actor.LightArrayRevolverScheduler$$anon$4.executeBucket$1(LightArrayRevolverScheduler.scala:279)\n\tat akka.actor.LightArrayRevolverScheduler$$anon$4.nextTick(LightArrayRevolverScheduler.scala:283)\n\tat akka.actor.LightArrayRevolverScheduler$$anon$4.run(LightArrayRevolverScheduler.scala:235)\n\tat java.lang.Thread.run(Thread.java:748)\n"
}

Thanks for your time and help on this.
Do let me know in case you need any additional information. 

-Aseem

--
Please join our new forum at https://discuss.lagomframework.com!
The lagom-framework Google Group will soon be put into read-only mode.
For details, see https://www.lagomframework.com/blog/announcing-discuss-lagomframework-forum.html.
---
You received this message because you are subscribed to the Google Groups "Lagom Framework Users [deprecated]" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/27abedea-8b35-4012-99b9-f40dc1c50bf3%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Ignasi Marimon-Clos
Software Developer @ Lagom


Reply all
Reply to author
Forward
0 new messages