A Neate Blog

Technology Blog Posts

13 January 2022 - Easily log the Request and Response of a Microprofile REST Client

~ 2 minutes
Category: Technology

Using the Microprofile REST Client makes life significantly easier when you’re having to call a REST API, if you aren’t using them already I’d definitely consider adopting them.

The biggest drawback is that it’s not always clear exactly what they’re doing, because the framework handles the majority of the work for you, it’s not as simple as just logging the entity to see what the response looks like because your logger could output the entity in a different way to the one used by the REST Client.

Luckily for us, we can easily register a LoggingFeature that will automatically log the Headers, Request and Response details for each request made. Hurrah! This is really simple and straightforward whilst being especially useful for development and debugging.

Read on to find out more!

TL;DR:- You can register the Jersey LoggingFeature with the REST Client, and it will log Request and Response content out of the box. You can even alter the output to log headers only or everything.

6 January 2022 - Mounting OCI Object Storage to Oracle Cloud Free Tier Compute Instance

~ 7 minutes
Category: Technology

This post was born out of me needing an SFTP Server somewhere cheap that I could use quickly, immediately I thought about Oracle’s Always Free cloud tier and wondered if it was possible. It was. This post explains how to mount an Object Storage bucket on an Oracle Cloud Always Free compute instance.

TL;DR:- Create compute instance, create an Object Storage bucket, use the s3fs-fuse package to mount your bucket to the desired location.

20 May 2020 - Setup EmbeddedKafka for Unit Testing Kafka in Java

~ 2 minutes
Category: Technology

Unit testing Kafka can be a pain, it seems a lot of overkill to have an entire Kafka cluster ready just for unit testing purposes, luckily, spring-kafka-test helps with this by providing an Embedded Kafka instance you can use to produce or consume messages.

This article contains a short How-To guide on setting up Embedded Kafka to be used for unit testing an application.

TL;DR:- Using embedded kafka is a simple way to run unit tests that don’t have or need a local Kafka instance, such as your CI server

15 April 2020 - Using Persistable for JPA Performance Improvements

~ 5 minutes
Categories: Technology, Java

Using JPA to interact with a database is, and always has been, heavily popular for Java applications; this post contains an example of how implementing persistable results in performance improvements for certain use-cases that might not be commonly known. This is particularly useful if you have little to no control over the database schema or it isn’t designed that well.

TL;DR:- Implementing persistable on a Java entity can force JPA to either always insert or always update the records by overriding the isNew method instead of first checking whether the record exists via a select and then deciding whether to insert or update the record, this can heavily reduce the overall number of SQL statements executed by JPA. This is done automatically if you use a JPA Generated ID but there are times where you can’t control the ID within your Java entities…

9 March 2020 - Running Oracle JET in Docker

~ 5 minutes
Category: Technology

In the previous Dockerfile articles, we looked at a Dockerfile example that was an Oracle JET application, in this post we dive deeper and enhance this Dockerfile which results in a great way to run an Oracle JET application via Docker, whether that’s on a local machine or in the cloud.

TL;DR:- Oracle JET can be served via a simple web server tool such as Nginx or Express, scroll down to the end to see the final Dockerfile.

17 February 2020 - Simple Dockerfile Performance Improvements (Part 3)

~ 5 minutes
Category: Technology

In Part 2 we learned about how we can create multi-stage Docker builds, this article follows on from the previous therefore if you haven’t already, please give it a read!

This time in Part 3, we focus specifically on how your various stages can be cached in order for your CI process to build images quicker using the Docker layer cache by creating a setup stage that is used by multiple stages later on.

Note: Docker 17.05 or higher is required to enable Multi-Stage builds

TL;DR:- It’s possible to create an entire stage that can be cached, thinking carefully about your command order and any duplicated commands that can be moved to a “common/parent” stage significantly reduces overall build time.

22 January 2020 - Simple Dockerfile Performance Improvements (Part 2)

~ 5 minutes
Category: Technology

In Part 1 we learned about how the order of your Dockerfile commands matters along with copying only what you need, using these principles, this post dives deeper into a Dockerfile and reveals a great strategy called multi-stage builds that provide immense power when used correctly.

Note: Docker 17.05 or higher is required to enable Multi-Stage builds

TL;DR:- Whilst slightly more advanced, using multi-stage builds is often the ultimate Dockerfile improvement, this allows you to run intermediate containers to perform processing whilst only keeping the end result or compiled artifacts in your final docker image, thus resulting in a significantly smaller image.

20 December 2019 - Simple Dockerfile Performance Improvements (Part 1)

~ 8 minutes
Category: Technology

As a developer, I find that one of the easiest ways to ship an application is to create a Docker image via a custom Dockerfile in order for it to be deployed usually on AWS/Azure/Oracle cloud Kuberenetes (AKS, EKS, OKE). In recent times I’ve spent some time looking into the docker image created and attempted to find ways to shrink the final image size and also make the build quicker by caching docker image layers, this post is Part 1 of my approaches and also the final outcomes. This particular Dockerfile builds an Oracle JET UI Application.

TL;DR:- Ordering your commands in terms of slowly-changing outputs to more frequently increasing output has a huge impact on build time, explicitly specifying files to copy instead of copying everything results in image size reduction and finally using ADD for local tar archives means Docker will automatically unpack the archive for you, no more manual unpacking! The above might sound like common sense but they’re often overlooked, even in production ready applications.

14 November 2019 - Changing the default editor of Kubectl Edit

~ 1 minute
Category: Technology

If you find yourself working with Kubernetes, whether that’s in the cloud on AKS (Azure), EKS (AWS), OKE (Oracle Cloud), GKE (Google Cloud) or even locally, chances are you have encountered the need to edit a piece of config via the kubectl edit command, did you know that you can change the default editor that kubectl edit uses, on Windows it’s Notepad by default but I changed it to VS Code and here’s how.

TL;DR:- You need to create an environment variable named KUBE_EDITOR, the value should be set to the CLI command to open the editor of your choice and ideally specify a watch flag so K8s knows when the file has has been saved and closed.