100% found this document useful (2 votes)
3 views

R2DBC Revealed: Reactive Relational Database Connectivity for Java and JVM Programmers 1st Edition Robert Hedgpeth download

The document is an overview of the book 'R2DBC Revealed: Reactive Relational Database Connectivity for Java and JVM Programmers' by Robert Hedgpeth, which focuses on R2DBC and its applications in reactive programming. It includes details about the book's structure, including chapters on reactive programming principles, R2DBC implementation, and transaction management. Additionally, it provides links to related resources and other Java programming books available for download.

Uploaded by

boicetattauy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
3 views

R2DBC Revealed: Reactive Relational Database Connectivity for Java and JVM Programmers 1st Edition Robert Hedgpeth download

The document is an overview of the book 'R2DBC Revealed: Reactive Relational Database Connectivity for Java and JVM Programmers' by Robert Hedgpeth, which focuses on R2DBC and its applications in reactive programming. It includes details about the book's structure, including chapters on reactive programming principles, R2DBC implementation, and transaction management. Additionally, it provides links to related resources and other Java programming books available for download.

Uploaded by

boicetattauy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

R2DBC Revealed: Reactive Relational Database

Connectivity for Java and JVM Programmers 1st


Edition Robert Hedgpeth download

https://textbookfull.com/product/r2dbc-revealed-reactive-
relational-database-connectivity-for-java-and-jvm-
programmers-1st-edition-robert-hedgpeth/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Java 8 Pocket Guide Instant Help for Java Programmers


1st Edition Liguori Robert Liguori Patricia

https://textbookfull.com/product/java-8-pocket-guide-instant-
help-for-java-programmers-1st-edition-liguori-robert-liguori-
patricia/

Computer Graphics for Java Programmers 3rd Edition Leen


Ammeraal

https://textbookfull.com/product/computer-graphics-for-java-
programmers-3rd-edition-leen-ammeraal/

Java Image Processing Recipes: With OpenCV and JVM


Modrzyk

https://textbookfull.com/product/java-image-processing-recipes-
with-opencv-and-jvm-modrzyk/

Java Image Processing Recipes: With OpenCV and JVM 1st


Edition Nicolas Modrzyk

https://textbookfull.com/product/java-image-processing-recipes-
with-opencv-and-jvm-1st-edition-nicolas-modrzyk/
Java 9 Revealed: For Early Adoption and Migration 1st
Edition Kishori Sharan (Auth.)

https://textbookfull.com/product/java-9-revealed-for-early-
adoption-and-migration-1st-edition-kishori-sharan-auth/

Java 9 Modularity Revealed: Project Jigsaw and Scalable


Java Applications Alexandru Jecan

https://textbookfull.com/product/java-9-modularity-revealed-
project-jigsaw-and-scalable-java-applications-alexandru-jecan/

Vert x in Action Asynchronous and Reactive Java 1st


Edition Julien Ponge

https://textbookfull.com/product/vert-x-in-action-asynchronous-
and-reactive-java-1st-edition-julien-ponge/

Pro SQL Server Relational Database Design and


Implementation 5th Edition Louis Davidson

https://textbookfull.com/product/pro-sql-server-relational-
database-design-and-implementation-5th-edition-louis-davidson/

Pro SQL Server Relational Database Design and


Implementation Sixth Edition Louis Davidson

https://textbookfull.com/product/pro-sql-server-relational-
database-design-and-implementation-sixth-edition-louis-davidson/
R2DBC
Revealed
Reactive Relational Database Connectivity
for Java and JVM Programmers

Robert Hedgpeth
R2DBC Revealed
Reactive Relational Database
Connectivity for Java and JVM
Programmers

Robert Hedgpeth
R2DBC Revealed: Reactive Relational Database Connectivity for Java and JVM
Programmers
Robert Hedgpeth
Chicago, IL, USA

ISBN-13 (pbk): 978-1-4842-6988-6 ISBN-13 (electronic): 978-1-4842-6989-3


https://doi.org/10.1007/978-1-4842-6989-3

Copyright © 2021 by Robert Hedgpeth


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Jonathan Gennick
Development Editor: Laura Berendson
Coordinating Editor: Jill Balzano
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media LLC, 1 New York Plaza, Suite
4600, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.
com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner)
is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware
corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484269886. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
To my beautiful, intelligent, and incredibly patient wife, Tracy,
for encouraging and supporting me throughout all the nights and
weekends I spent on this book, and to our infant son, Darius, for
providing ample opportunities for early morning writing.
Table of Contents
About the Author��������������������������������������������������������������������������������������������������� xiii

About the Technical Reviewer���������������������������������������������������������������������������������xv


Acknowledgments�������������������������������������������������������������������������������������������������xvii

The World at Scale��������������������������������������������������������������������������������������������������xix

Introduction����������������������������������������������������������������������������������������������������������xxiii

Part I: The Reactive Movement and R2DBC������������������������������������������� 1


Chapter 1: The Case for Reactive Programming������������������������������������������������������� 3
A Traditional Approach������������������������������������������������������������������������������������������������������������������ 3
Imperative vs. Declarative Programming�������������������������������������������������������������������������������������� 6
Thinking Reactively����������������������������������������������������������������������������������������������������������������������� 8
The Reactive Manifesto���������������������������������������������������������������������������������������������������������������� 9
Reactive Systems������������������������������������������������������������������������������������������������������������������ 10
Reactive Systems != Reactive Programming������������������������������������������������������������������������ 12
Asynchronous Data Streams������������������������������������������������������������������������������������������������������� 13
Data Streams������������������������������������������������������������������������������������������������������������������������� 13
Back Pressure����������������������������������������������������������������������������������������������������������������������� 15
Summary������������������������������������������������������������������������������������������������������������������������������������ 16

Chapter 2: Introduction to R2DBC��������������������������������������������������������������������������� 17


What Is R2DBC?�������������������������������������������������������������������������������������������������������������������������� 17
A New Approach�������������������������������������������������������������������������������������������������������������������� 18
Beyond JDBC������������������������������������������������������������������������������������������������������������������������� 19

v
Table of Contents

R2DBC Implementations������������������������������������������������������������������������������������������������������������� 20
Embracing Reactive Programming���������������������������������������������������������������������������������������� 21
Enabling Vendor Creativity����������������������������������������������������������������������������������������������������� 22
Enforcing Compliance����������������������������������������������������������������������������������������������������������� 22
Reactive Streams������������������������������������������������������������������������������������������������������������������������ 22
Another Specification������������������������������������������������������������������������������������������������������������ 23
API Fundamentals������������������������������������������������������������������������������������������������������������������ 23
Processors����������������������������������������������������������������������������������������������������������������������������� 25
JVM Interfaces����������������������������������������������������������������������������������������������������������������������� 26
Implementations�������������������������������������������������������������������������������������������������������������������� 27
Summary������������������������������������������������������������������������������������������������������������������������������������ 27

Part II: The R2DBC Service-­Provider Interface������������������������������������ 29


Chapter 3: The Path to Implementation������������������������������������������������������������������ 31
The Database Landscape������������������������������������������������������������������������������������������������������������ 31
Power in Simplicity��������������������������������������������������������������������������������������������������������������������� 33
R2DBC Compliance��������������������������������������������������������������������������������������������������������������������� 34
Guiding Principles������������������������������������������������������������������������������������������������������������������ 34
Specification Implementation Requirements������������������������������������������������������������������������ 35
Specification Extensions������������������������������������������������������������������������������������������������������������� 37
Wrapped Interfaces��������������������������������������������������������������������������������������������������������������� 38
Closeable Interfaces�������������������������������������������������������������������������������������������������������������� 38
Testing and Validation����������������������������������������������������������������������������������������������������������������� 40
Summary������������������������������������������������������������������������������������������������������������������������������������ 40

