Author Archive

DDD eXchange 2017

Last year I went to several conferences, one about JavaScript and at least two about Java. Unfortunately, the last conference was rather boring since at every Java conference they are talking about the same cool Java 8 and Java 9 stuff, for example project Jig-Saw or Lambda expressions. After listening to several “Java User Group” talks and attending one Java conference there will not be a lot of new content in another three-day conference. In my opinion this is sad and I decided this year to go to more specialised conferences.

Continue Reading

Components and usage of Spring Data Elasticsearch (Part 2)

In the previous post we discussed how to read data in chunks from a relational database as a Spring Batch process using Spring Boot runner. This post will explain how to import that data into Elasticsearch.

Spring Boot provides out of the box support for Elasticsearch that saves a lot of configuration time so we are going to take full advantage of that. However, in real world application, you will need to use the Elasticsearch Java Client that requires additional instantiating and configuring. When no configuration is provided, the Spring Boot integration for Elasticsearch will automatically create an embedded Elasticsearch instance which is very useful for testing….

Continue Reading

Import Relational Database Data to Elasticsearch with Spring Batch (Part 1)

Recently I had a customer project that required transferring large amounts of data from a relational database to the NoSQL database that is Elasticsearch in order to take advantage of its famous fast searching capabilities. Elasticsearch is part of the ELK stack that is released and maintained by Elastic.co. The abbreviation ELK stand for Elasticsearch, Logstash, and Kibana.

The easiest way to transfer data from a traditional relational database into Elasticsearch is by using the “L” in the “ELK” stack: Logstash. Unfortunately, Logstash has some limitations, and one of those limitations is directly related to reading records from a relational database because, although database entry and Elasticsearch entry may seem very similar, it’s not possible to match single database entry to a single Elasticsearch document. This difference originates from the fact that Elasticsearch doesn’t use the notion of “relations” between its “records”, but instead it uses flat documents structure to store its data and flat documents have no relations between each other. In addition, the customer database have several millions entries which made the situation even more complicated. So, instead of using Logstash, a decision was made to write our own importer that was going to use batch processing and bulk writing into Elasticsearch.

Continue Reading

Testing an Angular 2 Service with a Mocked HTTP Interface

Angular 2 is the successor of the famous and broadly used AngularJS Javascript Framework, for building dynamic web applications. Due to the huge success and popularity of its predecessor, some client projects started using Angular 2 before its official release.This resulted in Angular 2 becoming one of the most famous platforms for web and hybrid application development. Although this framework is relatively new there are already a lot of tutorials and examples explaining how to develop an Angular 2 application. However, there is one aspect of Angular 2 that is not widely covered, but is still very important for every project: Writing tests. The command used to generate the default test cases is “ng generate” and it’s contained in the Angular 2 CLI. However, it only generates the boilerplate code that is needed for each test case. The actual tests have to be created separately and the API is still experimental, so examples are often outdated. In example, most of the available tutorials use the “beforeEachProviders” method, which was removed in an earlier Angular 2 pre-release and was replaced by “TestBed.configureTestingModule({providers:…})” with a completely different signature. In the following example we will test a simple “ItemService” which executes one HTTP GET request against a REST endpoint.

Continue Reading