Occasionally you’ll want to write a class that is just grouping of a static methods and static fields. Such classes have acquired a bad reputation because some people abuse them to avoid thinking in terms of objects, but they do have valid uses. They can be used to group related methods on primitive values or […]
A singleton is simply a class that is instantiated exactly once. Singletons typically represent a system component that is intrinsically unique, such as the window manager or file system. Making a class a singleton can make it difficult to test its clients, as it’s impossible to substitute a mock implementation for a singleton unless it implements and interface that serves as its type. // Singleton with public […]
Static factories and constructors share a limitation – they do not scale well to large number of parameters. Consider a class representing the Nutrition facts label that appears on packaged food. These labels have a few required fields – serving size, servings per container, and calories per serving – and over twenty optional fields. Most […]
One advantage of static factory methods is that, unlike constructors, they have names – ex: BigInteger(int, int, Random) – probably returns a prime number, it is much readable BigInteger.probabluPrime() Static factory methods, unlike constructors, they are not required to create a new object each they’re invoked. Static factory methods, unlinke constructors, can return an object […]
Consuming messages is similar with producing messages because of abstraction offered by kafka library. There are two methods for consuming messages, subscribe(List<String>) can be used to consume messages from one or more topics, assign(List<TopicPartition>) should be used when we are interested to consume messages from specific partitions.
The central part of the KafkaProducer API is KafkaProducer class. The KafkaProducer class provides an option to connect a Kafka broker.
Will discuss details about debugging a local application, then will apply the same techniques for remote debugging.
Few times I was debugging an application and it was possible to reproduce a problem only using remote available data. I will explain how it is possible to solve this in a easy way. Possible applications are: remote Mysql/Elasticsearch service exposed to your machine, replacement of remote service with a local one that contains a […]
There are times when it’s necessary to follow a path in your application and logs related to that path are relevant, in this video I will explain how to use tail -f with grep in order to filter a continuous stream.
In this blog post I will describe required steps in order to build with Spring boot a fully executable application as a jar file, deploy over ssh, run it as a System V service using a custom user for this. I have generated a Spring Boot application using Initializr and configured the build.gradle script to […]