[{"content":"Intro Eureka is primarily used in the AWS cloud for the purpose of discovery, load balancing and failover of middle-tier servers.\nAs it have not received updates recently and there are solutions with some advantages over it, it\u0026rsquo;s not rare to see companies that have migrated or are migrating to other solutions.\n Scenario I worked for a company that started using Netflix\u0026rsquo;s OSS in 2014. Since this time Eureka was the main service used to discover and register all microservices.\nEureka has a lot of limitations, and we can list some:\n Eventual consistency  This is a huge problem when instances suddenly stop   Need for round-trips to heartbeat every application Application needs to know his own IP. If this is a container IP, it needs to know his external/node IP.  It is common to try to migrate to Kubernetes' Services/Ingresses or to another solution like Consul.\nHere we will see how it is possible to migrate to Kubernetes' Services/Ingresses with these goals in mind:\n Applications outside Kubernetes, using the legacy Eureka service, should still be able to discover and send requests to the new deployments, running in Kubernetes. Applications outside Kubernetes should prefer to send requests to services outside Kubernetes.  Comparison    Eureka Kubernetes Service     May take a long time to know a service is not running anymore Rapidly knows a service is not running   Services needs to keep heartbeating every X seconds There is no need to heartbeat, but using probes is recommended, though   Needs more configuration, client needs to do round-robin itself Application doesn\u0026rsquo;t need to bother    References:\n Kubernetes Services Kubernetes Cluster Networking   Eurek8s To solve this scenario, one option is to create a Kubernetes controller. Fortunately, we have Eurek8s.\nEurek8s adds a Custom Resource Definition called EurekaApplication to Kubernetes that we can use to configure how the application should be registered in Eureka.\nThere is a Helm Chart that you can use to install it.\nAfter installing (You should use GitOps for this - subject I will write about in the future) it, you\u0026rsquo;ll want to configure the Eureka client to do not register in Eureka, because Eurek8s will do that for you.\nIf you are using a Spring Boot application, the configuration should be like this:\n1 2 3  eureka: client: register-with-eureka: false    TIP 1: You can use the zones' info to make your applications outside Kubernetes to prefer requesting the instances outside Kubernetes.\n  TIP 2: If you are using Spring, I recommend that you create a new configuration file for a new profile. For example: create a application-k8s.yml file with the specific configuration for applications running in Kubernetes.\n Each application you want to Eurek8s register, you\u0026rsquo;ll need to create a EurekaApplication resource.\ne.g.\n1 2 3 4 5 6 7 8 9 10 11 12 13  apiVersion: discovery.eurek8s.com/v1 kind: EurekaApplication metadata: name: sample-app spec: disabled: false ingressName: sample-app environment: qa # Eurek8s uses the environment name to identify which Eureka it should use to register this application appName: sample-app zone: k8s-us-east-1 paths: healthcheck: /healthz home: /   Eurek8s will register the Ingress address as an application instance in Eureka and heartbeat it every 10 seconds.\nAt this point you should see your applications registered in your Eureka cluster.\nPlease, leave any comments if you have questions or suggestions!\n","permalink":"https://http200error.com/posts/2022-01-24-eureka-migration-using-eurek8s/","summary":"Intro Eureka is primarily used in the AWS cloud for the purpose of discovery, load balancing and failover of middle-tier servers.\nAs it have not received updates recently and there are solutions with some advantages over it, it\u0026rsquo;s not rare to see companies that have migrated or are migrating to other solutions.\n Scenario I worked for a company that started using Netflix\u0026rsquo;s OSS in 2014. Since this time Eureka was the main service used to discover and register all microservices.","title":"Eureka - How to replace it without a headache"},{"content":"This will be a fast-paced sequence of tips for using Kotlin Coroutines with Spring.\nTip 1 If you need transactions, don\u0026rsquo;t forgot to use the @EnableTransactionManagement annotation.\nTip 2 Probably you do not want to .subscribe to your Mono/Flux instances like in the example below:\n1 2 3 4 5 6 7 8 9 10  suspend fun handleSomeRequest(request: ServerRequest): ServerResponse { val someNewEntity = SomeEntity() someEntityRepository.save(someNewEntity).subscribe()  // some other stuff...  }   Just use coroutine\u0026rsquo;s .awaitSingle() instead.\nTip 3 For some reason, as of today (Spring Framework v5.3.3 / Spring Boot v2.4.2), Kotlin Coroutines reactive DSL doesn\u0026rsquo;t work with Spring\u0026rsquo;s declarative transactions (@Transactional annotation).\nThis exception won\u0026rsquo;t rollback the current transaction:\n1 2 3 4 5 6 7 8 9 10 11 12  import kotlinx.coroutines.reactor.mono //...  @Transactional suspend fun exampleMonoDSLThrow(): Mono\u0026lt;Void\u0026gt; { return mono { val employee = Employee(name = faker.artist().name()) val savedArtist = repository.save(employee).awaitSingle() throw RuntimeException(\u0026#34;createMonoThrow\u0026#34;) } } //...   On the other hand, the kotlinx.coroutines.flow.flow works fine. Also, kotlinx.coroutines.reactor.flux doesn\u0026rsquo;t work.\n","permalink":"https://http200error.com/posts/2021-02-15-spring-and-coroutines-quick-tips-part-1/","summary":"This will be a fast-paced sequence of tips for using Kotlin Coroutines with Spring.\nTip 1 If you need transactions, don\u0026rsquo;t forgot to use the @EnableTransactionManagement annotation.\nTip 2 Probably you do not want to .subscribe to your Mono/Flux instances like in the example below:\n1 2 3 4 5 6 7 8 9 10  suspend fun handleSomeRequest(request: ServerRequest): ServerResponse { val someNewEntity = SomeEntity() someEntityRepository.save(someNewEntity).subscribe()  // some other stuff.","title":"Spring and Coroutines - Quick Tips"}]