Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Renato Cavalcanti
@renatocaval
@erip, there is another option to that which is a write-side support table. You maintain a crud table that is read on whenever you receive such a command and only after reading it you send the command to the entity
the advantage of this over another PE is that such a PE can grow undefinetely if have one PE to hold all unique ids.
the consistency guarantees are the same though, you may reserve an ID and don't use it because of failed command. You may want to have a read-side processor that keeps track of it and eventually delete garbage
you can also have one PE instance per ID, in such a case they won't grow undefinetely, but that's kind of abusing the journal. What is really needed here is a dumb crud model
Srepfler Srdan
@schrepfler
The spring data rest project has a bunch of implementations of HAL data structures, it might take an effort but you could probably port the stuff over
James Harlow
@hythloday

I'm trying to test a lagom service subscribing to another lagom service's topic as detailed in the docs and running into an error which I think is to do with object instantiation order, but I'm not sure how to fix it.

(My generating service is called A and my subscribing service is called B. They both work and pass tests on their own)

  1. In B's impl project, I import A's api project. Inside B's Application, I
  2. construct a ServiceClient for A, which is injected into B's Impl, which I
  3. use to subscribe to A's topic. To test this, I
  4. create a AServiceStub class in B's tests, and in the test call ServiceTest.withServer(...)(fn1)(fn2), which instantiates an instance of BApplication which has an (overridden) AServiceStub in fn1 and uses it in fn2.

My problem is: when fn1 is run, it instantiates a new BApplication, which mixes in LagomKafkaComponents, which starts registering TopicProducers, which constructs the LagomServer (serverFor[AService](wire[AServiceImpl]), which subscribes to the topic, which is of course still null since fn1 hasn't finished running. I can see I have to break the chain somewhere but it's not at all clear where - I could put the subscribe inside a lazy val and call it from every ServiceCall, but that's obviously disgusting. Has anyone run into this? Is there anywhere in example code where this is worked around? I looked but couldn't find anything.

Shubham Agarwal
@shubham4194
I have created two microservices. I am calling an API of Microservice1 from Microservice2. The api returns a custom exception with a custom error code, but at Microservice2, I receive TransportException(http errorcode 500) and my custom error code is lost. Due to this I am not able to do proper handling in Microservice2. How can I get the custom error code from Microservice1 at Microservice2?
@TimMoore : I have created two microservices. I am calling an API of Microservice1 from Microservice2. The api returns a custom exception with a custom error code, but at Microservice2, I receive TransportException(http errorcode 500) and my custom error code is lost. Due to this I am not able to do proper handling in Microservice2. How can I get the custom error code from Microservice1 at Microservice2?
Sergey Morgunov
@ihostage
Custom exception extend TransportException?
Shubham Agarwal
@shubham4194
@ihostage No
@ihostage I'll try that. Thanks
Sergey Morgunov
@ihostage
If I'm not mistaken, we can send only exception that extend TransportException. And custom exception must located in api module.
Shubham Agarwal
@shubham4194
@ihostage I was sending customExceptions that extended RuntimeExceptions
Lagom will generally be able to throw these exceptions through to the client. You may also instantiate TransportException directly and use that, or you may define a sub class of TransportException, however note that Lagom won’t throw the subclass in a client since it will not know about it.
For custom exception you need custom serializer :smile:
But, I think for common case, you can use TransportException and recognize type of exception by TransportException.ExceptionMessage.name
Sergey Morgunov
@ihostage
Also, if you use custom exception, don’t forget configure white list in circuit breakers.
https://www.lagomframework.com/documentation/current/java/ServiceClients.html#Circuit-Breaker-Configuration
Otherwise, circuit breaker will be opened by your business exceptions.
Shubham Agarwal
@shubham4194
@ihostage When using TransportException , we can recognize type of exception by TransportException.ExceptionMessage.name. Is there a way to provide custom error codes also?
Sergey Morgunov
@ihostage
Write custom exception serializer, how it described in docs :wink:
Shubham Agarwal
@shubham4194
@ihostage (Y) Thanks
:)
Matias Partanen
@humpahh_twitter
I'm getting "akka.http.scaladsl.model.EntityStreamException: HTTP chunk size exceeds the configured limit of 1048576 bytes" with ServiceCall for a impl defined in a build.sbt. "akka.http.server.parsing.max-chunk-size" in application.conf root or application.conf play { } -block doesn't seem to do anything. Where should Akka HTTP configuration in a Lagom microservice go?
Sergey Morgunov
@ihostage
@humpahh_twitter may be ask in akka/akka? Are you sure that problem on server side? May be it Akka HTTP Client?
Ignasi Marimon-Clos
@ignasi35
@humpahh_twitter to configure the Akka HTTP backend inside Play (which is what is powering Lagom under the covers), you need to prefix Akka HTTP settings with play.server. See https://www.playframework.com/documentation/2.6.x/SettingsAkkaHttp . So, in your case, I think you should use: play.server.akka.http.server.parsing.max-chunk-size
@humpahh_twitter you should keep in mind that Lagom’s DevMode uses a custom HTTP server which may ignore the settings in play.server scope.
Srepfler Srdan
@schrepfler
We were struggling a bit with the “external kafka cluster, subscriber only” service but finally we managed to make it work. would be nice to clean up the docs around that and provide an example
Work carries on!
Sergey Morgunov
@ihostage
@schrepfler You can help Lagom community and create PR for docs repository :wink:
jibbers42
@jibbers42
:point_up: September 25, 2018 2:59 AM @TimMoore where is the best place to write to the tracking crud table? In PE, the write would block command handling - In read-side, you would have a time window that allows duplicate IDs.
Well, I guess the read to check the table is blocking in the PE too right? So is that just the trade-off for this level of consistency or is there another option?
Srepfler Srdan
@schrepfler
am I correct in understanding that the lagom-javadsl-persistence-cassandra in the case of subscriber-only services is to keep the kafka offset inside cassandra?
(more/less equivalent of the external storage of offset in the reactive-kafka library)
Alan Klikić
@aklikic_twitter
@schrepfler for subscriber only service you do not require persistence. Subscribe offsets are stored in kafka.
Srepfler Srdan
@schrepfler
I thought so too, but without the cassandra persistance module this is what I’m getting when the service module starts
com.google.inject.CreationException: Unable to create injector, see the following errors:

