Skip to main content
Top

Pro Java Clustering and Scalability

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

  • 2017
  • Book

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

  1. Frontmatter

  2. Usage

    1. Frontmatter

    2. Chapter 1. Docker

      Jorge Acetozi
      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.
    3. Chapter 2. Prerequisites

      Jorge Acetozi
      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.
    4. Chapter 3. Executing the Project Locally

      Jorge Acetozi
      Abstract
      Now that you have the dependencies up and running, it’s time to start the chat application.
    5. Chapter 4. Simulating a Conversation

      Jorge Acetozi
      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.
    6. Chapter 5. Setting Up the Development Environment

      Jorge Acetozi
      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).
  3. Architecture

    1. Frontmatter

    2. Chapter 6. Understanding the Relationship Between Domain and Architecture

      Jorge Acetozi
      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.
    3. Chapter 7. Introduction to NoSQL

      Jorge Acetozi
      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.
    4. Chapter 8. The Spring Framework

      Jorge Acetozi
      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).
    5. Chapter 9. WebSocket

      Jorge Acetozi
      Abstract
      As web applications got more advanced and pages more dynamic, a new model emerged, called Ajax.
    6. Chapter 10. Spring WebSocket

      Jorge Acetozi
      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.
    7. Chapter 11. Single-Node Chat Architecture

      Jorge Acetozi
      Abstract
      After you sign in, the list of all available chat rooms is displayed.
    8. Chapter 12. Multinode Chat Architecture

      Jorge Acetozi
      Abstract
      Imagine that you want to horizontally scale the chat application by running two instances of the chat app on different servers.
    9. Chapter 13. Horizontally Scaling Stateful Web Applications

      Jorge Acetozi
      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.
  4. Code by Feature

    1. Frontmatter

    2. Chapter 14. Changing the Application Language

      Jorge Acetozi
      Abstract
      This way, users from different countries can make better use of the system.
    3. Chapter 15. Login

      Jorge Acetozi
      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.
    4. Chapter 16. New Account

      Jorge Acetozi
      Abstract
      This field is the user database table’s primary key.
    5. Chapter 17. New Chat Room

      Jorge Acetozi
      Abstract
      In this chapter, I illustrate how easy it is to work with endpoints in Spring MVC.
    6. Chapter 18. Joining the Chat Room

      Jorge Acetozi
      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.
    7. Chapter 19. Sending a User’s Public Messages over WebSocket

      Jorge Acetozi
      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.
    8. Chapter 20. Sending a User’s Private Messages over WebSocket

      Jorge Acetozi
      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.
  5. Testing the Code

    1. Frontmatter

    2. Chapter 21. Lazy Deployments vs. Fast Deployments

      Jorge Acetozi
      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.
    3. Chapter 22. Continuous Delivery

      Jorge Acetozi
      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!
    4. Chapter 23. Types of Automated Tests

      Jorge Acetozi
      Abstract
      There are lots of types of automated tests that can be coded. All of them have their strengths and weaknesses.
    5. Chapter 24. Unit Tests

      Jorge Acetozi
      Abstract
      Unit tests provide fast feedback, but they test only an isolated unit of code (a method in a class, for example).
    6. Chapter 25. Integration Tests

      Jorge Acetozi
      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.
    7. Chapter 26. Splitting Unit Tests from Integration Tests Using Maven Plug-ins

      Jorge Acetozi
      Abstract
      This will execute the class UnitTestsSuite.java, that is, all the unit tests. Note how fast it is to execute these unit tests.
    8. Chapter 27. Continuous Integration Server

      Jorge Acetozi
      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!
  6. Backmatter

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

Accessibility information for this book is coming soon. We're working to make it available as quickly as possible. Thank you for your patience.

Premium Partner

    Image Credits
    Neuer Inhalt/© ITandMEDIA, Nagarro GmbH/© Nagarro GmbH, AvePoint Deutschland GmbH/© AvePoint Deutschland GmbH, AFB Gemeinnützige GmbH/© AFB Gemeinnützige GmbH, USU GmbH/© USU GmbH, Ferrari electronic AG/© Ferrari electronic AG