Netty in Action
eBook - ePub

Netty in Action

Norman Maurer, Marvin Wolfthal

Partager le livre
  1. 296 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Netty in Action

Norman Maurer, Marvin Wolfthal

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Summary Netty in Action introduces the Netty framework and shows you how to incorporate it into your Java network applications. You'll learn to write highly scalable applications without the need to dive into the low-level non-blocking APIs at the core of Java.Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications. About the Technology Netty is a Java-based networking framework that manages complex networking, multithreading, and concurrency for your applications. And Netty hides the boilerplate and low-level code, keeping your business logic separate and easier to reuse. With Netty, you get an easy-to-use API, leaving you free to focus on what's unique to your application. About the Book Netty in Action introduces the Netty framework and shows you how to incorporate it into your Java network applications. You will discover how to write highly scalable applications without getting into low-level APIs. The book teaches you to think in an asynchronous way as you work through its many hands-on examples and helps you master the best practices of building large-scale network apps. What's Inside

  • Netty from the ground up
  • Asynchronous, event-driven programming
  • Implementing services using different protocols
  • Covers Netty 4.x


About the Reader This book assumes readers are comfortable with Java and basic network architecture. About the Authors Norman Maurer is a senior software engineer at Apple and a core developer of Netty. Marvin Wolfthal is a Dell Services consultant who has implemented mission-critical enterprise systems using Netty. Table of Contents
PART 1 NETTY CONCEPTS AND ARCHITECTURE

  • Netty-asynchronous and event-driven
  • Your first Netty application
  • Netty components and design
  • Transports
  • ByteBuf
  • ChannelHandler and ChannelPipeline
  • EventLoop and threading model
  • Bootstrapping
  • Unit testing
  • PART 2 CODECS
  • The codec framework
  • Provided ChannelHandlers and codecs
  • PART 3 NETWORK PROTOCOLS
  • WebSocket
  • Broadcasting events with UDP
  • PART 4 CASE STUDIES
  • Case studies, part 1
  • Case studies, part 2

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Netty in Action est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Netty in Action par Norman Maurer, Marvin Wolfthal en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Programming Languages. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Éditeur
Manning
Année
2015
ISBN
9781638353041

Part 1. Netty concepts and architecture

Netty is an advanced framework for creating high-performance networking applications. In part 1 we’ll explore its capabilities in depth and demonstrate three main points:
  • You don’t have to be a networking expert to build applications with Netty.
  • Using Netty is much easier than using the underlying Java APIs directly.
  • Netty promotes good design practices, such as keeping your application logic decoupled from the network layer.
In chapter 1, we’ll begin with a summary of the evolution of Java networking. After we’ve reviewed the basic concepts of asynchronous communications and event-driven processing we’ll take a first look at Netty’s core components. You’ll be ready to build your first Netty application in chapter 2! In chapter 3 you’ll begin your detailed exploration of Netty, from its core network protocols (chapter 4) and data-handling layers (chapters 5–6) to its concurrency model (chapter 7).
We’ll conclude part 1 by putting all the pieces together, and you’ll see how to configure the components of a Netty-based application to work together at runtime (chapter 8) and finally, how Netty helps you to test your applications (chapter 9).

Chapter 1. Netty—asynchronous and event-driven

This chapter covers
  • Networking in Java
  • Introducing Netty
  • Netty’s core components
Suppose you’re just starting on a new mission-critical application for a large, important company. In the first meeting you learn that the system must scale up to 150,000 concurrent users with no loss of performance. All eyes are on you. What do you say?
If you can say with confidence, “Sure, no problem,” then hats off to you. But most of us would probably take a more cautious position, like: “Sounds doable.” Then, as soon as we could get to a computer, we’d search for “high performance Java networking.”
If you run this search today, among the first results you’ll see this:
Netty: Home
netty.io/
Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients.
If you discovered Netty this way, as many have, your next steps were probably to browse the site, download the code, peruse the Javadocs and a few blogs, and start hacking. If you already had solid network programming experience, you probably made good progress; otherwise, perhaps not.
Why? High-performance systems like the one in our example require more than first-class coding skills; they demand expertise in several complex areas: networking, multithreading, and concurrency. Netty captures this domain knowledge in a form that can be used even by networking neophytes. But up to now, the lack of a comprehensive guide has made the learning process far more difficult than need be—hence this book.
Our primary goal in writing it has been to make Netty accessible to the broadest possible range of developers. This includes many who have innovative content or services to offer but neither the time nor inclination to become networking specialists. If this applies to you, we believe you’ll be pleasantly surprised at how quickly you’ll be ready to create your first Netty application. At the other end of the spectrum, we aim to support advanced practitioners who are seeking tools for creating their own network protocols.
Netty does indeed provide an extremely rich networking toolkit, and we’ll spend most of our time exploring its capabilities. But Netty is ultimately a framework, and its architectural approach and design principles are every bit as important as its technical content. Accordingly, we’ll be talking about points such as
  • Separation of concerns (decoupling business and network logic)
  • Modularity and reusability
  • Testability as a first-order requirement
In this first chapter, we’ll begin with background on high-performance networking, particularly its implementation in the Java Development Kit (JDK). With this context in place, we’ll introduce Netty, its core concepts, and building blocks. By the end of the chapter, you’ll be ready to tackle your first Netty-based client and server.

1.1. Networking in Java

Developers who started out in the early days of networking spent a lot of time learning the intricacies of the C language socket libraries and dealing with their quirks on different operating systems. The earliest versions of Java (1995–2002) introduced enough of an object-oriented façade to hide some of the thornier details, but creating a complex client/server protocol still required a lot of boilerplate code (and a fair amount of peeking under the hood to get it all working smoothly).
Those first Java APIs (java.net) supported only the so-called blocking functions provided by the native system socket libraries. The following listing shows an unadorned example of server code using these calls.
Listing 1.1. Blocking I/O example
The previous listing implements one of the basic Socket API patterns. Here are the most important points:
...

Table des matiĂšres