Skip to main content
Top

2017 | Book

Pro Java Clustering and Scalability

Building Real-Time Apps with Spring, Cassandra, Redis, WebSocket and RabbitMQ

insite
SEARCH

About this book

Build clustered and scalable Java-based, real-time applications using Spring Framework, Boot, WebSocket, Cassandra, Redis and RabbitMQ. In this book, you'll tie all this together with a dive-in case study, a real-time scalable chat application under differing scenarios. Pro Java Clustering and Scalability also discusses how to horizontally scale the WebSocket chat application using a full STOMP broker such as RabbitMQ.
Although this is a programming book, it also discusses many interesting infrastructure topics and tips about continuous delivery, Docker, NoSQL (Cassandra and Redis) and other related technologies.
What You Will LearnHandle clustering and scalability using various open source Java, microservices, and web services tools and technologies
Use Spring Framework, Boot, and other Spring technologies
Integrate with Redis, RabbitMQ, Cassandra, NoSQL, and much more
Test the case study code under various scenarios and stresses

Who This Book Is For
Experienced Java developers with at least some prior experience with Java, especially Spring Framework, Boot and other tools, and some web services.


Table of Contents

Frontmatter

Usage

Frontmatter
Chapter 1. Docker
Abstract
The chat application dependencies are pretty straightforward to set up when using Docker. In this chapter, you’ll learn what Docker is and also how to use the main Docker commands to manage services running on containers.
Jorge Acetozi
Chapter 2. Prerequisites
Abstract
Now that you have an understanding of how to run Docker containers, it’s time to set up the chat dependencies and get the application up and running. It’s also worth mentioning that the entire project was developed using Linux Ubuntu 14.04 LTS, although it can run on any operating system effortlessly. You are only required to have basic experience using a Unix shell such as Bash.
Jorge Acetozi
Chapter 3. Executing the Project Locally
Abstract
Now that you have the dependencies up and running, it’s time to start the chat application.
Jorge Acetozi
Chapter 4. Simulating a Conversation
Abstract
Now that you have the chat application up and running, you’ll learn how to use this application as if you were a common user.
Jorge Acetozi
Chapter 5. Setting Up the Development Environment
Abstract
Configuring the development environment for this project is quite straightforward. In this chapter, you will install Apache Maven and import the application to the Eclipse integrated development environment (IDE).
Jorge Acetozi

Architecture

Frontmatter
Chapter 6. Understanding the Relationship Between Domain and Architecture
Abstract
It’s impossible to create an architecture that is scalable, high-performing, secure, highly available, and cost-effective without having a deep understanding of the challenges you are going to face while developing it.
Jorge Acetozi
Chapter 7. Introduction to NoSQL
Abstract
The world is changing. For a long time companies such as IBM and Oracle were dictating the rules, but now Google, Facebook, Amazon, and others are ahead. These companies produce terabytes of data and receive millions of requests in short periods of time, and they are still growing every day. The question is, how are they able to scale and handle such a high volume of data and so many requests? The fact is that no one had ever encountered these sorts of problems before (even IBM or Oracle), so they had to create their own solutions to be able to scale.
Jorge Acetozi
Chapter 8. The Spring Framework
Abstract
The Spring Framework is the most widely used framework for enterprise Java applications. It’s a complete platform with many Spring subprojects under the “Spring umbrella” that help you with almost anything you need. It has a great community, and it’s evolving much faster than Java EE (and has been since the beginning actually).
Jorge Acetozi
Chapter 9. WebSocket
Abstract
As web applications got more advanced and pages more dynamic, a new model emerged, called Ajax.
Jorge Acetozi
Chapter 10. Spring WebSocket
Abstract
Spring WebSocket provides good support for WebSocket applications, and it’s easy to use when you understand what’s going on behind the scenes.
Jorge Acetozi
Chapter 11. Single-Node Chat Architecture
Abstract
After you sign in, the list of all available chat rooms is displayed.
Jorge Acetozi
Chapter 12. Multinode Chat Architecture
Abstract
Imagine that you want to horizontally scale the chat application by running two instances of the chat app on different servers.
Jorge Acetozi
Chapter 13. Horizontally Scaling Stateful Web Applications
Abstract
Let’s forget the WebSocket technology for a while and think about traditional web applications. You have already learned about the request/response HTTP model, and you know that HTTP is stateless. This means that after a server gives a response to a request, it closes the TCP connection, and it doesn’t know anything about the client (not even if the client is going to make other requests) anymore.
Jorge Acetozi