1) No implementation for com.lightbend.lagom.javadsl.persistence.PersistentEntityRegistry was bound.
  while locating com.lightbend.lagom.javadsl.persistence.PersistentEntityRegistry
    for the 4th parameter of com.lightbend.lagom.internal.javadsl.persistence.ReadSideImpl.<init>(ReadSideImpl.scala:37)
  at com.lightbend.lagom.javadsl.persistence.PersistenceModule.bindings(PersistenceModule.scala:18):
Binding(class com.lightbend.lagom.internal.javadsl.persistence.ReadSideImpl to self) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)

2) No implementation for com.lightbend.lagom.spi.persistence.OffsetStore was bound.
  while locating com.lightbend.lagom.spi.persistence.OffsetStore
    for the 5th parameter of com.lightbend.lagom.internal.javadsl.broker.kafka.JavadslRegisterTopicProducers.<init>(JavadslRegisterTopicProducers.scala:33)
  at com.lightbend.lagom.internal.javadsl.broker.kafka.KafkaBrokerModule.bindings(KafkaBrokerModule.scala:13):
Binding(class com.lightbend.lagom.internal.javadsl.broker.kafka.JavadslRegisterTopicProducers to self eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)

2 errors
So it seems the OffsetStore is external to Kafka
Alan Klikić
@aklikic_twitter
@schrepfler you should use lagomJavadslKafkaClient not lagomJavadslKafkaBroker
Client does not require persistence dependency like broker does
Srepfler Srdan
@schrepfler
I don’t have the broker module in the classpath for this module
<dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>service-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.lightbend.lagom</groupId>
            <artifactId>lagom-javadsl-server_${scala.binary.version}</artifactId>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>com.lightbend.lagom</groupId>-->
            <!--<artifactId>lagom-javadsl-persistence-cassandra_${scala.binary.version}</artifactId>-->
        <!--</dependency>-->
        <dependency>
            <groupId>com.lightbend.lagom</groupId>
            <artifactId>lagom-javadsl-kafka-client_${scala.binary.version}</artifactId>
        </dependency>
        <dependency>
            <groupId>com.lightbend.lagom</groupId>
            <artifactId>lagom-logback_${scala.binary.version}</artifactId>
        </dependency>
        <dependency>
            <groupId>com.typesafe.play</groupId>
            <artifactId>play-akka-http-server_${scala.binary.version}</artifactId>
        </dependency>
        <dependency>
            <groupId>com.lightbend.lagom</groupId>
            <artifactId>lagom-javadsl-testkit_${scala.binary.version}</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
these are all the deps in the subscribe-only service module implementation
Alan Klikić
@aklikic_twitter
I do not use maven but sbt. I assume you checked this: https://www.lagomframework.com/documentation/1.4.x/java/KafkaClient.html
Srepfler Srdan
@schrepfler
we’re on the latest 1.5 milestone
Simon
@simon-lam
hello lagom experts - we've a Lagom cluster with 3 nodes deployed in Kubernetes with a persistent entity that uses Persitence and not DData to manage cluster shard data. when we cycle our cluster, the kubernetes pod IPs change and fall out of alignment with the values saved in the ShardCoordinator's event stream
is Kubernetes + Cluster Sharding with Persistence inherently incompatible?
Alan Klikić
@aklikic_twitter
@schrepfler Did you try with 1.4.8?
Srepfler Srdan
@schrepfler
no
1.5.0-M3 atm
you suspect the broker jar ends up wrongly on the service classpath