Because your threads are blocking my performance.

Spools of multi-colored thread
Spools of multi-colored thread
Image by Vesna Harni from Pixabay

Non-Blocking I/O has been around for a while. Different languages implement it differently, but all provide a way to reduce the thread count while seeming to allow full concurrency. JavaScript has been doing it from the start; with only one thread, you better not be the coder that pushes a blocking call into production.

While reactive Java is gaining some traction, most Java coders I know still live in a multi-threaded frame of mind. Why? Threads are a relatively easy concept to grasp. Reactive Java requires us to rethink a lot of how we learned to code. …


A simple explanation without the hype

Some prop coins that have come to represent Bitcoin
Some prop coins that have come to represent Bitcoin
Image by MichaelWuensch from Pixabay

Once again, cryptocurrencies are in the news everywhere. Are you still struggling with what cryptocurrencies are? Don’t worry, we all are. No one knows what to make of them or even how to value them. That’s why when you watch the crypto markets, you’ll get dizzy watching them go up and down so fast. We’re in a discovery process, where a market tries to come to a consensus on valuation.

Disclosure: I work for a company that enables you to buy Bitcoin.

Bitcoin was invented in 2009. The financial markets were in a tail-spin, and the U.S. was printing dollars…


Unchaining the blockchain

A chain
A chain
Image by analogicus from Pixabay

I get a lot of questions about cryptocurrencies and their underlying mechanism, the blockchain. A lot of the time I have trouble explaining it succinctly, so I’m going to write a blockchain example to better understand it myself. This article is one of three that will talk about the constituent parts: the chain of blocks, peer-to-peer networking, and mining. I won’t be making a cryptocurrency from it, just the blockchain with some abstract unit of value.

Not trying to make a true cryptocurrency simplifies a number of things. There are no fees or rewards (mining is done for the pure…


Despite all his flaws, Walt wanted a better future for everyone.

Photo by Randal Kamradt

As a child of Southern California, Disneyland was a yearly staple for me and my family. I have many memories of the magic that Disney conjured for the world. His was a vision of a better world; clean, organized, fun, and exciting.

Of course, his vision was shaded by a white European mindset. His Jungle Cruise was a Conradesque vision of a trek through Africa. It’s being cleaned up now, but it’s still white culture depicting black culture. If there was ever a black Disneyland, it would probably be a complete shock to white visitors. …


Good practices in asynchronous programming

Traffic at night
Traffic at night
Image by John Howard from Pixabay

The key to reactive programming is to react. You don’t say “do this now,” you say “do this when.” The “when” applies to when you have work to do. The work comes to you as events: a message on a message bus or an HTTP request.

First, I should explain the reason reactive programming is important. One of the benefits of Java is relatively easy threading. That has made threads the predominant model for handling events. When you get an event, you dispatch a thread to handle it. The problem is when you get a lot of events, you wind…


Conjuring functions from thin air

photo of a lamb
photo of a lamb
Image by Anja🤗#helpinghands #solidarity#stays healthy🙏 from Pixabay

I seem to spend a lot of time explaining Java functional programming. Really, there’s no magic here. You pass functions into functions to adapt their behavior. Why would you want to do that? If you’re using object-oriented development, you’re already doing it but in a very controlled fashion. Java’s polymorphism is implemented by keeping a list of functions that can be replaced by sub-classing. Then other functions of that class might call a function that has been overridden, and thus its behavior is changed even though the outer function wasn’t itself overridden.

Let’s take an example of polymorphism and translate…


Don’t bring your JavaScript code smells to Java

Pyramids
Pyramids
Photo by Nour Wageh on Unsplash.

JavaScript coders recognize the deeply nested callbacks that were the original way of dealing with asynchronous code and have given it a name. Since JavaScript only has a single thread, blocking is a no-no, so any code that has I/O needed to have a function that would be called when the request was finished. So you would have code like this:

This is the most straightforward way of writing code when the blocking methods all take a function as a parameter, but reading it can give you a headache. If the code gets too wide, it scrolls off the…


Using an orchestration orchestrator

Conductor Andrea Vitello
Conductor Andrea Vitello
Image by artesitalia from Pixabay

In my previous article Running Java Microservices in Kubernetes, I created a set of deployment files for some example microservices that I created. Today I’m going to automate deploying them using ArgoCD. Argo will take a directory filled with deployment files and not only deploy them but give you some visibility into them.

To install Argo, I used their instructions with a few minor modifications. My commands were:

kubectl create namespace argocd
kubectl apply -n argocd -f \
https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
brew install argocd
kubectl port-forward svc/argocd-server -n argocd 8080:443

This will expose the UI at port 8080, so you can browse…


Using priority queues to schedule work

Gears and stuff
Gears and stuff
Image by Pavlofox from Pixabay

I was recently reminded that Java has priority queues as part of its collections framework. A priority queue gets its name from one of its first usages, that of scheduling work in an operating system. It is a partially ordered list, which means that it doesn’t have to sort all the items, but only has to ensure that the least valued object is at the head. Because it doesn’t sort, it is more efficient than using a sorted list, but still allows you to pull the items off the queue in sorted order, least to greatest. …


Using Reactive pipelines to implement Gherkin based integrated tests

Cucumbers
Cucumbers
Image by Krzysztof Jaracz from Pixabay

One thing about integration tests is that you need to have state carried along from step to step. Let’s say you’re testing an application that implements a RESTful API. First, you want to create some test data and pass it along to the create endpoint.

Then you want to call another endpoint to see if you can retrieve it. You need the test data from the first step to be able to make assertions that the data retrieved in the second step is correct. It gets even worse when you have reusable steps that can be called in different orders…

Randal Kamradt Sr

Software dev for thirty years still keeping on top of the latest tech trends. I write about the learning process. https://rkamradt.github.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store