Posts

AKHQ login with Keycloak

Introduction This article describes case of running AKHQ with docker and enabling login with Keycloak requirement to browse data on AKHQ UI. All the code is available on my GitHub . Specification: - Protocol: HTTP - AKHQ authorization: YES, with keycloak Requirements: - internet access - to download AKHQ docker image, - installed docker - to run downloaded image, - running kafka - visible within any connected network interface, - running keycloak - with created realm and configured client (confidential access, service account enabled, redirect URL), also reachable via any connected network. Configuration First of all we have to create YAML file - to tell AKHQ where is our kafka running and how to authorize users via Keycloak. At this moment we are not using any role-based privileges and default logged user group is "reader". If you need to execute any write operation, you have to change default grou...

Basic AKHQ running with docker (HTTP)

Introduction This article describes basic case of running AKHQ with docker. All the code is available on my GitHub . Specification: - Protocol: HTTP - AKHQ authorization: NO Requirements: - internet access - to download AKHQ docker image, - installed docker - to run downloaded image, - running kafka - visible within any connected network interface. Configuration First of all we have to create YAML file - to tell AKHQ where is our kafka running. akhq: ui-options: topic-data: sort: Newest connections: local: properties: bootstrap.servers: "localhost:9092" Then just run AKHQ docker image (on port 1790) with previously created YAML config: docker run -it -p 1790:8080 --name akhq_basic_container -v application-basic.yml:/app/application.yml tchiotludo/akhq Once container is created you can start simple by: docker container start akhq_basic_container ...

Testing JVM resources availability in docker environment

Introduction JVM is changing over the time what makes us, Software Engineers, to periodically measure stability of our applications. JVM flag adaptations can be needed not only when upgrading JDK but also when we are changing available app cloud resources. If we pay for resources, we should use them in the most effective way. This article provides useful scripts and code to make resource control easier. All scripts and code used in this article you can find in this GitHub demo Testing JVM flags To test default JVM flags values depending on given resources I’m using script docker-jvm-flags.sh (available on github repo). You can easily modify it according to your preferences. Basically it runs JRE docker image with given memory and CPUs resources and for each of them executes command to get default JVM flags and filtering (with grep) those, which we specified on JVM_FLAGS_TO_PRINT list. docker-jvm-flags.sh JVM_IMAGE_NAME="e...

Java 21 vs. Java 11 - practical comparison

Image
Introduction This study aims to compare some metrics related to Java 11 and Java 21 applications and based on it, approximate the value of savings due to migration. In the tests I used following JDKs: - for Java 11: Coretto openjdk 11.0.19 2023-04-18 LTS - for Java 21: Oracle openjdk 21.0.1 2023-10-17 Hardware: - model: Lenovo Y50-70 - RAM: 16GB DDR3 1600MHz - CPU: Intel Core i7-4720HQ (Quad Core, 2.6GHz - 3.6GHz, 6MB Cache) - OS: Ubuntu Desktop 22.04.3 LTS Application which I've tested is available here Tested aspects Each test was done 10 times, one by one. Collected values description: - application start time – logged in application output: - application initial memory usage – RAM memory usage after application started (by PID from app logs): - application memory usage after init – RAM memory usage after sending request to application endpoint (by PID from app logs): ...

Keycloak config for Java application with Spring (Java 21)

If you want to secure your Spring microservice endpoints with Keycloak, you are in perfect place. Let’s do this step by step. First we need is of course to add proper dependencies, I’m using maven: <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-oauth2-resource-server</artifactId> </dependency> </dependencies> Second, provide some properties for our authorization server connection: spring: security: oauth2: resourceserver: jwt: issuer-uri: http://localhost:8080/realms/custom-realm jwk-set-uri: http://localhost:8080/realms/custom-realm/protocol/openid-connect/certs Thi...

Postgres database connection for Spring app (Java 21)

Dependencies: &ltdependencies&gt &ltdependency&gt &ltgroupId&gtorg.postgresql&lt/groupId&gt &ltartifactId&gtpostgresql&lt/artifactId&gt &lt/dependency&gt &ltdependency&gt &ltgroupId&gtorg.springframework.boot&lt/groupId&gt &ltartifactId&gtspring-boot-starter-data-jpa&lt/artifactId&gt &lt/dependency&gt &lt/dependencies&gt Properties short way: spring: datasource: url: jdbc:postgresql://localhost:5432/custom_database username: postgres password: password # if you want your app to auto create tables on start: # jpa: # hibernate: # ddl-auto: create And a little more advanced: spring: jpa: properties: hibernate: jdbc: time_zone: UTC datasource: url: jdbc:postgresql://localhost:5432/custom_database user...

Postgres database connection for Spring app (Java 11)

I’m using Postgres DB in almost all my projects because it’s good enough for most cases and FREE. This article describes how to connect Java&Spring app to a Postgres database. First of all – dependencies: &ltdependencies&gt &ltdependency&gt &ltgroupId&gtorg.postgresql&lt/groupId&gt &ltartifactId&gtpostgresql&lt/artifactId&gt &lt/dependency&gt &ltdependency&gt &ltgroupId&gtorg.springframework.boot&lt/groupId&gt &ltartifactId&gtspring-boot-starter-data-jpa&lt/artifactId&gt &lt/dependency&gt &lt/dependencies&gt Second, add properties. This is short way: spring: datasource: url: jdbc:postgresql://localhost:5432/custom_database username: postgres password: password # if you want your app to auto create tables on start: # jpa: # hibernate: # ...

My Ubuntu Desktop config

Image
This article describes Ubuntu configuration I’m personally using. Those are tools which makes my work much easier and more pleasant. Consider adding them to your setup. Extensions To add Ubuntu GNOME extensions you have to enable this possibility at first. Here is short tutorial: https://damiankumor.blogspot.com/2023/08/enabling-gnome-extensions.html Dash to panel Custom menu panel. I like to have it on the top. https://extensions.gnome.org/extension/1160/dash-to-panel Final effect looks like that: Audio selector Tool for easily selection of audio input and outputs. https://extensions.gnome.org/extension/5135/audio-selector Final effect: Extension list Tray icon for fast extension management. https://exten...

Enabling Gnome Extensions

Image
GNOME Shell extensions allow us to modify our system elements behavior and add some new features in very easy way. Browser extensions work similar so don't be afraid. If you want to read more about GNOME Shell extensions visit this site: https://extensions.gnome.org/about If you are looking for some useful extensions check this article about Ubuntu Desktop config I personally use: https://damiankumor.blogspot.com/2023/08/my-ubuntu-desktop-config.html Requirements Firefox To enable possibility to install gnome extensions via Firefox you have to install one package and add browser extension: sudo apt-get install chrome-gnome-shell https://addons.mozilla.org/en-US/firefox/addon/gnome-shell-integration Chrome To enable gnome extensions on Chrome you have to install same package and also add browse...

Pagination in API – why and how?

Introduction Pagination is splitting our data lists returned to the user from API into smaller parts. We can see that in many cases – i.e. changing pages of search results on Amazon or scrolling Facebook. What are benefits of pagination? Below you can see couple of them: reducing network traffic (users with poor network connection have better experience using app), making application more stable and production usable (Java apps can throw Out of Memory Error if the heap size exceeds Xmx value - it can happen when you load too much data from DB), reducing load of data processing and as a result reducing cost of maintenance our app - especially when hosting in cloud, app can handle more requests in the same period of time (cause faster responses), reducing number of returned objects which are not ...