A Feature Flag Experiment with Config and CDI

Lately I have been doing some research into Feature Toggle approaches, and how these can be used in Micro Services components developed in Java. These are simple true/false values used to determine if a given application feature (or code path) is enabled.

On looking at a MicroProfile quick start with sample code, the Config feature specification looked interesting for tackling a piece of this functionality.

The aim here is to provide a proof-of-concept implementation that allows for feature toggles that can be scoped down to different user attributes. This should be able to act as a starting point for a more complicated implementation if required. While it turned out that this could not be done solely using the Config feature, there appears to be a viable approach when combining this with Context Dependency Injection (CDI).

In the interests of speed and simplicity, this will use a header in the HTTP request to define the role of the user. If this approach was to be used in a production environment this role assignment would need to be provided by something which is verifiable, such as the JWT token provided.

All the source code for this implementation is part of my microprofile experiments project.

» Continue reading

Integration Testing with Payara Micro

It should go without saying that in any piece of development testing is important.

While unit testing can (and should) be used to test the individual components which make up a piece of software, there always comes a point where the software has to have a set of integration tests ran. Mocking of components can allow code to be tested in isolation, however if overdone all that has been achieved is testing the mocks. Integration tests should be ran in as close to a realistic deployment as possible, as the more differences which exist between the test environment and a production deployment, the more scope there is for bugs to slip through. Testing of a deployed component makes getting code coverage metrics more difficult than in regular unit tests, but is still possible.

Frameworks such as the Jersey Test Framework can allow unit testing of JAX-RS REST endpoints that have been created, but this is not equivalent to a truly deployed component and so features such as CDI and the MicroProfile features I am looking into cannot easily be tested this way. While not related to MicroProfile, testing of DAO code is another area which has traditionally been an integration approach, as it required a running database server, but there are now libraries available that can allow this to be tested as unit tests.

» Continue reading

Publishing to Nexus

I have a Nexus 3 server running on my internal network which I was using for testing some performance related things, which were relying on the Payara Micro feature that enables it to deploy artifacts from Maven coordinates directly.

What I wanted to do was to have my local machine know where to publish build artifacts, but not have the details of this server published in the publicly available pom file as it is not relevant to anyone except myself. Usually the server URLs are stored in the distributionManagement section of the POM file.

» Continue reading

Plex, Docker, and the problem of always appearing as "Remote"

I have no idea when exactly this issue started happening, but for a while now I have been noticing that when I attempted to play media through the Plex application on my Xbox One it would default to transcoding down to a lower quality. While this was an annoyance, I could always manually set the quality back to original quality.

Finally this week I spent a bit of time to try and work out why.

The Problem

It appears that the majority of Plex clients on my network were considering the server to be a “remote” server, and so were setting bandwidth restrictions on playback. It is worth noting that there are two types of settings at play here, in the Xbox Plex application, and the bandwidth settings in the Plex Server settings which are available to Plex Pass subscribers.

» Continue reading

Eclipse MicroProfile

The Eclipse MicroProfile project has been evolving over the last few years, but only in the last month or so have I started taking a proper look into it.

The mission of the project is described to provide:

An open forum to optimize Enterprise Java for a microservices architecture by innovating across multiple implementations and collaborating on common areas of interest with a goal of standardization.

microprofile.io

The collection of framework specifications which are included in this standard, when used along with JAX-RS, provides the pieces required to build applications in a modern “microservices” architecture, while leaving behind more legacy aspects (and bloat) of the Java EE specification.

» Continue reading