Code by Feature

Frontmatter
Chapter 14. Changing the Application Language
Abstract
This way, users from different countries can make better use of the system.
Jorge Acetozi
Chapter 15. Login
Abstract
When the form login is submitted to POST /login, Spring Security will intercept the request and query the MySQL instance to fetch the user and check whether the provided credentials are correct. However, if you don’t instruct Spring on how to do that, things are not going to work.
Jorge Acetozi
Chapter 16. New Account
Abstract
This field is the user database table’s primary key.
Jorge Acetozi
Chapter 17. New Chat Room
Abstract
In this chapter, I illustrate how easy it is to work with endpoints in Spring MVC.
Jorge Acetozi
Chapter 18. Joining the Chat Room
Abstract
Actually, the first two subscriptions are executed only once on the server side, and they are used to get some initial data, that is, the connected users and the users’ old conversations in this specific chat room.
Jorge Acetozi
Chapter 19. Sending a User’s Public Messages over WebSocket
Abstract
When the client sends a public in the chat room, the sendMessage JavaScript function is called. Essentially, it converts the instantMessage JavaScript object into a JSON representation and sends the message to the application destination /chatroom/send.message.
Jorge Acetozi
Chapter 20. Sending a User’s Private Messages over WebSocket
Abstract
When the client sends a private message in the chat room, the sendMessage JavaScript function is called. Essentially, it converts the instantMessage JavaScript object into a JSON representation and sends the message to the application destination /chatroom/send.message, which is the same destination used for sending a user’s public messages.
Jorge Acetozi

Testing the Code

Frontmatter
Chapter 21. Lazy Deployments vs. Fast Deployments
Abstract
Perhaps you’ve worked for a company where the deployment process to the production environment was very lazy. That is, it took many days or sometimes even months to happen. Believe it or not, in practice it’s not that difficult to find these scenarios.
Jorge Acetozi
Chapter 22. Continuous Delivery
Abstract
Of course, achieving this comes at a price. The entire delivery process (from development to production) must be highly automated. Remember, humans are good at creative tasks but horrible at repetitive tasks. Machines are horrible at creative tasks but excellent at repetitive tasks. Why not take advantage of both humans and machines? In other words, let humans and machines do what they do best!
Jorge Acetozi
Chapter 23. Types of Automated Tests
Abstract
There are lots of types of automated tests that can be coded. All of them have their strengths and weaknesses.
Jorge Acetozi
Chapter 24. Unit Tests
Abstract
Unit tests provide fast feedback, but they test only an isolated unit of code (a method in a class, for example).
Jorge Acetozi
Chapter 25. Integration Tests
Abstract
Integration tests are not as straightforward to code as unit tests because they really need to test an entire integration. For example, to test a database integration, you would need to set up this database before running the tests.
Jorge Acetozi
Chapter 26. Splitting Unit Tests from Integration Tests Using Maven Plug-ins
Abstract
This will execute the class UnitTestsSuite.java, that is, all the unit tests. Note how fast it is to execute these unit tests.
Jorge Acetozi
Chapter 27. Continuous Integration Server
Abstract
As the chat application grows, running integration tests on a developer’s machine becomes a boring task because it starts consuming a lot of time. Can you see the problem that could emerge? The application has good test coverage, but the developer doesn’t run the tests because they take too much time (the developer’s machine is not a powerful server, right?). Well, having tests and not running them is the same as not having tests, and you already know that having no tests is not a good idea!
Jorge Acetozi
Backmatter
Metadata
Title
Pro Java Clustering and Scalability
Author
Jorge Acetozi
Copyright Year
2017
Publisher
Apress
Electronic ISBN
978-1-4842-2985-9
Print ISBN
978-1-4842-2984-2
DOI
https://doi.org/10.1007/978-1-4842-2985-9

Premium Partner