Interesting Stuff – Volume IX

  1. Java EE 8 & 9 Road map
  2. Load Balancing Microservices with Ha-Proxy
  3. Java 2016 videos
  4. Spring 5: Functional Web Framework
  5. RxJava 1.0 vs RxJava 2.0 vs Reactor – Benchmarks
  6. Apache Solr Tutorial
  7. Performance and Availability pitfalls in the Microservices Architecture — CQK Top 10
  8. Announcing MicroProfile 1.0
  9. Swift 3.0 Released
  10. Golang UK Conference 2016 – videos
  11. Building a Modern Bank Backend (Golang)
  12. Go 1.8 performance improvements
  13. {py}gradle, an open source Python plugin for Gradle
  14. Docker Swarm vs Kubernetes

Go Language – First Impressions

Just wrote something small with Go Language. Simple CRUD/webservice with MySQL using gorilla mux and sqlx, but it is almost plain golang. If anything wrong about it, tell me😉
https://github.com/kgoralski/go-crud-template

(need to fix the tests😉 )

Here are my impressions about it:

  • it feels pragmatic from the beginning
  • probably you don’t need any frameworks at all to use it
  • simpler = better, simplicity as a feature
  • quite easy to write REST application
  • the build in package manager ‘go get’ is cool thing
  • compilation & running time of go server is much faster than java
  • it doesn’t eat much of resources
  • you can use many text editors or IDEs for it (IntelliJ has Go Plugin)
  • gofmt – one and the only code formatter
  • designed for special needs, not for everything
  • it is easy to find examples by googling it, good enough community
  • return multiple values from Go functions – nice feature
  • syntax not beautiful like Python but still good
  • the build in ‘testing’ package – ok, but too simple (testify looks better)
  • concurrency – believe that it is nice, but didn’t tried it yet
  • it is much different than Scala – complexity vs simplicity
  • I think that I could be very productive with Go if i will get used to it
  • Docker, Kubernetes, CoreOs,  Consul, Flynn, Lime, Google, Dropbox…
  • heard that golang is good for ‘real time apps’ – want to try it soon
  • it seems to be good for building command-line tools
  • it is different than Java, little bit tricky at beginning, but easy to start😉
  • ‘good when you need to write something yourself instead of using library’
  • need to find idea for real project, because I kinda like Go

Links:

Univocity Parsers Library

Very good parsing library.
Official Website
Univocity Parsers – Maven Repository

public class ExampleCsvToPojoParser {
  
    private final Logger logger = LoggerFactory.getLogger(CsvToPojoParser.class);
  
    public <T> List<T> parseFileToPojo(Class<T> clazz, String fileName) {
  
        BeanListProcessor<T> rowProcessor = new BeanListProcessor<T>(clazz);
  
        CsvParserSettings parserSettings = new CsvParserSettings();
  
        parserSettings.setRowProcessor(rowProcessor);
        parserSettings.setHeaderExtractionEnabled(true);
        parserSettings.setLineSeparatorDetectionEnabled(true);
        parserSettings.setSkipEmptyLines(true);
  
        CsvParser parser = new CsvParser(parserSettings);
        try (InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(fileName)) {
            parser.parse(resourceAsStream);
        } catch (IOException e) {
            logger.error("Cannot read file " + fileName, e );
        }
        return rowProcessor.getBeans();
    }
}

Then you can put there class like this (which will match the file):

public class Users {
  
    @Trim
    @NullString(nulls = { " ", "" })
    @Parsed(field = "USER_ID")
    private Long userId;
    @Trim
    @NullString(nulls = { " ", "" })
    @Parsed(field = "USER_NAME")
    private String userName;
    //getters & setters
}

My programming books: Update

Time for update. My current, unordered book list but I wasn’t able to read them all, yet.😉

  1. Core Java, Volume I and II; Horstmann
  2. Thinking in Java; Eckel
  3. OCA/OCP Java SE 7 Programmer I & II Study Guide; Sierra & Bates
  4. Effective Java; Bloch
  5. Java Concurrency in Practice; Goetz
  6. Spring Boot in Action; Walls
  7. Java EE 7 Development with WildFly; Ćmil, Matłoka, Marchioni
  8. The C Programming Language; Kernighan, Ritchie
  9. The C++ Programming Language; Stroustrup
  10. Effective Modern C++; Meyers
  11. Learning Python: Powerful Object-Oriented Programming; Lutz
  12. Scala for the Impatient; Horstmann
  13. Functional Programming in Scala; Chiusano, Bjarnason
  14. Seven Languages in Seven Weeks, Tate
  15. Algorithms Unlocked, Cormen
  16. Introduction to Algorithms, Cormen
  17. Design Patterns; Gang of Four
  18. Head First, Design Patterns; Sierra, Robson, Bates & Freeman
  19. Clean Code; Martin
  20. The Pragmatic Programmer; Hunt
  21. The Software Craftsman: Professionalism, Pragmatism, Pride; Mancuso

Wildfly CRUD example with Docker

I’m not that familiar with pure Java EE stack. My experience is mostly mixing Java EE with Spring. So, I just wanted to play with it. You can find it here:
https://github.com/KrzysztofGoralski/wildfly-template

Java EE
JAX-RS – RESTEasy
Apache Deltaspike (similiar to Spring Data)
H2 Database
Docker
Maven

It is just an example and far from real application. It will be required to add tests for sure and it would be interesting to do it this way:
Docker with Arquillian Cube

Continue reading

Docker + Fedora Linux

sudo dnf update
curl -fsSL https://get.docker.com/ | sh
sudo systemctl start docker
sudo docker run hello-world
sudo groupadd docker
sudo usermod -aG docker your_username
docker run hello-world
sudo systemctl enable docker
sudo systemctl stop docker
sudo vi /etc/sysconfig/docker
Change to "OPTIONS=--selinux-enabled -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock"
sudo systemctl start docker

Docker docs
Docker configuring
Very easy. Next blog entry about Wildfly CRUD with docker.
docker run jboss/wildfly