Lagom Cassandra setup

972 views
Skip to first unread message

Zlatko Josic

unread,
Jun 18, 2016, 12:34:50 PM6/18/16
to Lagom Framework Users
Hi,

I'm trying to setup lagom chirp example on dockers(everry microservice is one docker). I've finished full development/deployment circle (gitlab ci, nexus, rundeck) for this example. Cassandra server is also running as docker processes. 

Unfortunately I'm getting this error:

[warn] c.l.l.i.p.c.ServiceLocatorSessionProvider - Could not find Cassandra contact points, due to: org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.36:8500 refused

[warn] a.p.c.j.CassandraJournal - Failed to connect to Cassandra and initialize. It will be retried on demand. Caused by: org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.36:8500 refused



So, the problem is connection between microservice( friend-impl in this case) and cassandra server. 

How can I configure Lagom to use external cassandra server?

In Lagom's documentation http://www.lagomframework.com/documentation/1.0.x/ConductR.html there is explanation how to run cassandra in ConductorR.

Thanks for any help

Zlaja

Mirco Dotta

unread,
Jun 19, 2016, 3:56:16 AM6/19/16
to Zlatko Josic, Lagom Framework Users
Hi,

You will need to provide the address and port on which your Cassandra servers are running via the following configuration (to place in each of your project’s application.conf - yes, life is a lot easier when using ConductR as it does all these things automatically for you):

