lagom | A Jekyll blog theme with just the right amount of style | Theme library
kandi X-RAY | lagom Summary
kandi X-RAY | lagom Summary
Lagom, a Jekyll blog theme with just the right amount of style.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of lagom
lagom Key Features
lagom Examples and Code Snippets
Community Discussions
Trending Discussions on lagom
QUESTION
We observe that on increasing concurrent http calls to our service, thread count (akka.actor.default-dispatcher) keeps increasing (see screenshot from visualVM). Also after the requests stop, the thread count don’t go down. And most of these remain in PARK state. Is this proportional increase of threads an expected behaviour? How do we control this and reuse the same actors or kill the actors after request has been served.
I’m running the shopping-cart example from lagom-samples.
...ANSWER
Answered 2021-Apr-12 at 06:51Are you blocking in your calls? Eg, are you calling Thread.sleep? Or using some synchronous IO? If so, then what you're seeing is entirely expected.
Lagom is an asynchronous framework. All the IO and inter-service communication mechanisms it provides are non blocking. Its thread pools a tuned for non blocking. If you only using non blocking calls, you will see the thread pools behave with very low thread counts, and you won't find things going unresponsive.
But the moment you start blocking, all bets are off. Blocking requires one thread per request.
The default dispatcher that Akka uses is a fork join pool. It is designed for asynchronous use. If you block in a thread in its pool, it will start another thread to ensure other tasks can continue. So, that's why you see the thread pool grow. Don't block, and this won't happen.
The thread pool executor on the other hand uses a fixed number of threads. If you block on this, then you risk deadlocking the entire application. Don't block, and this won't happen.
QUESTION
I just started with Lagom & Akka. I am following the design decribed in Domain Modelling with Akka Persistence Typed
I am trying to create a brand new instance of an entity (EntityState
). But the event is not getting persisted, and I am getting the following error:
ANSWER
Answered 2020-Aug-31 at 21:31It seems that the real cause for the exception was because I should have added logic for handling the event as follows:
in helloEvents()
, I needed to add logic similar to the following:
QUESTION
I'm new to scala and I'm trying to integrate a PostgreSQL database to a Lagom application written in scala.I'm trying to utilise the persistence API of Lagom. Lagom has inbuilt support for slick.
My table has 3 fields id of type int, name of type string, data of type jsonb
Since Slick doesn't support json format I'm trying to use slick-pg .
Below is my implementation
My custom profile class
...ANSWER
Answered 2020-Jul-27 at 09:59Your object CustomPostgresProfile
extends PostgresProfile
instead of CustomPostgresProfile
. If you fix that, it works.
QUESTION
As part of deploying my lagom application to the kubernetes production environment, I am trying to publish all my logs to a file besides writing to the standard output. For this I created a logback.xml
under resources directory adding file appender as per suggestion here.
ANSWER
Answered 2020-May-30 at 06:03Writing to a file in a container is bad for two reasons:
1. Logs are available only within the container i.e.,would require to get into the container to see the logs
2. They are not available via kubectl log
command
3. They are ephemeral in nature i.e., if container crashes, logs will disappear
Instead writing to STDOUT and STDERR is considered as best practise in a container environment. The logs written to STDOUT and STDERR are redirected by docker engine to a location in the node (/var/log/containers/). Moreover, these logs are also available via kubectl logs
command.
Practically logs are not even preserved at even a node but are instead moved to a central logging system. You can read more about it here.
QUESTION
I'm currently trying to build an application that handles personal finances. I'm struggling with Lagom ways of doing because I can't find any example of "real" application built with Lagom. I have to guess what are best practises and I'm constantly afraid of falling into pitfalls.
My case is the following: I have Users, Accounts and Transactions. Accounts belong to users but can be "shared" between them (with some sort of authorization system, one user is admin and other can read or edit the account). Transactions have an optional "debit" account, an optional "credit" account and an amount which is always positive.
The scenarios I was considering are the followings:
- I consider that transactions belong to accounts and are parts of the account entity as a list of entries. In that scenario, a transfert transaction must have a "sister" entry in the other account. This seems easy to implement but I'm concerned by :
- the potential size of the entity (and the snapshots). What happen if I have accounts that contain thousands of ten of thousands of transactions?
- the duplication of the transaction in several accounts.
- I consider that transactions have their own service. I that case I can use Kafka to publish events when transactions are recorded so the Account entity can "update" it's balance. In that case does it make sense to have a "balance" property in the entity or a read-side event listener for transaction events that update the read-database?
- I can have two Persistent Entities in the same service but in that case I'm struggling with the read-side. Let say I have a transaction, I want to insert into the "transactions" table and update the "accounts" table. Should I have multiple read-side processors that listen to different events but write in the same db?
What do you think?
...ANSWER
Answered 2020-May-11 at 07:35I think that you shouldn't have a different entity 'Transactions' because it is tightly coupled to the account entity, in fact, the transactions of an account is no more than the event log of this account. So I recommend persisting the balance with a unique transaction id and the id of the other account when it is a transfer transaction, and make the read processor to listen the events of the account changes to store them in the read model.
Doing this, a transfer is just a message between the two accounts that results in a modification of the balance that later will be persistent as part of the event log of each of them. This way seems more natural and you don't have to manage a sepparate aggregate root that, in addition, is tightly coupled to the account entities.
QUESTION
I have the following configuration in my build.gradle file
...ANSWER
Answered 2020-May-08 at 21:36I was calling the wrong method. The openApiGenerators just list the generators which is what it was doing. To generate the output, you have to call the task created above openApiGenerate. Thanks @philonous for the answer.
QUESTION
The Play website says it should be in "conf", but the Lagom default HelloeWorld example places it under the "resources" directory within /applicationProject/src/main". "conf/" does not even show up anywhere in the directory structure in Lagom. Can someone clarify?
...ANSWER
Answered 2020-Mar-19 at 16:14According to default Play project layout
application.conf
located at conf/application.conf
. So if you will inject play.api.Configuration
this will represent parsed and loaded config from that file.
On another hand I suppose, Lagom is library, which relies on default Maven project layout, which differs from default Play layout, in which src/main/resources
is standard folder for resources like configuration, which is why in Lagom project example you see application.conf
in another folder then in Play.
What you can do as an option: take play.api.Configuration.underlying
and pass manually to Lagom code.
Or keep using standard Maven project layout for Play via special plugin introduced after version 2.6.8: https://www.playframework.com/documentation/2.6.x/Highlights26#PlayService-sbt-plugin-(experimental)
Hope this helps!
QUESTION
I know how to throw a bad request in Lagom by using
throw BadRequest("Bad Request")
but this will return with an http error code of 400. how do I return with a http error code of 409 (Conflict) for example?
...ANSWER
Answered 2020-Mar-17 at 05:59You need to create your custom exception that must be inherited from TransportException:
QUESTION
I am getting a login untried when trying to access a Rest API with authentication. I am using WS Play within Lagom. The login request looks something like:
...ANSWER
Answered 2020-Mar-03 at 05:37In the first request, you are logging in using HTTP Basic authentication. Does the site that you're using support HTTP basic authentication? Typically when a site does support it, it won't send you a cookie, rather, it will expect the login credentials to be sent with every request. So, when using HTTP basic authentication, there should be no need to login at the login URL, instead, add the username and password to the request to queryUrl
. If that doesn't work, then that could mean the site you are making requests on doesn't support HTTP Basic authentication.
The other type of login is to submit the username and password in a login form, and then site you are logging into will send you back a cookie which you can use for subsequent requests. That appears to be what you're trying to do, but to do that, you can't use the withAuth
method, rather, you have to find out what the username/password parameters are in the sites login form, and send a form with those parameters set. I can't tell you what those parameters are, that is entirely dependent on the site you're logging into, you'll have to look at the documentation for that site, or at the HTML it outputs on the login page. When you get back the response to the login request, you should check the response code to see if it was successful. The documentation for how to submit form parameters using Play WS can be found here, here's an example of what it might look like:
QUESTION
We're developing several Lagom-based Scala micro-services. They are configured using variable replacement in application.conf, eg.
...ANSWER
Answered 2020-Jan-23 at 14:20I've used Lightbend config to configure Lagom services via environment variables in docker containers for many years, so know that it can be done and has been pretty straightforward in my experience.
With that in mind, when you say that they're not used by application.conf
, do you mean that they're unset? Note that unless you're passing a very specific option as a Java property, configuration.getString("ENV_MYSQL_DATABASE_URL")
will not read from an environment variable, so checking that will not tell you anything about whether mysql.url
is affected by the environment variable. configuration.getString("mysql.url")
will give you a better idea of what's going on.
I suspect that in fact your Docker image is being built with the dev-mode properties hardcoded in, and since Java system properties take precedence over everything else, they're shadowing the environment variable.
You may find it useful to structure your application.conf
along these lines:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install lagom
Fork this repository
Clone it: git clone https://github.com/YOUR-USER/lagom
Install the GitHub Pages gem (includes Jekyll): bundle install
Run the jekyll server: jekyll serve
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page