Posts

Apache Avro

"Avro is a language independent, schema-based data serialization library. It uses a schema to perform serialization and deserialization. Moreover, Avro uses a JSON format to specify the data structure which makes it more powerful..." More: https://www.baeldung.com/java-apache-avro

Main characteristics of APIs

1. Understandable (give consideration to the entry points into their API) 2. Well-documented 3. Consistent (methods should have the form getXYZ() or xyz(), but not both forms) 4. Fit for purpose (Do only one thing, and do it right) 5. Restrained (API can happen almost too quickly, we are potentially committing to a lifetime of support) 6. Evolvable (view them in the wider context) Read API best practices here: https://dzone.com/refcardz/java-api-best-practices

Message format: Protobuf vs JSON

"Protocol buffers, or Protobuf, is a binary format created by Google to serialize data between different services ..." https://auth0.com/blog/beating-json-performance-with-protobuf/

Getting started with AmazonWS SDK for Java

https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/getting-started.html

Is it RESTful, or simply RPC?

"Pretty URLs like /employees/3 aren’t REST. Merely using GET, POST, etc. aren’t REST. Having all the CRUD operations laid out aren’t REST. In fact, what we have built so far is better described as RPC (Remote Procedure Call)... What needs to be done to make the REST architectural style clear on the notion that hypertext is a constraint? In other words, if the engine of application state (and hence the API) is not being driven by hypertext, then it cannot be RESTful and cannot be a REST API. Period. Is there some broken manual somewhere that needs to be fixed? of NOT including hypermedia in our representations is that clients MUST hard code URIs to navigate the API. This leads to the same brittle nature that predated the rise of e-commerce on the web. It’s a signal that our JSON output needs a little help. Introducing Spring HATEOAS (Hypermedia as the Engine of Application State), a Spring project aimed at helping you write hypermedia-driven outputs." Read here: https...

Organize logs using MDC

MDC (Mapped Diagnostic Context) is supported by log4j, log4j2, and SL4J/logback and offers a key/value possibility to enrich log statements: public class MDC { //Put a context value as identified by key //into the current thread's context map. public static void put ( String key , String val ); //Get the context identified by the key parameter. public static String get ( String key ); //Remove the context identified by the key parameter. public static void remove ( String key ); //Clear all entries in the MDC. public static void clear (); } Add an aspect (filter/interceptor etc.) to pre-handle your requests and add the desired information: MDC . put ( "userId" , userId); MDC. put ( "correlcationId" , correlationId); In the log appender, the values can be retrieved using %X{<key>} log4j.appender.rollingFile.layout.ConversionPattern=[%d...

REST - Richardson Maturity Model

"A model (developed by Leonard Richardson) that breaks down the principal elements of a REST approach into three steps. These introduce resources, http verbs, and hypermedia controls..." https://martinfowler.com/articles/richardsonMaturityModel.html