Chapter 4: Connections������������������������������������������������������������������������������������������ 41
Establishing Connections������������������������������������������������������������������������������������������������������������ 41
The Anatomy�������������������������������������������������������������������������������������������������������������������������� 42
R2DBC Hindsight������������������������������������������������������������������������������������������������������������������� 43
Connection Factory��������������������������������������������������������������������������������������������������������������������� 45
Driver Implementations��������������������������������������������������������������������������������������������������������� 45
Exposing Metadata���������������������������������������������������������������������������������������������������������������� 46

vi
Table of Contents

ConnectionFactories������������������������������������������������������������������������������������������������������������������� 47
Discovery������������������������������������������������������������������������������������������������������������������������������� 47
Bringing It All Together���������������������������������������������������������������������������������������������������������� 48
Connections�������������������������������������������������������������������������������������������������������������������������������� 48
Obtaining Connections���������������������������������������������������������������������������������������������������������� 51
Acquiring Metadata��������������������������������������������������������������������������������������������������������������� 51
Validating Connections���������������������������������������������������������������������������������������������������������� 51
Closing Connections�������������������������������������������������������������������������������������������������������������� 52
Summary������������������������������������������������������������������������������������������������������������������������������������ 52

Chapter 5: Transactions������������������������������������������������������������������������������������������ 53
Transaction Fundamentals���������������������������������������������������������������������������������������������������������� 53
The Need for Transactions����������������������������������������������������������������������������������������������������� 54
ACID Compliance������������������������������������������������������������������������������������������������������������������� 55
Methods of Control���������������������������������������������������������������������������������������������������������������� 56
R2DBC Transaction Management������������������������������������������������������������������������������������������������ 58
Auto-commit Mode���������������������������������������������������������������������������������������������������������������� 58
Explicit Transactions�������������������������������������������������������������������������������������������������������������� 59
Managing Savepoints������������������������������������������������������������������������������������������������������������ 60
Releasing Savepoints������������������������������������������������������������������������������������������������������������ 62
Isolation Levels��������������������������������������������������������������������������������������������������������������������������� 62
Managing Isolation���������������������������������������������������������������������������������������������������������������� 62
Performance Considerations������������������������������������������������������������������������������������������������� 63
Summary������������������������������������������������������������������������������������������������������������������������������������ 64

Chapter 6: Statements�������������������������������������������������������������������������������������������� 65
SQL Statements�������������������������������������������������������������������������������������������������������������������������� 65
R2DBC Statements���������������������������������������������������������������������������������������������������������������������� 66
The Basics����������������������������������������������������������������������������������������������������������������������������� 67
Dynamic Input����������������������������������������������������������������������������������������������������������������������� 68
Auto-generated Values���������������������������������������������������������������������������������������������������������������� 72
Performance Hints���������������������������������������������������������������������������������������������������������������������� 72
Summary������������������������������������������������������������������������������������������������������������������������������������ 73
vii
Table of Contents

Chapter 7: Handling Results����������������������������������������������������������������������������������� 75


The Fundamentals���������������������������������������������������������������������������������������������������������������������� 75
Consuming Results��������������������������������������������������������������������������������������������������������������������� 77
Cursors���������������������������������������������������������������������������������������������������������������������������������� 77
Update Count������������������������������������������������������������������������������������������������������������������������� 77
Rows and Columns��������������������������������������������������������������������������������������������������������������������� 78
Row Anatomy������������������������������������������������������������������������������������������������������������������������� 79
Retrieving Values������������������������������������������������������������������������������������������������������������������� 81
Summary������������������������������������������������������������������������������������������������������������������������������������ 82

Chapter 8: Result Metadata������������������������������������������������������������������������������������ 83


Data About Data�������������������������������������������������������������������������������������������������������������������������� 83
Row Metadata����������������������������������������������������������������������������������������������������������������������� 83
Column Metadata������������������������������������������������������������������������������������������������������������������ 84
Retrieving Metadata�������������������������������������������������������������������������������������������������������������������� 87
Obtaining a RowMetadata Object������������������������������������������������������������������������������������������ 87
Accessing ColumnMetadata�������������������������������������������������������������������������������������������������� 88
Summary������������������������������������������������������������������������������������������������������������������������������������ 88

Chapter 9: Mapping Data Types������������������������������������������������������������������������������ 89


Data Type Differences����������������������������������������������������������������������������������������������������������������� 89
Mapping Simple Data Types�������������������������������������������������������������������������������������������������������� 91
Character Types��������������������������������������������������������������������������������������������������������������������� 91
Boolean Types������������������������������������������������������������������������������������������������������������������������ 92
Binary Types�������������������������������������������������������������������������������������������������������������������������� 92
Numeric Types����������������������������������������������������������������������������������������������������������������������� 93
DateTime Types��������������������������������������������������������������������������������������������������������������������� 94
Collection Types��������������������������������������������������������������������������������������������������������������������� 95
Mapping Advanced Data Types��������������������������������������������������������������������������������������������������� 95
BLOBs and CLOBs������������������������������������������������������������������������������������������������������������������ 95
Summary������������������������������������������������������������������������������������������������������������������������������������ 99

viii
Table of Contents

Chapter 10: Handling Exceptions�������������������������������������������������������������������������� 101


General Exceptions������������������������������������������������������������������������������������������������������������������� 101
IllegalArgumentException���������������������������������������������������������������������������������������������������� 101
IllegalStateException����������������������������������������������������������������������������������������������������������� 102
UnsupportedOperationException����������������������������������������������������������������������������������������� 102
R2DBCException������������������������������������������������������������������������������������������������������������������ 102
Categorized Exceptions������������������������������������������������������������������������������������������������������������� 108
Non-transient Exceptions���������������������������������������������������������������������������������������������������� 108
Transient Exceptions����������������������������������������������������������������������������������������������������������� 109
Summary���������������������������������������������������������������������������������������������������������������������������������� 109

Part III: Getting Started with R2DBC and MariaDB���������������������������� 111


Chapter 11: Getting Started with R2DBC�������������������������������������������������������������� 113
Database Drivers����������������������������������������������������������������������������������������������������������������������� 113
]������������������������������������������������������������������������������������������������������������������������������������������� 113
R2DBC Client Libraries�������������������������������������������������������������������������������������������������������������� 114
Creating a Client������������������������������������������������������������������������������������������������������������������ 115
Use an Existing Client Library���������������������������������������������������������������������������������������������� 116
Looking Ahead��������������������������������������������������������������������������������������������������������������������� 117
MariaDB and R2DBC����������������������������������������������������������������������������������������������������������������� 117
Introduction to MariaDB������������������������������������������������������������������������������������������������������ 118
Download and Install����������������������������������������������������������������������������������������������������������� 118
Using R2DBC����������������������������������������������������������������������������������������������������������������������������� 121
Requirements���������������������������������������������������������������������������������������������������������������������� 121
Apache Maven Basics��������������������������������������������������������������������������������������������������������� 122
Show Me the Code�������������������������������������������������������������������������������������������������������������������� 125
Looking Ahead�������������������������������������������������������������������������������������������������������������������������� 125
Summary���������������������������������������������������������������������������������������������������������������������������������� 125

ix
Table of Contents

Chapter 12: Managing Connections���������������������������������������������������������������������� 127


Configuration���������������������������������������������������������������������������������������������������������������������������� 127
Database Connectivity��������������������������������������������������������������������������������������������������������� 128
Driver Implementation and Extensibility������������������������������������������������������������������������������ 128
Running Reactive Code������������������������������������������������������������������������������������������������������������� 129
Establishing Connections���������������������������������������������������������������������������������������������������������� 129
Obtaining MariadbConnectionFactory��������������������������������������������������������������������������������� 130
Creating a Connection��������������������������������������������������������������������������������������������������������� 132
Validating and Closing Connections������������������������������������������������������������������������������������ 133
Putting It All Together���������������������������������������������������������������������������������������������������������� 134
Metadata����������������������������������������������������������������������������������������������������������������������������� 139
Show Me the Code�������������������������������������������������������������������������������������������������������������������� 140
Summary���������������������������������������������������������������������������������������������������������������������������������� 141