lagom.persistence.read-side.cassandra.contact-points (this is an array, i.e., [<contact-point-1>, <contact-point-2>, ...]
cassandra-journal.port
cassandra-journal.contact-points
cassandra-snapshot-store.port
cassandra-snapshot-store.contact-points

For the above config, the `port` is defaulted to 9042, while the `contact-points` are defaulted to  ["127.0.0.1”]

Also, you need to provide a keyspace that your application will use for the following configurations (different values are to be provided for each of your project)

cassandra-journal.keyspace
cassandra-snapshot-store.keyspace
lagom.persistence.read-side.cassandra.keyspace

One suggestion for naming the keyspaces is:

cassandra-journal.keyspace=“<your_project_name>”
cassandra-snapshot-store.keyspace=“<your_project_name>_snapshot”
lagom.persistence.read-side.cassandra.keyspace=“<your_project_name>_read”

As you really want the three keyspaces to be different.

Hope this will help,
Mirco

--
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-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/966a64b4-5a71-47b1-8ed9-33af89e7ca1e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zlatko Josic

unread,
Jun 19, 2016, 12:14:12 PM6/19/16
to Lagom Framework Users, zlatko...@gmail.com
I've configured cassandra, but I'am gettings this error now:

[warn] c.l.l.i.p.c.ServiceLocatorSessionProvider - Could not find Cassandra contact points, due to: null

[warn] c.l.l.i.p.c.ServiceLocatorSessionProvider - Could not find Cassandra contact points, due to: null


I've tryied to put akka.loglevel=DEBUG in application.conf to get something more meaningful but with no success. 
I can to telnet from microservice docker to host's ports where I published cassandra's ports.

Zlaja

Zlatko Josic

unread,
Jun 30, 2016, 7:36:19 AM6/30/16
to Lagom Framework Users, zlatko...@gmail.com
Sorry, I did not explain the problem well. I use consul for service locator. Docker for consul wasn't good so it was reason for null message error.  I solved that problem and I registered cassandra contact points in consul. 

Now, I have 4 docker for chirp example, but I'm facing to the other problem when I run the application. 

For example, If I want to sign up a new user I get http://host:9000/api/users 404 Not found. So, I think it is the gateway problem. Every docker, except front-end, has internal gateway and front-end does not see it. 

So, the question. How SPA (Single page application) should access services through the gateway or through the service locator?


Zlaja

Mirco Dotta

unread,
Jun 30, 2016, 7:58:05 AM6/30/16
to Zlatko Josic, Lagom Framework Users
Hi,

Have you started and configured a Service Gateway? The Service Gateway is an infrastructural component that you need to start and manage in your production environment, just like you are managing Consul for service discovery.

Cheers,
Mirco

Zlatko Josic

unread,
Jun 30, 2016, 8:27:58 AM6/30/16
to Lagom Framework Users, zlatko...@gmail.com
Hi, 

Thanks for quick response.

No, is that component part of Lagom framework or I have to find other implementation and an adapter like for consul?

Thanks for any hint.

Zlaja

Mirco Dotta

unread,
Jun 30, 2016, 8:42:45 AM6/30/16
to Zlatko Josic, Lagom Framework Users
Hi Zlaja,

No, there is no Service Gateway included in Lagom. Your confusion may originate from the fact that we have embedded a Service Gateway in the Lagom Development Environment, so that you don’t have to run and manage one on your own during development (the goal is boost developer productivity). Also, if you are using Lightbend Conductr in production, a Service Gateway is automatically configured and run for you. In ConductR we use HAProxy for this, so maybe you can have a look at it. And, to configure ConductR (and the HaProxy run by ConductR), we use the sbt-conductr plugin (https://github.com/typesafehub/sbt-conductr). I thought I’d mention the sbt plugin as you may want to create a similar one to automatically configure your Service Gateway.

An important point I’d like to make is that you actually may not need a Service Gateway at all, as you could just start the front-end service on port 9000 and be done with it.

Zlatko Josic

unread,
Jul 5, 2016, 2:32:32 PM7/5/16
to Lagom Framework Users, zlatko...@gmail.com
I did it with  haproxy. I had to change a server ( it wasn't able to run many services, it is old server).

Anyway, the example is fully running on dockers now.

Adding haproxy led me to  some questions. I will ask them in separated post.

Thanks for help.


Zlaja

Jules Ivanic

unread,
Sep 26, 2016, 5:37:00 AM9/26/16
to Lagom Framework Users
As a summary of what Mirco said to configure Cassandra, you'll have to add this in every service configuration :

lagom.persistence.read-side {
 
cassandra {
   
keyspace = "toto_service_read"
    # Comma-separated list of contact points in the Cassandra cluster
    contact-points = [${?CASSANDRA_HOST}]
   
# Port of contact points in the Cassandra cluster
    port = ${?CASSANDRA_PORT}
   
# To connect to the Cassandra hosts with credentials.
    # Authentication is disabled if username is not configured.
    authentication.username = ${?CASSANDRA_USER}
   
authentication.password = ${?CASSANDRA_PASSWORD}
 
}
}
cassandra-journal {
 
keyspace = "toto_service"
  # Comma-separated list of contact points in the Cassandra cluster
  contact-points = [${?CASSANDRA_HOST}]
 
# Port of contact points in the Cassandra cluster
  port = ${?CASSANDRA_PORT}
 
# To connect to the Cassandra hosts with credentials.
  # Authentication is disabled if username is not configured.
  authentication.username = ${?CASSANDRA_USER}
 
authentication.password = ${?CASSANDRA_PASSWORD}
}
cassandra-snapshot-store {
 
keyspace = "toto_service_snapshot"
  # Comma-separated list of contact points in the Cassandra cluster
  contact-points = [${?CASSANDRA_HOST}]
 
# Port of contact points in the Cassandra cluster
  port = ${?CASSANDRA_PORT}
 
# To connect to the Cassandra hosts with credentials.
  # Authentication is disabled if username is not configured.
  authentication.username = ${?CASSANDRA_USER}
 
authentication.password = ${?CASSANDRA_PASSWORD}
}

Valentin Jacquemin

unread,
Oct 5, 2016, 3:09:09 PM10/5/16
to Lagom Framework Users, zlatko...@gmail.com
Hi Zlaja,

I'm evaluating Lagom and I'd like to get the cargotracker lagom example on docker. Is your setup versioned anywhere?

Thanks,
Valentin


Le mardi 5 juillet 2016 20:32:32 UTC+2, Zlatko Josic a écrit :

Zlatko Josic

unread,
Nov 2, 2016, 6:29:18 PM11/2/16
to Lagom Framework Users, zlatko...@gmail.com
Hi Valentin,

Sorrry for this late response. 

No, it uses my internal gitlal, nexus and rundeck. 

I'm going to make an example, banking (creating accounts, transfering money) and put it on github.

I hope I will find time in next two weeks.

I can copy here my docker's files if you like, let me know.




Zlaja

michal....@gmail.com

unread,
Dec 15, 2016, 1:44:50 PM12/15/16
to Lagom Framework Users, zlatko...@gmail.com

Hi Zlaja,

I would be very grateful for posting your docker files here. Also, have you put up something related on Github? I am trying something similar, but I'm only a begginer in these topics and I'm struggling.

Thanks in advance

Michal

Anton Zagrebelny

unread,
May 3, 2017, 7:54:06 PM5/3/17
to Lagom Framework Users, zlatko...@gmail.com
It would be great if that example is ready by now :)
Reply all
Reply to author
Forward
0 new messages