Saturday, August 25, 2018

Simple spring integration with springboot

In this example we will see a simple file poller application using spring integration. It will poll for a file in a particular location at certain interval and if file is found it will move it to another location.

There are 3 core components of spring integration -

Messages - Messages are the objects sent from one component to another. In our case a file is sent from file poller to file handler.
Channels - Assume channels are the network (a pipe) by which messages are sent from one component to another.
Adapters - Adapters route the output from one channel to the input of another one.



Please see the codes below -



Wednesday, August 15, 2018

Read/Write large excel (xlsx) file

In this article you will see how to write a huge excel file.

Using SXSSFWorkbook you can write large excel file. It is a Streaming version of XSSFWorkbook implementing the "BigGridDemo" strategy. This allows to write very large files without running out of memory as only a configurable portion of the rows are kept in memory at any one time.

Note - I have tested it to write 10,48,576 rows which created 40 MB excel file. If you want to write more rows than this then you may opt to write CSV file.

You need to add below dependencies in your pom.xml

Tuesday, August 7, 2018

Berlin Clock with Java

The Berlin Clock is a rather strange way to show the time. On the top of the clock there is a yellow lamp that blinks on/off every two seconds. The time is calculated by adding rectangular lamps.
The top two rows of lamps are red. These indicate the hours of a day. In the top row there are 4 red lamps. Every lamp represents 5 hours. In the lower row of red lamps every lamp represents 1 hour. So if two lamps of the first row and three of the second row are switched on that indicates 5+5+3=13h or 1 pm.
The two rows of lamps at the bottom count the minutes. The first of these rows has 11 lamps, the second 4. In the first row every lamp represents 5 minutes. In this first row the 3rd, 6th and 9th lamp are red and indicate the first quarter, half and last quarter of an hour. The other lamps are yellow. In the last row with 4 lamps every lamp represents 1 minute.


Sunday, August 5, 2018

JBehave Hello World example (Eclipse + Maven + JUnit)

JBehave is a framework for Behaviour-Driven Development (BDD). To know more about JBehave, click here.

Below is the eclipse folder structure -



Please create a maven project and add the following files -