Chapter 13: Managing Data���������������������������������������������������������������������������������� 143


MariadbStatement�������������������������������������������������������������������������������������������������������������������� 143
Statement Hierarchy������������������������������������������������������������������������������������������������������������ 143
Dependency Disclaimer������������������������������������������������������������������������������������������������������� 144
The Basics��������������������������������������������������������������������������������������������������������������������������������� 144
Creating Statements������������������������������������������������������������������������������������������������������������ 144
Obtaining a Publisher���������������������������������������������������������������������������������������������������������� 145
Subscribing to Execution����������������������������������������������������������������������������������������������������� 145
Retrieving Results��������������������������������������������������������������������������������������������������������������������� 146
Row Update Count��������������������������������������������������������������������������������������������������������������� 146
Mapping Results������������������������������������������������������������������������������������������������������������������ 147
Generated Values����������������������������������������������������������������������������������������������������������������� 151
Multiple Statements������������������������������������������������������������������������������������������������������������ 152
Parameterized Statements������������������������������������������������������������������������������������������������������� 154
Binding Parameters������������������������������������������������������������������������������������������������������������� 154
Batching Statements����������������������������������������������������������������������������������������������������������� 155

x
Table of Contents

Reactive Control������������������������������������������������������������������������������������������������������������������������ 156


Blocking Execution�������������������������������������������������������������������������������������������������������������� 156
Show Me the Code�������������������������������������������������������������������������������������������������������������������� 160
Summary���������������������������������������������������������������������������������������������������������������������������������� 160

Chapter 14: Managing Transactions��������������������������������������������������������������������� 161


Database Transaction Support�������������������������������������������������������������������������������������������������� 161
Database Preparation���������������������������������������������������������������������������������������������������������� 161
Transaction Basics�������������������������������������������������������������������������������������������������������������������� 162
Auto-committing������������������������������������������������������������������������������������������������������������������ 163
Explicit Transactions������������������������������������������������������������������������������������������������������������ 163
Managing Savepoints���������������������������������������������������������������������������������������������������������������� 167
Using Savepoints����������������������������������������������������������������������������������������������������������������� 167
Releasing Savepoints���������������������������������������������������������������������������������������������������������� 169
Handling Isolation Levels���������������������������������������������������������������������������������������������������������� 170
Show Me the Code�������������������������������������������������������������������������������������������������������������������� 170
Summary���������������������������������������������������������������������������������������������������������������������������������� 171

Chapter 15: Connection Pooling��������������������������������������������������������������������������� 173


Connection Pool Fundamentals������������������������������������������������������������������������������������������������ 173
Benefits of Connection Pooling�������������������������������������������������������������������������������������������� 174
How to Get Started�������������������������������������������������������������������������������������������������������������� 175
R2DBC Pool������������������������������������������������������������������������������������������������������������������������������� 176
Adding a New Dependency�������������������������������������������������������������������������������������������������� 176
Connection Pool Configuration�������������������������������������������������������������������������������������������� 177
Managing Connections�������������������������������������������������������������������������������������������������������� 181
Show Me the Code�������������������������������������������������������������������������������������������������������������������� 183
Summary���������������������������������������������������������������������������������������������������������������������������������� 184

xi
Table of Contents

Chapter 16: Practical Applications with Spring Data and R2DBC������������������������ 185
Introduction to Spring��������������������������������������������������������������������������������������������������������������� 185
Spring Boot�������������������������������������������������������������������������������������������������������������������������� 186
Spring Data�������������������������������������������������������������������������������������������������������������������������� 187
Spring Data R2DBC�������������������������������������������������������������������������������������������������������������� 187
Getting Started�������������������������������������������������������������������������������������������������������������������������� 189
Spring Initializr�������������������������������������������������������������������������������������������������������������������� 189
Configuring Connections����������������������������������������������������������������������������������������������������� 194
Spring Data Repositories����������������������������������������������������������������������������������������������������� 195
Bringing It All Together�������������������������������������������������������������������������������������������������������� 199
Testing It Out����������������������������������������������������������������������������������������������������������������������������� 204
Build and Run the Project���������������������������������������������������������������������������������������������������� 204
Call an Endpoint������������������������������������������������������������������������������������������������������������������ 205
Show Me the Code�������������������������������������������������������������������������������������������������������������������� 205
Summary���������������������������������������������������������������������������������������������������������������������������������� 205

Index��������������������������������������������������������������������������������������������������������������������� 207

xii
About the Author
Robert Hedgpeth is a professional software engineer,
speaker, and developer relations enthusiast residing in the
bustling metropolis of Chicago, Illinois. Rob has more than
15 years of professional development experience, primarily
in the application development space. Throughout the years,
he has contributed to the architecture and development
of many solutions, using a large array of languages and
technologies. Now, as a developer advocate and evangelist,
Rob gets to combine his love for technology with his mission
to fuel developers' curiosity and passion. Follow him on
Twitter: @probablyrealrob.

xiii
About the Technical Reviewer
Brian Molt is a software developer at a manufacturing
company in Nebraska where he has been for 17 years.
During his time there, he has programmed with multiple
languages on a variety of platforms, including RPGLE on
an AS/400, web development with ASP.NET, and desktop
application development with JavaFX, and now he creates
REST services using JAX-RS.

xv
Acknowledgments
I’m not going to lie. Writing my first book has been an incredibly daunting and
challenging task. I spent many long nights, early mornings, and weekends researching,
writing, researching some more, and rewriting. But absolutely none of it would have
been possible without the help from some amazing people.
First, I’d like to thank the Apress team, as this book wouldn’t have been possible
without the opportunity provided by Jonathan Gennick, Jill Balzano, Laura Berendson,
and the rest of the amazing folks at Apress. A special thank you, Brian Molt, for not only
providing technical expertise but also the insight of a teammate who was truly invested
in the success of this book.
Next, I’d like to thank Mark Paluch, the spec lead for the R2DBC specification. You
were incredibly helpful and encouraging throughout the whole process and provided
extremely thorough feedback for all of my questions.
And last, and most importantly, I’d like to thank my wonderful wife, Tracy. Writing
a book isn’t easy. Writing a book during a global pandemic and as first-time parents
is a whole other level. Absolutely none of this would have been possible without your
support, encouragement, and patience.

xvii
The World at Scale
One of the few stable things in information technology is constant change.
Software, once written as machine code, then by using compilers, went (and still
goes) through various paradigm changes: procedural, data driven, object oriented,
functional. There have been many more programming models, and others will follow.
Patterns come and go as we speak. All this is driven by purpose, capabilities of our
runtime environments, constraints, and business requirements.
In a similar way, the way how we consume software services has changed many
times. Back in the 1990s, software was primarily installed locally and sometimes backed
by a server. Think of your good old desktop computer. The 2000s are characterized by
online services. More and more services became available through the Internet, all
hosted in their own data centers. Businesses began investigating web applications to
avoid installing software on each machine. Data centers grew.
The 2010s finally set the stage for software-backed services to run in the cloud. Many
online services were founded these years. It’s the golden digital age. Businesses driven
by software can simply scale by adding another batch of machines to their data center to
serve more customers, or in their cloud.
Scalability is only constrained by the remaining capacity in a data center, the
investment in servers, and the operational cost for computer systems. Scaling a business
comes with many challenges. One of them is efficiency. Efficiency becomes an important
metric to measure how well a system is utilized compared to its cost.
But what impacts the efficiency and scalability of an application?
To answer this question, we have to get to the bottom of an application and its
programming language. Are you ready to dig through the physiology of applications?
Ready? Go!
All applications have in common that they require computation power and memory
to fulfill their work. How many concurrent requests/users/processes/<insert your
measurement unit here> a single machine can handle depends primarily on CPU and
memory demand. It also depends on “how” CPU and memory are used with a strong tie
to the duration in which resources get occupied.

