Skip to main content

Posts

Cracking Java8 Stream Interview Question

Greetings! I have faced many interviews (too many to be frank) in my career as a software developer. In most of those interviews I have been asked to write a pseudo code for a given problem and implement it in Java. With Java8, this implementation mostly should be in Java8. When I look back all those questions it can be simplified as below. (difficulty may be vary though). Iterate over a given collection (stream) Filter the given data (filter) Transform into another format (map, reduce) Collect data into a collection (collect) or End the stream (forEach, min, etc) Is this familiar to you? This should be. This is what we do in our daily work. But, if you are blindly using it you will see it as a difficult question to answer. You need to have good understanding about intermediate and terminal operations. And, you need to really practise and use in daily work. It is meaningless to pass an interview without knowing these. java-8-streams-intermediate-operations java-8-stream...

Angular - Let's create a starter project

Greetings! Angular has many things to learn though we can skip those and directly create simple project. It will be harder to study all the features first. So here, i'm going to directly create a simple starter project. This is the end result of this tutorial. Install Angular CLI npm install -g @angular/cli ng version Create a project ng new angular-store --routing --style=scss cd angular-store npm install This will create a basic app structure. Run the project ng serve --open # short form ng s -o With zero code, we have a running template. That's some power. Angular Material Let's add material UI design into our project. For more information visit https://material.angular.io/ Below command will add angular material into our project and update neccessary files. ng add @angular/material We want to use material design component in our project. To add material components in a single place let's create a separate module named material and ...

Microservices - Api Gateway

Greetings! I was too busy past couple of days and lost my way of continuing Microservices series. So I decided to add simple dummy services service-a and service-b. Other than that, there is no change except the github repo. https://github.com/slmanju/simple-microservice In Microservices architecture we are dealing with many apis which work along or work with other services. Imagine that we are going to create a mobiile client using these client it will be very difficult to manage all services by that client. Or, imagine we expose our apis so that anyone can create their own client. This is a good place to introduce a another service which act as a gateway to all other services. Third party clients will know only about this api. Not only this, we can solve some other problems using Api Gateway. Single entry point to all the services. Common place to log request and responses. Authentication users in single place. Rate limits. Add common filters. Hide internal services. ...

Kafka - Spring Boot

Greetings! In this blog post i'm going to explain how to integrate Kafka with Spring boot. We use Spring boot configuration to send Kafka message in String format and consume it. Let's begin. (complete example can be found here .) Starting up Kafka First of all we need to run Kafka cluster. For this i'm using landoop docker image . Here is the docker command to run landoop docker container. docker container run --rm -it \ -p 2181:2181 -p 3030:3030 -p 8081:8081 \ -p 8082:8082 -p 8083:8083 -p 9092:9092 \ -e ADV_HOST=127.0.0.1 \ landoop/fast-data-dev Generate the application I'm using Intellij idea IDE to generate the Spring boot application. I have selected web, lombok and kafka dependencies. Let's rename application.properties to application.yml to use yaml format. Here is my application.yml file configuration values. server: port: 9000 spring: kafka: producer: bootstrap-servers: localhost:9092 key-serializer: org.apache.kafka....

Docker - Dockerfile

Greetings! We used Docker images to create containers multiple times. We used images from Docker Hub to create those containers. Ever wondered how to create a Docker image? Docker can build images automatically by reading the instructions from a Dockerfile. Dockerfile A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Think of it as a shellscript. It gathered multiple commands into a single document to fulfill a single task. build command is used to create an image from the Dockerfile. $ docker build . You can name your image as well. $ docker build - my-image . Let's first look at a Dockerfile and discuss what are those commands. This is extracted from official MySQL Dockerfile . FROM debian:stretch-slim # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added RUN groupadd -r mysql && useradd -r -g mysql mysql RUN a...