Nick Fisher's tech blog

Java

How To Invalidate an Nginx Cache In a Reverse Proxy Setup With Spring MVC

You can see the sample code associated with this post on Github.

In two previous posts, we looked at how to provision a reverse proxy using nginx and then how to add caching to the nginx reverse proxy. The implementation we ended up with at the end of the last post was a “dumb” cache, meaning that it doesn’t know when or if any data gets updated–it just times out after 60 seconds and then asks for a new payload from the application it’s acting as proxy for.

How to Use Nginx's Caching to Improve Site Responsiveness

The source code for this post can be found on Github.

In my last post, I provided an example for how to set up an Nginx Reverse Proxy for a Spring MVC application. One such reason to set up a reverse proxy is to utilize caching of resources. If you have dynamically generated content that doesn’t change very often, then adding caching at the site entry point can dramatically improve site responsiveness and reduce load on critical resources.

A Simple Zero Downtime Continuous Integration Pipeline for Spring MVC

The sample code associated with what follows can be found on GitHub.

One of the biggest paradigm shifts in software engineering, since the invention of the computer and software that would run on it, was the idea of a MVR (minimum viable release) or MVP (minimum viable product). With the lack of internet access becoming the exception in developed countries, it becomes more and more powerful to put your product out there on display, and to design a way to continuously make improvements to it. In the most aggressive of circumstances, you want to be able to push something up to a source control server, then let an automated process perform the various steps required to actually deploy it in the real world. In the best case, you can achieve all of this with zero downtime–basically, the users of your service are never inconvenienced by your decision to make a change. Setting up one very simple example of that is the subject of this post.

Use First Class Functions to Reduce Code Duplication In Java

Often when we program, we find ourselves creating patterns, usually in the form of boilerplate code, that seem to always do the same thing. For example, let’s say you have some logging logic that is non-trivial, and you want to make extra sure you don’t blow up your main application while it’s running, so you surround it with a try/catch block:

How to Use Spring's Dependency Injection in Setup And Teardown Code For Integration Tests With Maven

You can view the sample code for this repository on GitHub.

In our last post on Using Maven to Setup and Teardown Integration Tests, we saw how to run Java code before and after our integration tests to setup and teardown any data that our tests depended on. What if we are using Spring, and we want to use our ApplicationContext, and its dependency injection/property injection features? After all, we would be testing the configuration for our specific application more than anything else, so we should be certain to use it in our setup and teardown code.

How to Run Integration Tests with Setup and Teardown Code in Maven Build

The sample code for this post can be found on GitHub.

Unit testing with Maven is built in, and is the preferred way of validating code is performing correctly. However, sometimes you need integration testing, and most non-trivial applications built in the 21st century are reliant on network connections and databases–that is, things which are inherently third party to your application. If you don’t adequately take that to account in your CI/CD pipeline, you might end up discovering that something very bad has happened after damage has already been done.

How to Use Spring's Aspect Oriented Programming to log all Public Methods

The sample code for this post can be found on GitHub.

Aspect Oriented Programming In Spring is a clever way to reduce code duplication, by taking a different approach than traditional tools like dependency injection or inheritance. Cross cutting concerns like security and logging can permeate a code base and make maintainability a nightmare unless properly taken care of, and aspect oriented programming is one way to properly take care of that, when used appropriately. This post will illustrate how to get started with a transparent way to log without cluttering up business logic.

Newer Posts