xix
The World at Scale

Typical enterprise applications on the JVM follow an imperative programming style


that guarantees synchronization and order of execution for each individual statement.
Imperative programming comes with certain effects that aren’t immediately visible.
One of these effects is how I/O gets handled and how it affects threads. Typically,
applications require an integration with a database, message broker, or another remote
service to perform their work. When communicating with remote integrations, the
network becomes an integral part of the work that has to be done. It becomes a driver
for latency. Network performance and remote peer performance become a factor that
affects scalability as I/O causes to block the underlying thread. Threads require memory
and CPU. You can’t have an infinite number. That being said, threads impose a primary
constraint for application scalability.
With sufficiently high I/O load, machines can be kept busy with waiting for I/O – they
basically wait all the time with CPU and memory being maxed out. As you might already
tell, such an arrangement isn’t efficient.
Now that we have identified constraints for scalability and efficiency, we should take
a look at what we can do about this aspect.
There are various approaches to overcome the limitations of the imperative
programming model. The most significant and most efficient one is just not using
blocking I/O. Using non-blocking I/O is all but trivial.
In the JVM space, we can use various abstractions that help with developing highly
efficient applications. So far, the only consistent programming model that helps with
non-blocking I/O is reactive programming. Reactive programming is heavily stream and
event oriented. It is characterized by pipeline definitions, operators, and a functional
programming style. Reactive programming leads to a well-structured code that isn’t
cluttered with endless callbacks.
Data sources, internal and inter-process sources, follow the same style. The reactive
runtime and its integrations encapsulate threading and the non-blocking I/O business.
Reactive drivers expose a convenient API that can be directly used without worrying
about how to use non-blocking I/O.
Reactive programming on the JVM is still a young endeavor. In the past years, an
inter-op standard emerged to connect reactive libraries so that they can interact with
each other. This standard is Reactive Streams.
The very first abstractions that followed Reactive Streams were composition libraries,
web frameworks, messaging libraries, and the MongoDB client.

xx
The World at Scale

Over time, the number of reactive database clients grew, but all of these were
targeting NoSQL data stores: MongoDB, Redis, Cassandra, and Couchbase. However,
large parts of data are still hosted in SQL databases.
The standard way to access SQL databases on the JVM is JDBC. JDBC uses a blocking
API model which renders JDBC unusable for reactive programming.
The growing adoption of reactive programming raised continuously the question
of how to integrate with SQL databases in general and how to use existing libraries to
run queries and map objects in particular. Using JDBC on a ThreadPool may help for
small-scale applications. ThreadPools however do not turn blocking behavior into non-­
blocking – the blocking problem is just put somewhere else instead of solving it.
Facing demand from reactive application developers, without an existing
standardized API, a small group of developers formed to investigate how reactive
applications could be integrated with SQL databases. And that was the inception
of R2DBC in 2017, an open standard to let the world run at scale using reactive
programming with SQL databases.

xxi
Introduction
I think it goes without saying that software users' expectations have never been higher.
With the standards of performance and usability continually rising, we developers have
been challenged to innovate like never before. Reactive programming has provided us an
avenue toward such innovation.
However, for far too long, we weren't able to achieve fully reactive solutions within
the Java ecosystem. We've been limited to trying to work around the blocking nature of
the Java Database Connectivity (JDBC) Application Programming Interface (API) within
our reactive solutions. But along came the Reactive Relational Database Connectivity
(R2DBC) specification, and suddenly the doors to developing fully reactive applications
flung open.
Starting by gaining a solid understanding of reactive programming and what it
means to use declarative programming techniques, we’ll lay the foundation for not only
what it is and how it works but why it’s so important.
Diving into the specification, you’ll learn how a relatively small collection of
interfaces and classes makes it possible to create a lightweight driver implementation
that, utilizing the power of the Reactive Streams API, completely unblocks your
applications’ interactions to underlying relational data storage solutions.
So, whether you’ve been creating reactive applications for years or at this very
moment are like “What the heck is reactive programming?”, my hope is that by the time
you’ve finished this book, you will have not only a solid understanding of the R2DBC
specification but also the confidence, provided in part by practical solution code and
samples, to start creating your own solutions using R2DBC.

xxiii
PART I

The Reactive Movement


and R2DBC
CHAPTER 1

The Case for Reactive


Programming
Buzzword technologies are all too familiar within the software engineering world. For
years, some of the most creative minds have given us development innovations that have
completely changed the landscape of our solutions. On the other hand, some of those
trending technologies have caused us much more pain in the long run. All the hype can
be difficult to assess.
In this first chapter, I’d like to address the paradigm of reactive programming, which
has been gaining popularity for several years, and help to lay the groundwork for our
journey into the idea of Reactive Relational Database Connectivity (R2DBC).
Since you’re reading this book, I’m going to assume that you have likely at least
heard or read the words “reactive” and “programming” paired together before this point.
Heck, I’ll even go out on a limb and guess that you might have even heard or read that in
order to create a truly reactive solution, you need to think reactively. But what does all of
that even mean? Well, let’s find out!

A Traditional Approach
Introducing new technologies can be challenging, but I’ve found that it can help to
identify a common, real-world use case that we, as developers, have encountered and
see how it fits within that context.
Imagine a basic solution that contains web request workflow between a client
application and a server application, and let’s start at the point where there’s an
asynchronous request initiated from the client to the server.

3
© Robert Hedgpeth 2021
R. Hedgpeth, R2DBC Revealed, https://doi.org/10.1007/978-1-4842-6989-3_1
Chapter 1 The Case for Reactive Programming

Note When something is occurring asynchronously, it means that there is a


relationship between two or more events/objects that interact within the same
system but don’t occur at predetermined intervals and don’t necessarily rely on
each other's existence to function. Put more simply, they are events that are not
coordinated with each other and happen simultaneously.

Upon receiving the request, the server spins up a new thread for processing
(Figure 1-1).

Client Server Thread

Request

Response

Client Server Thread

Figure 1-1. Executing a simple, synchronous web request from a client to server

Simple enough, and it runs, so ship it, right? Not so fast! Rarely is it the case that
requests are that simple. It could be the case, like in Figure 1-2, that the server thread
needs to access a database to complete the work requested by the client. However, while
the database is being accessed, the server thread waits, blocking more work from being
performed until a response is returned by the database.

4
Chapter 1 The Case for Reactive Programming

Client Server Thread Database

Request

Query

Result
Response

Client Server Thread Database

Figure 1-2. The server thread is blocked from performing work while the database
returns a response
Unfortunately, that’s probably not an optimal solution as there’s no way to know how
long the database call will take. That’s not likely to scale well. So, in an effort to optimize
the client’s time and keep it working, you could add more threads to process multiple
requests in parallel, like in Figure 1-3.

5
Chapter 1 The Case for Reactive Programming

Client Server Thread 1 Server Thread 2 Database

Request 1
Query

Request 2

Response 2
Result
Response 1

Client Server Thread 1 Server Thread 2 Database

Figure 1-3. Subsequent incoming requests are processed using additional threads
Now we’re cooking! You can just continue to add threads to handle additional
processing, right? Not so fast. As with most things in life, if something seems too good to
be true, it probably is. The trade-off for adding additional threads is pesky problems like
higher resource consumption, possibly resulting in decreased throughput, and, in many
cases, increased complexity for developers due to thread context management.

