Tags

, , ,

So I recently blogged (here) about the announcement of Helidon – the open source project from Oracle to provide a microservice app server that includes optional support for the J2EE Microprofile. This is the first of what will probably become a series of blogs about Helidon, particularly in its SE form (non J2EE Micro-Profile) as Micro Profile and the wider J2EE model in general will have been documented more widely.

Hello World

Helidon comes with a quick start example app implemented both in SE and MP forms.  It is worth following the very simple instructions provided by the Helidon site to instantiate both versions of the Hello World app as it provides a good way to start to understand the differences in the way Helidon can be used.

The thing that really jumps out when you compare the code (for me at least) is the fact that the SE code being driven from values loading from configuration is more dynamic. The configuration can be sourced in a number of different ways from YAML files to etcd.So for our for first experiment we took the hello World app, and made the path /greet dynamic by loading the path from from some additional configuration. Enhancing the main with :
private static Routing createMultiRouting() {
Map greetingConfig = Config.create().get(“greeting”).asMap();
Routing.Builder routing = Routing.builder();
if (!greetingConfig.isEmpty())
{
greetingConfig.forEach((k,v)->
{
System.out.println (“Read config value>” + k + “=” + v + “<“);
// as the key is the fully qualified name, I just want the last piece,
// so let’s strip it to be a substring
String key = (String)k;
key = key.substring(key.lastIndexOf(“.”)+1);
// each different URI should have its own instance of the Greet Service
// with its tailored key which will mean it responds with the key e.g. France
routing.register(JsonSupport.get())
.register(“/”+v, new GreetService(key));
});
}
else
{
System.out.println(“No config\n”);
}
return routing.build();
}
We can create URLs for greetings in different languages, and see the different instances of the Service object responding to the web calls. Whilst many may associate this approach with Node.js for me it felt more like the webserver multiplexer (MUX) such as Gorilla used with Go (you can see what I mean here).

Helidon and On the Road

Two of the leading figures Tomas Langer and Dmitry Kornikov will be presenting at a number of meet-ups in Europe, including the London Meetup (go here)

Part 1?

Yes, I will be blogging more about Helidon as soon as I can, but presently wrapping up a white paper and running an API Design training session soon.