Ktor application with spring config server - ktor

wanted to try some new stuff and decided to build next micro-app in Ktor + Koin + Exposed. Everything looks really nice but I found one problem that is actually destroying the whole idea.
App needs DB access and the connection cannot be stored within repository but should be encrypted on config-server. Every other micro-app is suing spring boot and fetches configs with lib spring-cloud-config-client but I don't know if it's even possible to use that somehow from Ktor app. Anyone had the same problem and managed to fix it somehow?

Cfg4j seems to be an alternative to Spring Cloud Config Server.
https://github.com/cfg4j/cfg4j
Other than that, there are a few articles and some questions on SO about integrating Spring Cloud Config Server with non Spring Boot projects.
Spring Cloud Config Client Without Spring Boot
Also, I am working on an external configuration parser for Kotlin and am considering to implement similar functionality.

Related

Spring Cloud config with JDBC Backend Failure in Spring boot

I have a client-server based microservice architecture. i.e, a server-config(Spring cloud config) service that has all the configurations and properties that are fetched using jdbc Backend-(PostgreSQL in my case) along with profiling.
I wanted to understand that incase of failure of my server-config service are there any chances of the rest of the dependent services to fail as they will no longer be able to fetch the required properties from the server-config service? If yes, then how can I mitigate this issue.
I could think of implementing cache but will have to go through the steps required to do so. Can someone help me clear out the above scenario.

PCF / Cloud connector for Rabbit management API

All,
I'm running a simple SpringBoot app in PCF using a Rabbit on-demand service. The auto reconfiguration of the ConnectionFactory for the internal Rabbit service works just fine.
However I need a list of all queues on the Rabbit host. AFAIK this is only available through a call to the Rabbit management plugin (a REST API), see RabbitManagementTemplate::getQueues. This class expects an http URI with credentials.
I know the URI+credentials are exposed through the vcap.service variables as "http_api_uri', but I wonder if there's a more elegant way to get an instance of RabbitManagentTemplate with Spring magic cloud connectors / auto reconfiguration instead of manually reading the env vars and writing custom bean config.
It seems the ConnectionFactory only knows about the AMQP interface, and cannot create a RabbitManagementTemplate?
Thanks!
Spring Cloud Connectors won't help you here. It doesn't support setting up RabbitManagementTemplate, only a ConnectionFactory.
You don't have to parse the env yourself, you can use the flattened properties that Boot provides such as vcap.services.rabbitmq.credentials.http_api_uri. But you'll need to configure a RabbitManagementTemplate yourself using those Boot properties.

Does javamelody work with spring webflux?

can anyone point me to a resource, how I can get spring-webflux and javamelody to work together?
Seems, that a servletcontext is neccessary for startup, which I don't have/need.
I'm aware of the coll metrics stuff, that comes with spring-boot 2.x, but I don't have anything to display the metrics with, and am locked to a company environment, where just installing something isn't a valid option.
Thanks,
Henning
javamelody is mainly based on monitoring of memory, cpu, http requests, sql requests and spring components among other things. See javamelody-spring-boot-starter for example.
But as far as I know, Spring webflux does not use the servlet api. So what do you want to monitor?
If you just want to have graphs in a browser, then start a http server for javamelody reports like in standalone. And if you also want to monitor sql requests and spring components, then add in your application all methods from this example, except monitoringSessionListener and monitoringFilter.
A new spring-boot-starter for javamelody in webflux could be created if it makes sense.

Spring boot websocket test

I have a spring boot project with websocket and I want to test the project sending multiple request to the socket from different users. I want to use threads to imitate the users that send data from the web app but I don't know exactly how to make the test. Can anyone help me, and show one simple test for an websocket using threads?
You can use JMeter for testing your websocket project.
For further reading:
https://www.blazemeter.com/blog/websocket-testing-apache-jmeter
http://www.baeldung.com/websockets-spring
Good example:
https://github.com/Fyro-Ing/JMeter-WebSocket-StompSampler
When writing a Spring Boot application using STOMP on websockets, I struggled a lot to find out how to configure a test client.
I ended up writing a little library called Jackstomp to make it easier to create type-safe tests for STOMP WS applications using JSON as message body.
I haven't used it with multiple threads, but you should be able to easily use it within each thread to create independent clients for each user and perform basic operations. (Please note that a different client should be used in each thread).
The point is that you can really express a synchronous flow for each client, including actively querying for received events.
Even if you don't use this library, you can look at the code to get a grasp of the different things to setup.

Backup Spring Session with GemFire

Spring documentation says that Spring Session can transparently leverage Redis to back a web application’s HttpSession when using REST endpoints.
Does anyone know if Spring supports GemFire in this place instead of Redis to back a web application's HttpSession ?
Ref: http://docs.spring.io/spring-session/docs/current/reference/html5/guides/rest.html
Not yet, ;).
However, I did spend a little time researching the effort involved to implement a GemFire adapter for Spring Session to back (store/replicate) an HttpSession. I still need to dig a little deeper and I will be tracking this effort in JIRA here (SGF-373).
Also know that GemFire already has support for HTTP server session replication using GemFire's HTTP Session Management Module.
Will post back when I have more details.
Will these 3 steps (at a high level) be sufficient to allow Spring Session to write to Gemfire repository instead of Redis ?
Step 1: Implement just a Configuration class which provide all functions as the annotation
Allow spring to Load the configuration class
Register Spring Session Filter in Container
Establish Repo Connection Factory
Repo connection configuration
we will continue to re-use the Spring Session’s springSessionRepositoryFilter
Step 2: Need to develop an equivalent GemfireOperationsSessionRepository implementing the interface SessionRepository
Step 3: SessionMessageListener.java
3.1. Need to decide a technique to identify and save delta changes in Session to underlying repository
3.2. Need to see how session expire notification from underlying repository can be captured to invoke SessionDestroyEvent and cleanup operations -