Note For many applications, using multiple threads will work as a viable solution.
Reactive programming is not a silver bullet. However, reactive solutions can help
utilize resources more efficiently. Read on to learn how!

Imperative vs. Declarative Programming


Using multiple threads to prevent blocking operations is a common approach within
imperative programming paradigms and languages. That’s because the imperative
approach is a process that describes, step-by-step, the state a program should be in to
accomplish a specific goal. Ultimately, imperative processes hinge on controlling the
flow of information, which can be very useful in certain situations, but can also create
quite a headache, as I alluded to before, with memory and thread management.

6
Chapter 1 The Case for Reactive Programming

Declarative programming, on the other hand, does not focus on how to accomplish a
specific goal but rather the goal itself. But that’s fairly vague, so let’s back up a bit.
Consider the following analogies:

• Imperative programming is like attending an art class and listening


to the teacher give you step-by-step instructions on how to paint a
landscape.

• Declarative programming is like attending an art class and being


told to paint a landscape. The teacher doesn’t care how you do it, just
that it gets done.

Tip Both imperative and declarative programming paradigms have strengths and
weaknesses. Like with any task, make sure you choose the right tool for the job!

For this book, I’m going to be using the Java programming languages for all the
examples. Now, it’s no secret that Java is an imperative language, and as such its focus
is on how to achieve the final result. That said, it’s easy for us to imagine how to write
imperative instructions using Java, but what you may not know is that you can also write
declarative flows. For instance, consider the following.
Here’s an imperative approach to summing a range of numbers, step-by-step, from
one to ten:

int sum = 0;
for (int i = 1; i <= 10; i++) {
     sum += i;
}
System.out.println(sum); // 55

Alternatively, a declarative approach to summing a range of numbers from one to ten


involves working with data streams and receiving a result as some unknown, or rather
unspecified, time in the future:

int sumByStream = IntStream.rangeClosed(0,10).sum();


System.out.println(sumByStream); // 55

7
Chapter 1 The Case for Reactive Programming

Note In Java 8, streams were introduced as part of an effort to increase


the declarative programming capabilities within the language. IntStream
rangeClosed(int startInclusive, int endInclusive) returns an
IntStream from startInclusive (inclusive) to endInclusive (inclusive) by
an incremental step of 1.

However, for the time being, it’s not important that you understand a Stream object
or the underlying IntStream specialization. No, for now, set the idea of a “stream” to the
side; we’ll get back to it.
The real takeaway here is that both approaches yield the same results, but the
declarative approach is merely setting an expectation for the result of an operation, not
dictating the underlying implementation steps. This is fundamentally, from a high level,
how reactive programming works. Still a little hazy? Let’s dive deeper.

Thinking Reactively
As I mentioned previously, reactive programming, at its core, is declarative. It aims
to circumvent blocking states by eliminating many of the issues caused by having to
maintain numerous threads. Ultimately, this is accomplished by managing expectations
between the client and server.
In fact, pursuing a more reactive approach, upon receiving a request from the client,
the server thread calls on the database for processing, but does not wait for a response.
This frees up the server thread to continue processing incoming requests. Then, at an
undetermined amount of time later, a response, in the form of an event, is received and
reacted to by the server thread from the database.

8
Chapter 1 The Case for Reactive Programming

Client Server Thread Database

Request 1

Query

Request 2

Response
Result

Response

Client Server Thread Database

Figure 1-4. The client does not wait for a direct response from the server

The non-blocking and event-driven behaviors displayed in Figure 1-4 are the
foundation which reactive programming is built on.

The Reactive Manifesto


I know what you’re thinking. The overall concept behind reactive programming isn’t
new, so why the hype? Well, it started with the formalization of what constitutes a
reactive system.
In 2013, the Reactive Manifesto was created as a way to address new requirements, at
the time, in application development and provide a common vocabulary for discussing
complex concepts, like reactive programming. And then, in 2014, it was revised, via
version 2.0, to more accurately reflect the core value of reactive design.

9
Chapter 1 The Case for Reactive Programming

Reactive Systems
The Reactive Manifesto was created to clearly define four objectives of reactive systems,
cited verbatim in the following:

Responsive: The system responds in a timely manner if at all


possible. Responsiveness is the cornerstone of usability and utility,
but more than that, responsiveness means that problems may be
detected quickly and dealt with effectively. Responsive systems focus
on providing rapid and consistent response times, establishing
reliable upper bounds so they deliver a consistent quality of service.
This consistent behaviour in turn simplifies error handling, builds
end user confidence, and encourages further interaction.

Resilient: The system stays responsive in the face of failure. This


applies not only to highly-available, mission-critical systems—any
system that is not resilient will be unresponsive after a failure.
Resilience is achieved by replication, containment, isolation
and delegation. Failures are contained within each component,
isolating components from each other and thereby ensuring that
parts of the system can fail and recover without compromising
the system as a whole. Recovery of each component is delegated
to another (external) component and high-availability is ensured
by replication where necessary. The client of a component is not
burdened with handling its failures.
Elastic: The system stays responsive under varying workload.
Reactive Systems can react to changes in the input rate by
increasing or decreasing the resources allocated to service these
inputs. This implies designs that have no contention points or
central bottlenecks, resulting in the ability to shard or replicate
components and distribute inputs among them. Reactive Systems
support predictive, as well as Reactive, scaling algorithms by
providing relevant live performance measures. They achieve
elasticity in a cost-effective way on commodity hardware and
software platforms.

10
Chapter 1 The Case for Reactive Programming

Message Driven: Reactive Systems rely on asynchronous message-­


passing to establish a boundary between components that ensures
loose coupling, isolation and location transparency. This boundary
also provides the means to delegate failures as messages. Employing
explicit message-passing enables load management, elasticity, and
flow control by shaping and monitoring the message queues in
the system and applying back-pressure when necessary. Location
transparent messaging as a means of communication makes it
possible for the management of failure to work with the same
constructs and semantics across a cluster or within a single host.
Non-blocking communication allows recipients to only consume
resources while active, leading to less system overhead.

Figure 1-5. The four tenets of the Reactive Manifesto

Put more simply, a reactive system is an architectural approach that seeks to


combine multiple, independent solutions into a single, cohesive unit that, as a whole,
remains responsive, or reactive, to the world around it with the solutions simultaneously
remaining aware of each other. And put as simply as possible, a reactive system is when
a unit, adhering to a set of guidelines, of the system remains reactive to each of the other
units within the same system that, using those same guidelines, is collectively reactive to
external systems.

11
Another Random Document on
Scribd Without Any Related Topics
GENUINE IRISH LINENS AND LAWNS.
Where purchases are made by Gentlemen, or other Persons, for
Friends in the country, which fail to give satisfaction, the money is
invariably returned, excepting where an article is lessened in value,
by being separated from the piece.

HENRY GROVE,
(IMPORTER OF WINES AND SPIRITS,)

VICTORIA COMMERCIAL INN,


NEW MARKET PLACE,
BELMONT ROW,
Birmingham.
(Within Two Minutes’ Walk of both Railway Stations.)

The airy situation of the above Inn, and its proximity to the Grand
Junction and London and Birmingham Railway Companies’ Offices,
render it most eligible for Commercial Gentlemen and others, and
will be found to possess the two important requisites of Comfort and
Economy combined.

Well Aired Beds.


EXCELLENT STABLING,
N.B. OMNIBUSES to and from the principal Coach Offices, where
places may be secured by fast and well regulated Coaches to any
part of the Kingdom.
CHARLES BROOKES,
WOOLLEN DRAPER AND TAILOR,
81, NEW-STREET,
(Nearly opposite the Society of Arts,)
Birmingham.

H. MICHAEL & CO.


MANUFACTURING

FURRIERS AND SKIN MERCHANTS,


115, NEW-STREET,
Corner of King-street, Birmingham.

N.B. Furs of all descriptions Cleaned, Repaired, and Altered to the


present Fashion.

WAGNER & COTTRELL,


MANUFACTURERS OF

PORTABLE WRITING DESKS,


Ladies’ Toilet and Gentlemen’s Dressing Cases, Mahogany,
Rosewood, or Russia Leather Travelling Cases, Medicine Chests,
Copying Machines, and every article in the Cabinet Case Business.
21, PARADISE-STREET,
Birmingham.
By Special Appointment.

T. J. MORRIS,
REPOSITORY OF ARTS,
COLMORE ROW, BIRMINGHAM,
MANUFACTURER OF

Superfine Water Colours in Cakes,


AND

FINE HAIR PENCILS,


In Ordinary to Her Most Gracious Majesty the Queen,
Her Majesty the Queen Dowager,
and the
Duke of Sussex.
LONDON, and 28, Colmore Row, BIRMINGHAM.

Circulating Port Folios, consisting of the choicest Drawings, Flowers


by Holland and Edwards, Pole and Hand Screens, Card Racks, Gold
Papers and Borders, Screen Handles, White Wood-work for Painting,
Ivory and British Boards, and Fancy Stationery.
Papier Machee of every description.
Materials for Chinese Japan Painting, Hollands and Harding’s
Colours, Brookman and Langdon’s, and Banks’ Lead Pencils, Drawing
Materials, Varnishing in a Superior Style, Ivories for Miniatures,
Prepared Canvass and Bladder Colours.
MORDAN’S EVER-POINTED PENCILS AND PEN HOLDERS.

R. SIMS,
(TEN YEARS ASSISTANT TO MR. ENGLISH, COLMORE ROW,)

SURGEON DENTIST,
NO. 13,
UNION PASSAGE, NEW-STREET,
BIRMINGHAM,
Returns his sincere acknowledgments to the Inhabitants of
Birmingham and its vicinity, for the liberal support that has been
conferred upon him since his commencing Practice, and trusts that
his having had Ten Years’ experience with Mr. English, during which
he had nearly the whole of the Mechanical Department entrusted to
his care, will still entitle him to that support and patronage which
has hitherto been awarded to him.
In consequence of some unskilful pretenders having put themselves
forward to public notice as adepts in the above art, he thinks it
necessary to state that he never ties in teeth, which is the most that
these pretenders can ever accomplish; his superior Gold Plates never
in any instance require the painful and most injurious operation of
tying in; and he assures them they will wear more years than the
spurious bone teeth, which they put forth to the public, will last
months, at a less charge, and with greater comfort to the wearer.
FEES.
£ s. d. £ s. d.
A Single Tooth 0 10 0 usually charged 1 1 0
A Complete Set 10 0 0 usually charged 20 0 0

Teeth stopped with Cement or Gold according to the cavity.


Extracting, Scaling, and every other operation upon the Teeth; and
particular attention paid to the regulation of Children’s Teeth upon
equally moderate charges.

TO NOBLEMEN, GENTLEMEN, SPORTSMEN,


AND
GUN-MAKERS.

S. WALKER,
Military Percussion Cap Maker to Her Majesty’s
Honourable Board of Ordnance,
Begs most respectfully to inform her numerous Friends, and the
Public generally, that she has dissolved Partnership with her Son,
and that she will continue to carry on the Percussion Cap Business in
all its Branches.
S. WALKER’S Caps have been known and approved of by the
Sporting World for more than sixteen Years, and she can with
confidence assure them every exertion shall be made, this
seventeenth Season, to render them still superior to any yet
manufactured.
Sold in Boxes of 250 and 500 each, by most of the respectable Gun-
makers and Gunpowder Dealers throughout the Kingdom.
CHEMICALLY PREPARED GUN WADDING,

Manufactured upon an Improved Principle,


BY S. WALKER.
This Wadding will be found superior to any now in use, as it not only
cleans the barrel, every time it is used, but, through the Chemical
Properties of the oily Composition with which it is impregnated, the
lead is removed as quickly as deposited.
Sold in Bags, containing 500 each, price 5s., by all respectable Gun
Makers in the United Kingdom; where also may be had S. Walker’s
Improved Anti-Corrosive Percussion Caps.
MANUFACTORY,
No. 12, Legge-street, Birmingham.
Agents for Edinburgh—J. & R. Raines, Leith-Walk.
Agents for Dublin—J. H. and J. Perry, 27, Pill-lane; and Messrs.
Saunders and Gatchells, Gunpowder Office, 6 and 7, Mountrath-
street, Dublin.

ABRAHAM ALLPORT,
WOOLLEN DRAPER, TAILOR, &c.
2, COLMORE ROW, BIRMINGHAM.

Clothes of every description made in the first style of Fashion on the


most reasonable Terms, and at the shortest Notice.

WILLIAM JACKSON & CO.,


GLASS, LEAD, ZINC, AND OIL MERCHANTS,
MANUFACTURERS OF

COLOURS, VARNISHES, &c.


Sheet Lead, Pig Lead, Lead Pipe, Block Tin, White Lead,
Dry Colours, Oil Paints, Linseed Oil, Boiled Oil,
Tin Pipe, Turpentine, Putty, Sheet Zinc,
Glaziers’ Vices,
MANUFACTURED ZINC GOODS,
Beer Machines, Water Closets, Lift Pumps, Brass Cocks, and every
Description of Plumbers’ Brass Work.
WAREHOUSE, NO. 1, LITTLE CHARLES-STREET, BIRMINGHAM.

VARNISH, COLOUR, AND ZINC WORKS, AT ASHTED.

N.B. Sole Agents for the Whiston Copper Company. (Messrs. Sneyd,
Kinnersley & Co.)

HATS.
75, HIGH-STREET.
GOOD
FASHIONABLE GOSSAMERS
At 4s. 9d. to 10s.;
SUPERFINE SHORT-NAP STUFFS,
Best that can be made, 21s.;
TO BE HAD AT
WALKER’S
CHEAP HAT DEPÔT.
Also a large assortment of Fashionable CAPS and GRASS HATS for
Summer wear.

JAMES GRUNDY,
MANUFACTURER OF

GAS & OIL LAMPS, CHANDELIERS, &c.


IN BRONZE & OR-MOLU.
GAS FITTINGS OF EVERY DESCRIPTION.
No. 11, BARTHOLOMEW-STREET,
BIRMINGHAM.

JOHN GODFREY,
WORKING OPTICIAN, SILVERSMITH. &c.
NO. 93, COLESHILL-STREET,

Begs most respectfully to announce to the Nobility, Gentry, and


Inhabitants of Birmingham and its Vicinity, that he has, in addition to
his Wholesale Establishment, opened a Retail Shop as above, for the
purpose of supplying those who may in any way suffer from a defect
of sight, with spectacles suited to their various wants. Having been
practically engaged in the above business for more than forty years,
he trusts that his great experience will enable him to render all the
assistance required, so far as glasses, judiciously applied, are
capable of affording it.
Spectacles with shades of every description, particularly
recommended to persons travelling, or those who are affected with a
weakness in the eye, as they completely defend that tender organ
from the bright glare of the sun, and are extremely useful either in
windy or snowy weather.
Spectacles in tortoiseshell, silver, or blued steel mountings, set with
either best Brazilian pebbles, or glasses accurately ground.
Optical Instruments of every Description.
Spectacles of every description expeditiously and neatly repaired.
Pebbles or Glasses set in a few minutes.
Every Article supplied on Moderate Terms.
J. G. hopes that the quality of the various articles supplied by him,
will, upon a fair trial, ensure him the patronage and support of those
who may honour him with their commands.

CAPTAIN HOSKINS,
IMPORTER OF

FOREIGN WINES AND SPIRITS,


LOWER TEMPLE-STREET,
(Corner of New-street,)
BIRMINGHAM.
IMPORTER OF LIQUEURS.

TEETH.

MR. E. JONES,
DENTIST,
NO. 9, EASY ROW, BIRMINGHAM,
Six Years Assistant with Mr. Andrew Clark, of Brook-street,
Bond-street, London,
Begs to say he will continue to supply ARTIFICIAL TEETH upon the
same principle as Mr. A. Clark, and the only one that will ensure
ease, articulation, and mastication.
E. G., having undertaken several cases that had been refused by
other Dentists as impracticable, can give the most satisfactory
References as to the beneficial results of his Practice.
EVERY OPERATION IN
DENTAL SURGERY,
Performed on the most moderate Terms.

PERMANENT ELASTIC SPRING HYGEIAN BEDS,


CARRIAGE, GIG, SOFA, AND CHAIR SEATS,

Patronised by Her Royal Highness the Duchess of Kent.

RICHARD FARMER,
Manufacturer,
With the greatest deference submits to the attention of his Friends
and the Public the subjoined Documents, as flattering Testimonies of
the high estimation in which the above very superior and much
approved Articles are held:—
From Sir John Conroy, Secretary to Her Royal Highness
The Duchess of Kent.
“Sir John Conroy is honoured with the Duchess of Kent’s
command to acquaint Mr. Farmer, that he has permission to use
Her Royal Highness’s Name and Arms, as Manufacturer of
Permanent Elastic Spring Hygeian Beds to Her Royal Highness.
“Malvern, Sept. 13, 1830.”
“Sir John Conroy is to acknowledge the receipt of the Bed and
Mattress of Mr. R. Farmer’s invention, which he has made for the
Princess Victoria; and Sir John is commanded by the Duchess of
Kent to express Her Royal Highness’s highest approval of the
principle of his Mattresses, Cushions, &c.
“Kensington Palace, Dec. 17, 1830.
“Mr. Richard Farmer, &c. &c.”

From Congreve Selwyn, Esq. Surgeon of the Ledbury Dispensary.

“Mr. Congreve Selwyn, Surgeon of the Ledbury Dispensary, begs


to offer his Testimony of the value of Mr. Farmer’s invention of
his Elastic Mattresses and Cushions. The one he has sent to Mr.
Selwyn answers all the purposes for an Invalid, and is
particularly serviceable where the patient suffers from hectic
fever and night perspirations.
“Ledbury, May 2, 1834.
“Mr. Richard Farmer, &c. &c.”

From Sir William B. Cave, Bart.

“Stretton, Atherstone, July 22, 1835.


“Sir Wm. B. Cave has much satisfaction in informing Mr. Richard
Farmer, that the Elastic Steel Spring Bed which he purchased
from Mr. F. has fully answered every expectation he had formed
of it. Sir. W. C. lay upon it for five months without ever being
able to be moved in the least from it, and for the last six
months has not been removed from it for more than two hours
at a time, and it is now as perfect in the elasticity and strength
of the springs as when he received it from Mr. Farmer. Sir W.
Cave’s weight is sixteen stone and upwards. Dr. Palmer, of
Birmingham, who has been in the habit of attending Sir W. Cave
for many years, gave it as his opinion, that had he been lying on
a bed of any other description, the consequences would have
been very serious.
“Mr. Richard Farmer, &c. &c.”
Carpets, Paper Hangings, Oil-Cloths, Druggets, Crumb Cloths,
Double-stoved Feathers, &c. &c.—Upholstery and General Cabinet
Business.
→ 11, New-Street, (opposite the Hen & Chickens Hotel,) and 30, Bath
Row, Birmingham.

GEORGE RICHMOND COLLIS,


Late Sir Edward Thomason’s Manufactory,
CHURCH-STREET, BIRMINGHAM.
Manufacturer of Articles in the highest classes of the Arts, in Gold,
Silver, Plated, Bronze, and Or-Molu. In this Establishment is
manufactured Gold and Silver Plate, including Racing Cups, Dinner
and Tea Services, of various Patterns: Communion Plate and
Presentation Plate, made to descriptions given, or if required, a
variety of elegant Designs furnished for approval: Silver-mounted
Plated Wares of every denomination; Plated Cutlery upon Steel: Cut
Glass, Or-Molu, Candelabra and Lamps: Manufacturer of Medals in
great variety adapted for Societies and Institutions. Amongst the
numerous series of Dies are the celebrated Dassier Dies of the Kings
of England: The Mudie Dies for the series of grand National Medals,
commemorative of the Victories of the late War: Forty-eight Dies for
Medals of the Elgin Marbles. Also Sir Edward Thomason’s Splendid
Series of One Hundred and Twenty large Medal Dies Illustrative of
the Holy Scriptures, and a series of sixteen Medals upon Science and
Philosophy, for Societies: Livery Button Dies cut, and the Buttons
made. Numerous Patent Mechanical Inventions in the Metals, and
Papier Machee: Brass and Bronze Staircases: manufacturer of fine
Gold Jewellery of the most splendid descriptions: Dealer in
Diamonds, Pearls, and fine Gems: Diamond Suits made to order, and
altered to the present Style, or if required, purchased, and payment,
full value, in cash: English and Foreign Money exchanged; Old Gold
and Silver Articles reworked as new, or purchased. Manufacturer of
Sportsmen’s fine Fowling Pieces upon an improved principle. Duelling
Pistols, Rifles, Air Guns and Canes, and Guns of every variety for
Exportation.
These extensive Show Rooms and Manufactory, are situate in Church-
Street, in the centre of the Town, adjoining St. Philip’s Church Yard.
The Ware Rooms contain the Finished Articles for sale, and are open
to all persons of respectability.
The Fac-simile of the celebrated Warwick Vase, of upwards of 21 feet
in circumference, was made in metallic Bronze at this Manufactory.
The Copper Bronze Statue of His Late Majesty, George the Fourth,
upwards of 6 feet in height, was modelled, cast, and sculptured at
this Establishment: as also a Shield in honour of the Duke of
Wellington’s Victories. These and numerous other Works are
stationed in separate Rooms to exhibit the progress of British Art.
Servants are appointed to conduct Visiters over the different
Workshops, to whom and to the Work-people the Visiter is requested
to abstain from giving any gratuity.
N.B. Mr. George Richmond Collis is Vice Consul for France, Russia,
Spain, Portugal, and Turkey, with the privilege of granting Passports
to Persons visiting France and its Dominions.
Strangers of Respectability are permitted to view the Show Rooms
and Manufactory.

THOMAS & JAMES UPFILL,


IRON AND STEEL MERCHANTS,
157, GREAT CHARLES-STREET,
BIRMINGHAM.

MANUFACTURERS OF

WROUGHT AND CAST IRON


GATES, PARK FENCING,
HURDLES,
INVISIBLE WIRE FENCE, HAIR FENCE,
RACKS, MANGERS, CHAINS,
NAILS, BOOK CASES, TIN, IRON
ARMS, &c.

THORNTON AND SON,


WHOLESALE IRONMONGERS,
MANUFACTURERS OF

WROUGHT IRON AND PRESSED RIVETED


HINGES,
CUT NAILS,
Wood, Bed, and Machinery Screws, of every description; Iron Rim
and Mortice Locks, Sash Pulleys, Iron Bolts, Cast Butt Hinges,
Norfolk and Thumb Latches, &c. &c.
BRADFORD-STREET, BIRMINGHAM.

→ Redman’s Patent Rising Joint and Swing Hinges, Trough and


Centre Hinges of every kind.
F. KNIBB’S
COMMERCIAL
BOARDING ESTABLISHMENT,
15, BOLD-STREET,
(Two Doors above the Palatine Club House,)
LIVERPOOL.
The situation is central, and without exception the pleasantest of any
establishment of the kind in Liverpool. The rooms are large and airy,
and no attention will be spared to render this establishment
deserving the patronage of Commercial Gentlemen and Families.

W. FLETCHER,
MANUFACTURER OF

LAMPS, CANDLESTICKS,
LUSTRES, INKSTANDS, VASES,
And all kinds of Ornaments in Bronze and Or-molu,
31,
LOVEDAY-STREET, BIRMINGHAM.

Manufacturer of Japanned Wood and Papier Maché Cruet, Liquor,


and Pickle Frames; Papier Maché and Metallic Miniature Frames, &c.
Agent in London—C. JEPSON, 29, Thavies Inn, Lower Holborn.
NOW READY, PART I.
(To be completed in two Parts, demy 12mo., price 17s.)
THE
LAW AND PRACTICE
RELATING TO
LANDLORDS AND TENANTS:
COMPRISING

The most approved modern Precedents, alphabetically arranged


under distinct and separate heads, with Notes, Illustrations, and
Cases; to which is prefixed a concise Treatise on the nature of
Estates in general, in accordance with the recent statutes relating to
real property. The whole adapted for the use of attorneys and
solicitors; also landlords, tenants, farmers, stewards, agents, and
others concerned in the management, sale, or letting of estates. BY
R. SHIPMAN, Esq., Editor of “Jones’s Attorney’s Pocket Book,” and
Author of the “Attorney’s New Pocket Book, Notary’s Manual, and
Conveyancer’s Assistant.”
London: S. Sweet, 3, Chancery Lane; and J. Drake, 52, New-street,
Birmingham.

Also Ready, royal 12mo, price 7s.


A STEPPING STONE
TO THE
LAW OF REAL PROPERTY:
BEING AN
Elementary Treatise on the Statute of Uses.
By HENRY SMYTHIES.
London: S. Sweet, 3, Chancery Lane; and J. Drake, 52, New-street,
Birmingham.
SHORTLY WILL BE PUBLISHED, BY J. DRAKE,
And sold by the Agents for this Work, and all Booksellers,
Dedicated by Permission to the Chairman and Directors of the
London and
Birmingham Railway,
DRAKE’S ROAD BOOK,
OF THE
LONDON AND BIRMINGHAM RAILWAY,
With Views on the Line, from Drawings by Henry Harris; and a new
and beautifully engraved coloured Map of the entire Route, extending
many miles on each side of the line.
* *
* To be completed in about five Parts, at 1s. per Part; a few copies
on India Paper at 1s. 6d. per Part.

JUST PUBLISHED,
DRAKE’S
RAILROAD MAPS
OF THE ENTIRE LINE OF ROUTE
FROM
LONDON TO LIVERPOOL AND
MANCHESTER,
BEAUTIFULLY ENGRAVED AND COLOURED,
AND EXTENDING MANY MILES ON EACH SIDE OF THE LINE:

Ornamented with views of the Euston Grove Station, in London, and


a complete Train of Carriages. With the Rules, Regulations, Fares,
Times of Outset and Arrival of the Trains at the various Stations;
together with all requisite Information for Travellers.
Price, on Canvass, in a Case for the Pocket, 2s.
* *
* The Maps of the London and Birmingham and Grand Junction
Railways sold separately, done up in a similar manner, at 1s. 6d.
each. On a sheet, Coloured, 9d.—Plain, 6d. each.

“Mr. Drake, of New-street, has just published in a neat pocket


case, two well-engraved and coloured Maps of the London and
Birmingham and Grand Junction Railways. Each Map describes
not only the course of the line and a section of its gradients, but
the geographical position of various places for many miles on
either side. There are also annexed complete tables of fares
and distances, the rules to be observed by travellers, the modes
of conveyance to and from the hotels and inns to the stations
on the line, with the regulations for luggage, merchandise, &c.
These maps and accompanying tables comprise much
information in a small compass, which the railway traveller will
have frequent opportunities, on his journey, of making a
practical use of, and turning to good account.”—Midland
Counties’ Herald.
“Mr. Drake has just published Maps of the Grand Junction and of
the London and Birmingham Railways, together with tables of
distances, fares, and regulations. The Maps are done up in a
case for the pocket, and will be found very portable as well as
instructive.”—Birmingham Journal.

PRINTING OFFICE,
LAW STATIONERY, ACCOUNT BOOK,
AND PAPER WAREHOUSE,
52,
NEW-STREET, (OPPOSITE THE THEATRE,)
BIRMINGHAM.
JAMES DRAKE,
LAW BOOKSELLER, STATIONER, AND BINDER,
Takes this opportunity of presenting his grateful acknowledgments to
the Profession for their liberal support of his Establishment, and at
the same time he begs to assure them, that every article sold by him
will be found of superior quality and at reasonable prices, and will,
he hopes, induce a continuance of their esteemed favours.
J. D. takes this opportunity of calling the attention of the Profession
to his Law Stationery Business, established more than twenty years,
and which is conducted by himself and competent assistants.

DEEDS AND WRITINGS

Neatly and carefully Engrossed and Copied.


DRAFTS DRAWN, AND TITLES CAREFULLY ABSTRACTED,

(FOR THE PROFESSION ONLY).

Books Plainly and Elegantly Bound by Experienced


Workmen.
LAW BOOKS,
All the New Works kept in stock, or ordered on the shortest Notice,
on the same terms of DISCOUNT as in London.
LAW REPORTS SUPPLIED.
BANKRUPTCY & OTHER FORMS,
WRITS, NOTICES,
Forms under the new Act for the abolishing Imprisonment for
Debt; also for Justices of the Peace, Highway Act Forms,
Election Forms, &c., kept in Stock.
*** Orders from the Country executed with promptness.
Birmingham: Printed by James Drake, 52, New-street.
*** END OF THE PROJECT GUTENBERG EBOOK DRAKE'S ROAD
BOOK OF THE GRAND JUNCTION RAILWAY ***

Updated editions will replace the previous one—the old editions


will be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States
copyright in these works, so the Foundation (and you!) can copy
and distribute it in the United States without permission and
without paying copyright royalties. Special rules, set forth in the
General Terms of Use part of this license, apply to copying and
distributing Project Gutenberg™ electronic works to protect the
PROJECT GUTENBERG™ concept and trademark. Project
Gutenberg is a registered trademark, and may not be used if
you charge for an eBook, except by following the terms of the
trademark license, including paying royalties for use of the
Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such
as creation of derivative works, reports, performances and
research. Project Gutenberg eBooks may be modified and
printed and given away—you may do practically ANYTHING in
the United States with eBooks not protected by U.S. copyright
law. Redistribution is subject to the trademark license, especially
commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the


free distribution of electronic works, by using or distributing this
work (or any other work associated in any way with the phrase
“Project Gutenberg”), you agree to comply with all the terms of
the Full Project Gutenberg™ License available with this file or
online at www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand,
agree to and accept all the terms of this license and intellectual
property (trademark/copyright) agreement. If you do not agree
to abide by all the terms of this agreement, you must cease
using and return or destroy all copies of Project Gutenberg™
electronic works in your possession. If you paid a fee for
obtaining a copy of or access to a Project Gutenberg™
electronic work and you do not agree to be bound by the terms
of this agreement, you may obtain a refund from the person or
entity to whom you paid the fee as set forth in paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only


be used on or associated in any way with an electronic work by
people who agree to be bound by the terms of this agreement.
There are a few things that you can do with most Project
Gutenberg™ electronic works even without complying with the
full terms of this agreement. See paragraph 1.C below. There
are a lot of things you can do with Project Gutenberg™
electronic works if you follow the terms of this agreement and
help preserve free future access to Project Gutenberg™
electronic works. See paragraph 1.E below.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like