0% found this document useful (0 votes)
172 views57 pages

Examples in Nancy by Christian Horsdal Gammelgaard ISBN 9781617293375, 1617293377install Download

Uploaded by

tevsjwsi2995
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
172 views57 pages

Examples in Nancy by Christian Horsdal Gammelgaard ISBN 9781617293375, 1617293377install Download

Uploaded by

tevsjwsi2995
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

(Ebook) Microservices in .

NET Core, with


Examples in Nancy by Christian Horsdal
Gammelgaard ISBN 9781617293375,
1617293377install download

https://ebooknice.com/product/microservices-in-net-core-with-
examples-in-nancy-7302638

Download more ebook instantly today at https://ebooknice.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

(Ebook) Microservices in .NET Core - Second Edition (MEAP V04) by Christian Horsdal
Gammelgaard ISBN 9781617297922, 1617297925

https://ebooknice.com/product/microservices-in-net-core-second-edition-
meap-v04-27587822

ebooknice.com

(Ebook) Microservices in .NET, Second Edition by Christian Horsdal Gammelgaard ISBN


9781617297922, 1617297925

https://ebooknice.com/product/microservices-in-net-second-edition-35162766

ebooknice.com

(Ebook) Building Microservices with .NET Core 2.0: Transitioning Monolithic


Architectures Using Microservices with .NET Core 2.0 Using C# 7.0 by Gaurav Aroraa
ISBN 9781788399968, 178839996X

https://ebooknice.com/product/building-microservices-with-net-
core-2-0-transitioning-monolithic-architectures-using-microservices-with-net-
core-2-0-using-c-7-0-11639002

ebooknice.com

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James ISBN
9781459699816, 9781743365571, 9781925268492, 1459699815, 1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

ebooknice.com
(Ebook) Pro Microservices in .NET 6: With Examples Using ASP.NET Core 6,
MassTransit, and Kubernetes by Sean Whitesell, Rob Richardson, Matthew D. Groves
ISBN 9781484278321, 1484278321

https://ebooknice.com/product/pro-microservices-in-net-6-with-examples-using-
asp-net-core-6-masstransit-and-kubernetes-37258796

ebooknice.com

(Ebook) Pro Microservices in .NET 6: With Examples Using ASP.NET Core 6,


MassTransit, and Kubernetes by Sean Whitesell; Rob Richardson; Matthew D. Groves
ISBN 9781484278321, 9781484278338, 1484278321, 148427833X

https://ebooknice.com/product/pro-microservices-in-net-6-with-examples-using-
asp-net-core-6-masstransit-and-kubernetes-42449494

ebooknice.com

(Ebook) Building Microservices with .NET Core by Soumya Mukherjee ISBN


9781785887833, 1785887831

https://ebooknice.com/product/building-microservices-with-net-core-53645824

ebooknice.com

(Ebook) Building Microservices with .NET Core 2.0 - Second Edition by Gaurav Aroraa
ISBN 9781788393331, 1788393333

https://ebooknice.com/product/building-microservices-with-net-core-2-0-second-
edition-10807626

ebooknice.com

(Ebook) Microservices Patterns: With examples in Java by Chris Richardson ISBN


9781617294549, 1617294543

https://ebooknice.com/product/microservices-patterns-with-examples-in-
java-27417148

ebooknice.com
with examples in Nancy

Christian Horsdal Gammelgaard

MANNING

www.allitebooks.com
What is a microservice?
In short, a microservice is a very narrowly focused service
that has the following characteristics:
 A microservice is responsible for a single piece of func-
tionality.
 A microservice is individually deployable.
 A microservice consists of one or more processes.
 A microservice owns its own data store.
 A small team can maintain a handful of microservices.
 A microservice is replaceable.
You can use these characteristics in two ways: to guide the
design and implementation of microservices, and to recog-
nize microservices when you see them.

www.allitebooks.com
Microservices in .NET Core

www.allitebooks.com
www.allitebooks.com
Microservices in .NET Core
WITH EXAMPLES IN NANCY

CHRISTIAN HORSDAL GAMMELGAARD

MANNING
SHELTER ISLAND

www.allitebooks.com
For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964
Email: orders@manning.com

©2017 by Manning Publications Co. All rights reserved.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in


any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.

Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books are
printed on paper that is at least 15 percent recycled and processed without the use of elemental
chlorine.

Manning Publications Co. Development editor: Dan Maharry


20 Baldwin Road Technical Development Editor: Michael Lund
PO Box 761 Project editors: Tiffany Taylor
Shelter Island, NY 11964 and Janet Vail
Copyeditor: Tiffany Taylor
Proofreaders: Katie Tennant
and Melody Dolab
Technical proofreader: Karsten Strøbaek
Typesetter: Gordan Salinovic
Cover designer: Marija Tudor

ISBN 9781617293375
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – EBM – 22 21 20 19 18 17
brief contents
PART 1 GETTING STARTED WITH MICROSERVICES .......................1
1 ■ Microservices at a glance 3
2 ■ A basic shopping cart microservice 30

PART 2 BUILDING MICROSERVICES ...........................................55


3 ■ Identifying and scoping microservices 57
4 ■ Microservice collaboration 79
5 ■ Data ownership and data storage 109
6 ■ Designing for robustness 134
7 ■ Writing tests for microservices 155

PART 3 HANDLING CROSS-CUTTING CONCERNS: BUILDING


A REUSABLE MICROSERVICE PLATFORM ......................183
8 ■ Introducing OWIN: writing and testing OWIN
middleware 185
9 ■ Cross-cutting concerns: monitoring and logging 199

v
vi BRIEF CONTENTS

10 ■ Securing microservice-to-microservice
communication 223
11 ■ Building a reusable microservice platform 248

PART 4 BUILDING APPLICATIONS ...........................................271


12 ■ Creating applications over microservices 273
contents
preface xiii
acknowledgments xiv
about this book xv
about the cover illustration xix

PART 1 GETTING STARTED WITH MICROSERVICES ..............1

1 Microservices at a glance 3
1.1 What is a microservice? 3
What is a microservices architecture? 5 ■
Microservice characteristics 5
1.2 Why microservices? 10
Enabling continuous delivery 11 High level of

maintainability 12 Robust and scalable 13


1.3 Costs and downsides of microservices 13


1.4 Greenfield vs. brownfield 14
1.5 Code reuse 15
1.6 Serving a user request: an example of how microservices work
in concert 16
Main handling of the user request 17 Side effects of the user

request 18 The complete picture 19


vii
viii CONTENTS

1.7 A .NET microservices technology stack 20


Nancy 20 OWIN ■
21 ■
Setting up a development
environment 22
1.8 A simple microservices example 23
Creating an empty ASP.NET Core application 24 Adding ■

Nancy to the project 24 Adding a Nancy module with an


implementation of the endpoint 25 Adding OWIN ■

middleware 27
1.9 Summary 28

2 A basic shopping cart microservice 30


2.1 Overview of the Shopping Cart microservice 31
Components of the Shopping Cart microservice 33
2.2 Implementing the Shopping Cart microservice 34
Creating an empty project 34 The Shopping Cart microservice’s

API for other services 35 Fetching product information 42


Parsing the product response 44 Adding a failure-handling


policy 46 Implementing a basic event feed 48


2.3 Running the code 52


2.4 Summary 52

PART 2 BUILDING MICROSERVICES ..................................55

3 Identifying and scoping microservices 57


3.1 The primary driver for scoping microservices:
business capabilities 58
What is a business capability? 58 Identifying business

capabilities 59 Example: point-of-sale system 60


3.2 The secondary driver for scoping microservices: supporting


technical capabilities 65
What is a technical capability? 65 Examples of supporting

technical capabilities 65 Identifying technical capabilities 69


3.3 What to do when the correct scope isn’t clear 69


Starting a bit bigger 70 Carving out new microservices from

existing microservices 73 Planning to carve out new


microservices later 75
Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
CONTENTS ix

3.4 Well-scoped microservices adhere to the microservice


characteristics 75
Primarily scoping to business capabilities leads to good
microservices 76 Secondarily scoping to supporting technical

capabilities leads to good microservices 76


3.5 Summary 77

4 Microservice collaboration 79
4.1 Types of collaboration: commands, queries, and events 80
Commands and queries: synchronous collaboration 82 ■
Events:
asynchronous collaboration 85 Data formats 87 ■

4.2 Implementing collaboration 88


Setting up a project for Loyalty Program 89 Implementing ■

commands and queries 91 Implementing commands with HTTP


POST or PUT 91 Implementing queries with HTTP GET 95


Data formats 96 Implementing an event-based collaboration 98


4.3 Summary 107

5 Data ownership and data storage 109


5.1 Each microservice has a data store 110
5.2 Partitioning data between microservices 110
Rule 1: Ownership of data follows business capabilities 110 ■
Rule
2: Replicate for speed and robustness 113 Where does a ■

microservice store its data? 116


5.3 Implementing data storage in a microservice 118
Storing data owned by a microservice 119 Storing events raised■

by a microservice 122 Setting cache headers in Nancy


responses 129 Reading and using cache headers 130


5.4 Summary 132

6 Designing for robustness 134


6.1 Expect failures 135
Keeping good logs 136 Using correlation tokens 138 Rolling
■ ■

forward vs. rolling back 138 Don’t propagate failures 139


6.2 The client side’s responsibility for robustness 140


Robustness pattern: retry 142 ■
Robustness pattern: circuit
breaker 144
x CONTENTS

6.3 Implementing robustness patterns 146


Implementing a fast-paced retry strategy with Polly 148 Implementing ■

a circuit breaker with Polly 149 Implementing a slow-paced retry


strategy 150 Logging all unhandled exceptions 153


6.4 Summary 154

7 Writing tests for microservices 155


7.1 What and how to test 156
The test pyramid: what to test in a microservices system 156
System-level tests: testing a complete microservice system end-to-
end 157 Service-level tests: testing a microservice from outside its

process 158 Unit-level tests: testing endpoints from within the


process 161
7.2 Testing libraries: Nancy.Testing and xUnit 162
Meet Nancy.Testing 162 Meet xUnit 163

xUnit and Nancy.Testing working together 163


7.3 Writing unit tests using Nancy.Testing 164
Setting up a unit-test project 165 Using the Browser object to

unit-test endpoints 167 Using a configurable bootstrapper to


inject mocks into endpoints 170


7.4 Writing service-level tests 173
Creating a service-level test project 175 Creating mocked

endpoints 175 Starting all the processes of the microservice under


test 177 Executing the test scenario against the microservice


under test 179


7.5 Summary 180

PART 3 HANDLING CROSS-CUTTING CONCERNS: BUILDING


A REUSABLE MICROSERVICE PLATFORM ..............183

8 Introducing OWIN: writing and testing OWIN middleware 185


8.1 Handling cross-cutting concerns 186
8.2 The OWIN pipeline 188
What belongs in OWIN, and what belongs in Nancy? 191
8.3 Writing middleware 192
Middleware as lambdas 193 ■
Middleware classes 194
8.4 Testing middleware and pipelines 195
8.5 Summary 198
CONTENTS xi

9 Cross-cutting concerns: monitoring and logging 199


9.1 Monitoring needs in microservices 200
9.2 Logging needs in microservices 203
Structured logging with Serilog 205
9.3 Implementing the monitoring middleware 206
Implementing the shallow monitoring endpoint 207 Implementing ■

the deep monitoring endpoint 208 Adding the monitoring


middleware to the OWIN pipeline 210


9.4 Implementing the logging middleware 212
Adding correlation tokens to all log messages 214 Adding a ■

correlation token to all outgoing HTTP requests 215 Logging ■

requests and request performance 219 Configuring an OWIN


pipeline with a correlation token and logging middleware 220


9.5 Summary 222

10 Securing microservice-to-microservice communication 223


10.1 Microservice security concerns 224
Authenticating users at the edge 225 Authorizing users in

microservices 226 How much should microservices trust each


other? 227
10.2 Implementing secure microservice-to-microservice
communication 229
Meet IdentityServer 231 Implementing authentication with

IdentityServer middleware 237 Implementing microservice-to-


microservice authorization with IdentityServer and middleware 239


Implementing user authorization in Nancy modules 242
10.3 Summary 246

11 Building a reusable microservice platform


11.1 Creating a new microservice should be quick and easy
248
249
11.2 Creating a reusable microservice platform 249
11.3 Packaging and sharing middleware with NuGet 251
Creating a package with logging and monitoring middleware 252
Creating a package with authorization middleware 259
Creating a package with rest client factory 262 Automatically

registering an HTTP client factory in Nancy’s container 265


Using the microservice platform 267
11.4 Summary 270
xii CONTENTS

PART 4 BUILDING APPLICATIONS ..................................271

12 Creating applications over microservices 273


12.1 End user applications for microservice systems: one or many
applications? 274
General-purpose applications 274 ■
Specialized
applications 275
12.2 Patterns for building applications over microservices 276
Composite applications: integrating at the frontend 276 API■

gateway 279 Backend for frontend (BFF) pattern 281 When


■ ■

to use each pattern 282 Client-side or server-side


rendering? 283
12.3 Example: a shopping cart and product list 284
Creating an API gateway 287 Creating the product list

GUI 289 Creating the shopping cart GUI 294 Letting users
■ ■

add products to the shopping cart 297 Letting users remove


products from the shopping cart 299


12.4 Summary 300
appendix A Development environment setup 303
appendix B Deploying to production 308
Further reading 312
index 315
preface
When I first talked to Manning about writing a book, we discussed a book about Nancy.
Part of me was excited to write about Nancy again, because it’s an awesome web frame-
work, but my first book was about Nancy, and a different part of me wanted this book
to be something more. I felt that Nancy deserves not only to be explained and shown
off, but also to be put into a context that shows why Nancy is such a nice web framework
to work with. For me, the thing that makes Nancy so nice is that it’s so easy to work with.
It’s a framework that gets out of your way and lets you just write the stuff that you set out
to write. At the same time, it’s a powerful framework that grows along with your needs.
After some contemplation and some back-and-forth with Manning, it became clear that
the context I wanted to put Nancy into was microservices. Microservices allow for the
lightweight, fast way of working that I’ve come to appreciate over the years. They also
accentuate the need for lightweight, yet powerful technologies—just like Nancy. At this
point, the different ideas for what this book should be started to fall into place: I wanted
to write a book that was more about designing and implementing microservices than
about any specific technology, while at the same time showcasing some great, light-
weight .NET technologies. That’s the book you’re about to read, and I hope that you’ll
not only learn how to be successful with microservices, but also learn the value of care-
fully choosing libraries and frameworks that value simplicity, that get out of your way,
and that are a pleasure to work with.

xiii
acknowledgments
Writing a book takes time—a lot of time. So the first thank you is to my wife, Jane
Horsdal Gammelgaard, for supporting me all the way through. You’re awesome, Jane.
I would like to thank my editor, Dan Maharry, who, through great suggestions, gen-
tle nudges, the occasional shove, and a relentless focus on creating a high-quality
product, pushed me to write a much better book than I would have otherwise. A big
thank you also goes to my technical editor, Michael Lund, for his thorough code
reviews and suggestions for improvements, and for ripping my line of reasoning apart
whenever it wasn’t clear. A special thanks to Karsten Strøbæk for his in-depth techni-
cal proofreading.
I can’t thank enough the amazing group of technical peer reviewers: Andy Kirsch,
Brian Rasmussen, Cemre Mengu, Guy Matthew LaCrosse, James McGinn, Jeff Smith,
Jim McGinn, Matt R. Cole, Morten Herman Langkjær, Nestor Narvaez, Nick McGin-
ness, Ronnie Hegelund, Samuel Bosch, and Shahid Iqbal. They suggested topics and
other ways of presenting topics and caught typos and mistakes in code and terminol-
ogy. Each pass through the review process and each piece of feedback provided
through the forum discussions helped shape the book.
Finally, I want to thank the people at Manning who made this book possible: pub-
lisher Marjan Bace, acquisitions editor Greg Wild, and everyone on the editorial and
production teams, including Tiffany Taylor, Katie Tennant, Melody Dolab, and Gor-
dan Salinovic.

xiv
about this book
Microservices in .NET Core is a practical introduction to writing microservices in .NET
using lightweight and easy-to-use technologies, like the awesome Nancy web frame-
work and the powerful OWIN (Open Web Interface for .NET) middleware. I’ve tried
to present the material in a way that will enable you to use what you learn right away.
To that end, I’ve tried to tell you why I build things the way I do, as well as show you
exactly how to build them.
The Nancy web framework, used throughout this book, was started by Andreas
Håkansson, who still leads the project. Andreas was soon joined by Steven Robbins,
and the two of them made Nancy great. Today Nancy is carried forward by Andreas,
Steven, the Nancy Minions (Kristian Hellang, Jonathan Channon, Damian Hickey,
Phillip Haydon, and myself), and the broader community. The full list of Nancy con-
tributors can be found at http://nancyfx.org/contribs.html.
OWIN is an open standard for the interface between web servers and web applica-
tions. The work on OWIN was started in late 2010 by Ryan Riley, Benjamin van der
Veen, Mauricio Scheffer, and Scott Koon. Since then, a broad community has contrib-
uted to the OWIN standard specification—through a Google group in the early days,
and now through the OWIN GitHub repository (https://github.com/owin/owin)—
and to implementing OWIN.

Who should read this book


Microservices in .NET Core is a developers’ book first, but architects and others can ben-
efit from it, too. I wrote it keeping in mind .NET developers who want to get started

xv
xvi ABOUT THIS BOOK

writing distributed server-side systems in general and microservices in particular,


which means that the focus is on what a developer needs to know and do to write the
code for a system of microservices. Working knowledge of C# and a bit of HTTP knowl-
edge is assumed.

How this book is organized


Microservices in .NET Core has 12 chapters spread across four parts:
Part 1 gives a quick introduction to microservices, answering what they are and why
they’re interesting. This part also introduces Nancy and OWIN, the main technologies
used throughout the book.

Chapter 1 introduces microservices—what they are and why they matter. It
introduces the six characteristics of microservices that I use to guide the design
and implementation of microservices. At the end of the chapter, we say hello to
Nancy and OWIN.

Chapter 2 is a comprehensive example of coding a microservice using Nancy
and OWIN, along with the Polly library and .NET Core. At the end of the chap-
ter, we have a complete, albeit simple, microservice.
Part 2 covers how to split a system into microservices and how to implement function-
ality in a system of microservices.

Chapter 3 covers how to identify microservices and decide what to put into each
microservice. This chapter is about the design of a system of microservices as a
whole.

Chapter 4 shows how to design and implement the collaboration between
microservices. This chapter discusses the different ways microservices can col-
laborate and shows how to implement those collaborations.

Chapter 5 discusses where data should be stored in a system of microservices
and how some of the data may be replicated across several microservices.

Chapter 6 explains and demonstrates the implementation of some important
techniques for making microservice systems robust.

Chapter 7 takes a thorough look at testing a microservice system, including test-
ing the complete system, testing each microservice, and testing the code inside
the microservices.
Part 3 shows how to speed up development of new microservices by building a solid
microservice platform tailored to the needs of your particular system. Such a platform
provides implementations of a bunch of important concerns that cut across the entire
system of microservices, such as logging, monitoring, and security. In this part you’ll
build such a platform and see how it’s used to create new microservices quickly.

Chapter 8 gives an in-depth introduction to OWIN, walks through building
OWIN middleware, and shows how OWIN middleware is well suited for han-
dling many crosscutting concerns.
ABOUT THIS BOOK xvii


Chapter 9 explains the importance of monitoring and logging in a microservice
system. Building on the OWIN knowledge from chapter 8, you’ll build OWIN
middleware implementing monitoring support and middleware that aids good
logging from your microservices.

Chapter 10 discusses security in a microservice system. The highly distributed
nature of a microservice system poses some security concerns that we discuss in
this chapter. I’ll also walk you through using OWIN middleware to implement
security features in your microservices.

Chapter 11 builds on top of chapters 9 and 10 to create a microservice plat-
form. The platform is built by taking the OWIN middleware from the previous
chapters and packaging it in NuGet packages ready to be shared across micros-
ervices. The chapter includes an example of creating a new microservice using
the platform.
Part 4 consists of chapter 12, which rounds off the book with some approaches to cre-
ating end-user applications for a microservices system. The chapter also shows how to
build a small application on top of some of the microservices from earlier chapters.
Together, the 12 chapters will teach you how to design and code microservices
using a lightweight, no-nonsense, .NET-based technology stack.

Code conventions and downloads


Most chapters in this book have sample code. All of this can be found in the download
for this book on Manning’s site at https://www.manning.com/books/microservices-
in-net-core, or in the Git repository on GitHub found at https://github.com/hors-
dal/microservices-in-dotnetcore.
The code is based on .NET Core, so to run it, you need to install .NET Core,
the dotnet command-line tool, and a suitable IDE. You can find information on how
to set these up in appendix A.
Throughout the book, I use a number of third-party open source libraries, particu-
larly the Nancy web framework. .NET Core is a big shift from “traditional” .NET, so
existing libraries need to be ported and thoroughly tested before they can claim full
.NET Core support. At the time of writing .NET Core has just reached the 1.0.0 release,
so not all libraries have been tested on .NET Core. For this reason, the book uses pre-
release versions of libraries—Nancy, for instance, is used in a pre-release version of
Nancy 2.0. If, when you read the book, there are stable releases for .NET core of the
different libraries (for example, if the stable Nancy 2.0 is out), I recommend using
those as you code along with the examples.
In the GitHub repository, at https://github.com/horsdal/microservices-in-dotnet-
core, the master branch contains the code as it appears in the book. As stable releases
of libraries for .NET Core come out, I plan to create a current branch and keep a copy
of the code there that I will keep mostly up-to-date with the latest versions of libraries
for a few years after publication of this book.
xviii ABOUT THIS BOOK

This book contains many examples of source code, both in numbered listings and
inline with normal text. In both cases, source code is formatted in a fixed-width font
like this to separate it from ordinary text. Sometimes code is also in bold to high-
light code that has changed from previous steps in the chapter, such as when a new
feature adds to an existing line of code.
In many cases, the original source code has been reformatted; I’ve added line
breaks and reworked indentation to accommodate the available page space in the
book. In rare cases, even this was not enough, and listings include line-continuation
markers (➥). Additionally, comments in the source code have often been removed
from the listings when the code is described in the text. Code annotations accompany
many of the listings, highlighting important concepts.

Author Online
Purchase of Microservices in .NET Core includes free access to a private web forum run
by Manning Publications where you can make comments about the book, ask techni-
cal questions, and receive help from the author and from other users. To access the
forum and subscribe to it, point your web browser to https://www.manning.com/
books/microservices-in-net-core. This page provides information on how to get on
the forum once you are registered, what kind of help is available, and the rules of con-
duct on the forum. It also provides links to the source code for the examples in the
book, errata, and other downloads.
Manning’s commitment to our readers is to provide a venue where a meaningful
dialog between individual readers and between readers and the authors can take
place. It is not a commitment to any specific amount of participation on the part of
the authors, whose contribution to the forum remains voluntary (and unpaid). We
suggest you try asking the author challenging questions lest his interest strays!
The Author Online forum and the archives of previous discussions will be accessi-
ble from the publisher’s website as long as the book is in print.

About the author


Christian is an independent consultant with many years of experience building web
and distributed systems on .NET as well as other platforms. He is part of the Nancy
maintainer team and is a Microsoft MVP for .NET.
Visit https://ebooknice.com to
discover a wide range of
eBooks across various genres.
Enjoy exclusive deals and
discounts to enhance your
reading experience. Start your
digital reading journey today!
about the cover illustration
The figure on the cover of Microservices in .NET Core is captioned “Emperor of China in
his Robes, in 1700.” The illustration is taken from publisher Thomas Jefferys’ A Collec-
tion of the Dresses of Different Nations, Ancient and Modern (four volumes), London, pub-
lished between 1757 and 1772. The title page states that these are hand-colored
copperplate engravings, heightened with gum arabic. Thomas Jefferys (1719–1771)
was called “Geographer to King George III.” He was an English cartographer who was
the leading map supplier of his day. He engraved and printed maps for government
and other official bodies and produced a wide range of commercial maps and atlases,
especially of North America. His work as a mapmaker sparked an interest in local
dress customs of the lands he surveyed and mapped, which are brilliantly displayed in
this collection.
Fascination with faraway lands and travel for pleasure were relatively new phenom-
ena in the late 18th century and collections such as this one were popular, introduc-
ing both the tourist as well as the armchair traveler to the inhabitants of other
countries. The diversity of the drawings in Jefferys’ volumes speaks vividly of the
uniqueness and individuality of the world’s nations some 200 years ago. Dress codes
have changed since then and the diversity by region and country, so rich at the time,
has faded away. It is now often hard to tell the inhabitant of one continent from
another. Perhaps, trying to view it optimistically, we have traded a cultural and visual
diversity for a more varied personal life. Or a more varied and interesting intellectual
and technical life.

xix
xx ABOUT THE COVER ILLUSTRATION

At a time when it is hard to tell one computer book from another, Manning cele-
brates the inventiveness and initiative of the computer business with book covers
based on the rich diversity of regional life of two centuries ago, brought back to life by
Jeffreys’ pictures.
Part 1

Getting started
with microservices

T his first part explains what microservices are and why you should care. I’ll
begin by discussing six characteristics you can use to recognize and guide your
design of microservices. Along the way, we’ll look at the benefits and costs of
microservices.
Toward the end of chapter 1, I’ll give you a whirlwind tour of the technology
stack used throughout the book; the stack consists of .NET Core, the Nancy web
framework, and OWIN. Chapter 2 moves on to an example of building your first
microservice. You’ll also see more of Nancy’s strengths.
Another Random Document on
Scribd Without Any Related Topics
revival at the Canaan Methodist church, of which his employer was a
member and was serving at the time as class leader and janitor. The
meeting had been in progress for a number of days; many had
found the Savior, and the community was deeply stirred. He had
been sent to open the church and build the fire for the evening
service. While going quietly about his duties, all alone, the
impression came to him quite vividly that he ought to be a Christian,
and he resolved to go to the “mourner’s bench” that night. He was
never long in making up his mind, and when a decision was once
made, it was as a law of the Medes and Persians. So he went to the
altar that night and each succeeding night for more than a week.
One evening as he was listening to the sermon, conviction became
so intense that in his extremity he left the house. Though it was a
cold night and the ground was covered with snow, he stole out in
the woods. Kneeling in the snow, this youthful Jacob wrestled with
God in prayer. How long he tarried, he could not tell, but faith
triumphed, and the next he knew the woods were resounding with
his shouts of victory. Rushing into the church while the preacher was
yet talking, he put an end to the sermon by his shouting and
praising God. The congregation was electrified. Soon the
demonstration became general, and for a time pandemonium held
sway; but it was of a sort in which there were both method and
meaning, for its source was from above.
Like God’s servant of old, he could say, “My heart is fixed.” He
joined the church and from that time never missed an opportunity to
pray and testify in public or private. At that time children did not
receive much attention from the church. Churches were strong on
saving souls from damnation, but the idea of saving the entire life
for service had not taken deep root. As a result of the revival there
was a large class of “probationers.” When the period of probation
had expired, according to the church law, and they were to be
admitted into full membership, his name was not on the list. He was
not considered a member; at least that was his version of it, and the
only logical conclusion the case would warrant. It was a sore
disappointment, but of too delicate a nature to mention to his elders.
So he kept his feelings to himself.
Thus matters stood for little more than a year, when he learned
that there was to be a quarterly meeting at the Otterbein United
Brethren Church a few miles away. This church belonged to the
Rockville Circuit of the Wabash Conference. Rev. William Sherrill was
the pastor. The presiding elder, who was to hold the quarterly
conference, was Rev. Samuel Zuck. Both were strong and good men.
Jack had never attended a United Brethren service. What knowledge
he had of the Church was gained through conversations overheard
in the Maddox home. Ministers being frequently entertained there,
conversation at such times naturally took to religious channels. As
this was an age when churches did not entertain the most fraternal
feelings toward one another, these conversations were not
calculated, as a rule, to produce a favorable opinion of a rival
denomination. His interest in churches and religion was genuine,
born of a desire to know the truth. Hence, is was not mere curiosity
that led him to obtain his employer’s permission to spend Saturday
and Sunday with a neighbor in the Otterbein community so that he
might attend the services of the quarterly meeting.
The Church proved to be his affinity. Whatever misgivings he had,
vanished one by one. The general atmosphere of the first service
harmonized with his temperament. There was spirit in the singing.
His heart burned within him as he listened to the eloquent sermon
by the presiding elder; and when the pastor followed, as the custom
was, with a warm exhortation, he was enraptured. He resolved to
join the Church. As usual, the decision was made without much
preliminary. He knew where he stood, and stood there with both
feet. When he returned, his employer, as well as his own folks, was
thunderstruck to learn that he had become a full-fledged United
Brethren. Having put his hand to the plow, he never turned back. “I
have been so busy,” is a common saying with him, “that I have
never had time to backslide.”
It should be said in justice to the church where he first joined,
that his name had been entered upon the book, but by mistake it
was placed in the list with the full members. This accounts for his
not being received with the probationers, to which class he
belonged, and led to the conclusion that he was not considered a
member. Thus an apparently insignificant thing may prove to be a
matter of vital importance.
As a boy he possessed pronounced convictions and a keen sense
of religious obligation. This is demonstrated by an incident which
occurred while he was in the employ of Mr. Jerry Rush, a short time
after leaving the service of Mr. Maddox. Mr. Rush was a well-to-do
farmer and stock dealer. Neither he nor his wife made any profession
of religion, though their lives were regarded as exemplary and above
question in other respects. Some of the men who worked on the
farm, however, were of the baser sort. It seemed strange to young
Newgent that a man of Mr. Rush’s habits would surround himself
with men who were utterly destitute of moral scruples or of the
commonest decencies. To him their vulgarity and profanity were a
source of constant annoyance. At one time as their coarse jests were
grating on his sensitive ears, he was impressed with the idea that
this uncouth crowd afforded him a field for missionary work. The
impression was not long in taking definite shape. It came with the
force of a challenge, a bugle call to duty, a call that he never failed
to heed. His mind was made up that he would offer prayer with
these men before they retired that evening if Mr. Rush would grant
him the privilege.
It was a bold resolve, an ordeal from which a braver heart might
well have shrunk. Let eloquent tongues proclaim the praise of those
who face death at the cannon’s mouth, or the inspired pen
immortalize the hero, who, amid the applause of admiring
multitudes, imperils his own life to save another; but who would not
count it a worthy act to place a laurel wreath upon the brow of a
fourteen-year-old lad who dared to face, not one Goliath, but a
company of Goliaths, with the simple weapon of faith, and demand
that they bow before their God while he offered a petition in behalf
of their needy souls? Yet this resolute purpose was to undergo a
severe test. The fiercest battles are fought in our own hearts. As the
time drew near, he felt his courage slipping away. He stole out to the
barn for a time of secret prayer, that he might be equal to the
emergency. Feeling comforted and strengthened, he started to the
house to execute his plan. On reaching the yard gate his courage
seemed to take flight, and he could go no farther. He went back to
the place of prayer. On the second venture he got as far as the door,
when his strength again vanished. Not to be beaten, he went back
to the barn to fight the battle to a finish. The third effort won the
day. He hastened to the house, determined not to give the enemy a
chance. The men were sitting about the fire. Without a word by way
of preliminary, he stepped up to Mr. Rush and asked permission to
kneel with them in prayer. The permission was granted, and a
solemn hush came over the startled company as they listened while
the boy, with trembling voice and stammering accents, poured out
his soul to God. He then sought his bed with the consciousness that
he had done his duty. A sweet peace filled his soul and he lay for
hours in ecstacy of joy.
The next evening the family devotions were repeated. But on the
third evening the prayer was forestalled by a preconcerted plan on
the part of the men. As the time for prayer approached, one after
another, they arose and stalked out of the room, and the victor in
two hard-fought battles was left alone—defeated and dejected. His
spirits dropped down to zero. The fiery dart had pierced him through
and through. In agony of soul he sought his bed, but not to rest.
Out of the depth of his troubled heart he called upon God for
comfort. But the fury of the storm seemed only to increase. In his
desperation he felt that something must be done. So, about the hour
of midnight, he arose, dressed himself, and left the house to go—he
knew not where. Through the remaining hours of the night he
wandered, directing his course toward the West. Daylight came, the
sun rose above the horizon and pursued its course toward the
zenith, but his pilgrimage continued. At noon he found himself in the
city of Terre Haute, then a mere village. Here he tarried for a time to
seek employment. Failing in this, he resumed his westward journey.
He asked for work at the various farm houses which he passed.
While he found kind hearts who, touched by pity for the youthful
pilgrim, gave him food and temporary shelter, he found no man to
hire him until he reached Mattoon, Illinois, nearly a hundred miles
from whence he started. Work at that season of the year was scarce,
and his term of service at Mattoon was brief. At the end of three
days his employer gave him his wages with the intelligence that his
services were no longer needed.
He now decided to go back to Indiana. With his three days’ wages
in his pocket, with which he expected to pay for his transportation at
least part of the way, he set out upon the return journey. Within the
vicinity of Terre Haute he succeeded in finding steady employment
and a congenial home.
There were two sides to this story, and some months after Jack
was settled in his new home he learned the other side. It was
glorious news to him. The sequel was that Mr. Rush was converted,
joined the Baptist Church, and became a zealous leader in religious
work. It came about in this way: When Mr. Rush found that Jack had
disappeared and diligent effort failed to solve the mystery of his
disappearance, a feeling of remorse over his unchristian conduct so
possessed him that for days he was almost in a state of frenzy.
Remorse took the form of spiritual conviction and genuine
repentance which led to a glorious conversion.
On learning of the whereabouts of his young benefactor, Mr. Rush
at once went to see him, and told him his side of the story. He
confessed to Jack that he was a guilty party to the scheme the men
had used to defeat him. The boy’s awkward prayer together with
their own antipathy for such pious exercises was a source of
embarrassment to the men, and they agreed among themselves to
use the method described to rid themselves of further annoyance.
Little did Mr. Rush realize that those awkward prayers were to be the
means of his salvation.
“God moves in a mysterious way,
His wonders to perform,
He plants his footsteps on the sea,
He rides upon the storm.

“Judge not the Lord with feeble sense,


But trust him for his grace,
Behind a frowning providence
He hides a smiling face.”
Chapter Three.
Call to the Ministry—First Sermon—The Boy Preacher—
Answering a Fool After his Folly—Turning a Camp
Meeting Tide—Quieting a Skirmish—Takes a Wife.

Providence seemed to ordain that there should be one preacher in


the Newgent family and that that one should be Jack. As has been
observed, his religious zeal from the time of his conversion at the
age of ten, was exceptional. Just when the first impression looking
toward the ministry came to him he could scarcely tell, such
impressions having been associated more or less with his religious
experience from the beginning. By the time he was thirteen the
conviction that he had a “divine call” to preach the gospel became
clear and definite. And the conviction deepened with the passing of
time. Of course, no one dreamed of the emotions that were stirring
the boy’s breast, and to him the ministry was so high and sacred a
calling as to seem infinitely beyond his possibilities. Hence, he dared
not express his feelings to even his most intimate friends, and so
received no sympathy or encouragement from any human source.
He went about his Father’s business in his own way, rendering such
service to the cause of his Master as a boy of his years was capable
of. His zeal knew no abatement, and such diligence is sure to lead to
recognition and reward.
The minister who first took a special interest in him was Rev. Ira
Mater, an able preacher and a sympathetic discerner of the thoughts
and intents of the heart. Between the man and the lad there sprang
up a beautiful friendship, suggestive of that between Paul and
Timothy. Rev. Mr. Mater frequently invited his young friend to
accompany him to his appointments, and by way of stirring up the
gift that was in this prospective Timothy, sometimes called upon him
to open the service, to exhort after the sermon, or perform such
other public ministrations as were convenient. Rev. Mr. Newgent has
always gratefully acknowledged his indebtedness to this spiritual
father.
This association with Rev. Mr. Mater was during his sixteenth and
seventeenth years. He was small and rather delicate for one of his
age. His entire youth was a continual conflict with disease, the entire
category of which seemed to try their hand upon his slender frame.
But while his body was frail, his mind was strong and alert. That his
positive temperament and seeming disposition to never give up had
somewhat to do in staving off the grim monster, death, is not at all
unlikely.
His first regular discourse was preached at the Stedd School
House near Fontanet, in Clay County, Indiana. The school house was
used as a preaching point and weekly prayer meetings were
maintained. He was a frequent attendant at these services, and one
evening, on entering the house, he was met by the leader who said,
“Jack, the people are expecting you to preach to-night.” That he was
to preach was simply a surmise, his association with Rev. Mr. Mater
being the probable foundation of it. But some one surmised out loud
and the rumor gained currency. Observing his surprise at this
intelligence, the leader continued, “You had just as well begin here
and now,” in a manner that indicated that it was a foregone
conclusion that preaching was to be his life business. And Jack
preached. At any rate, if the effort could not be classed as
preaching, it was a splendid substitute for it. He announced as a
text, “If the righteous scarcely be saved, where shall the ungodly
and the sinner appear?” The congregation was visibly affected by his
fervor and earnestness, some of the more demonstrative ones giving
vent to their feelings in shouts of praise. He was urged to preach the
next night, and the meetings were continued for more than a week,
being held at various private homes, Newgent preaching at each
service. The divine seal was thus placed upon his ministry, and the
meeting marked the beginning of a new epoch in his career.
A few weeks later the Rockville quarterly conference granted him
a license to preach. The action was taken in his absence. J. P. White
was the preacher in charge and Thomas M. Hamilton was the
presiding elder. The action of the quarterly conference was almost a
superfluous formality, as he was now so greatly in demand that he
could not well avoid preaching.
The boy preacher was a popular character. To see a man on the
ante meridian of life in the pulpit was at that time quite unusual. The
popular prejudice was in favor of men who had spent the major part
of their lives on the farm or in business, thus acquiring a
competence that would enable them to proclaim that salvation is
free without being embarrassed or embarrassing their congregations
on the money question. Hence, a diminutive lad of seventeen,
weighing only about eighty pounds, exercising the ministerial
function was in itself sufficient to attract the multitudes. Wherever
he preached he was greeted by immense audiences. By many he
was regarded as a prodigy, though he could not be classed as such,
prodigies seldom accomplishing more than to afford amusement for
curious spectators. It is true, however, that he displayed qualities
unusual for one of his years, though it must be admitted that the
greater part of his power lay in his intense religious zeal and
earnestness.
Some characteristic incidents in this part of his ministry will not
only be of interest in themselves, but will at the same time serve to
illustrate his unique individuality. He went on one occasion to fill an
appointment at what was known as the Rough and Ready School
House. The name was justified by the prevailing social conditions.
Like Paul on Mars Hill, he found that at least some of the people
were very religious, though their religious energy was not always
directed to the best advantage. Not infrequently does it transpire
that men will fight for their religion even when they are utterly
averse to the practice of it, a fact which had a forcible illustration in
this particular service. He preached with his usual energy. The house
was crowded and the sermon seemed to be well received. There
happened to be present a minister of what was designated as the
Campbellite persuasion. Evidently the sermon did not coincide with
his theological bias. He asked permission to say a few words as the
speaker took his seat. The permission granted, he sallied forth with
a tirade of abuse and denunciation of the young preacher and his
theology in which his passion played a larger part than either his
judgment or his conscience. When he finally ran down, Newgent
arose in a calm manner and said, “Brother, with your way of applying
Scripture, I can prove that Eve was the mother of a turkey buzzard.”
“Prove it, then,” shouted back the irascible theologue. “Well, the
Bible says that Eve was the mother of all living, and that includes
turkey buzzards. Let us be dismissed,” and calling the audience to
their feet, he pronounced the benediction before his assailant had
time to reply.
At another time, with his brother, John Newgent, he happened to
drop in at a Methodist camp meeting in Sullivan County. They arrived
just in time for the morning service. A number of ministers were
seated on the platform, among them being Rev. Hayden Hayes, the
presiding elder. Rev. Mr. Hayes had met Newgent on a former
occasion, and as soon as he saw him enter the camp, rushed back
and taking him by the arm, led him to the platform. Hayes was a
strong, portly man, and the delicate lad was helpless in his grasp;
thus he was led as a lamb to the slaughter, and was informed that
he must preach. Though he vainly sought to be excused, yet he was
equal to the emergency. He had proceeded about ten minutes with
his discourse, when a man sitting a few feet in front of the platform
was converted and began to shout. He continued, and four others in
the congregation broke loose in like manner, all of them having been
converted through the effect of the sermon, and the discourse
disappeared in a whirlwind of praise that completely drowned the
speaker’s voice. Up to that time there had been no move in the
meeting.
John Newgent was imbued with the old-school Baptist doctrine
and had not sympathized with his brother’s preaching propensities.
After resuming their journey they rode for a time in silence. Finally
the older brother said, “Jack, you know I have always opposed your
preaching. But I want to say that I have no further objection to it;
but,” he added with quivering lips, “I want you to pray for me.” The
sermon had touched his heart.
Though urgent demands were made upon the boy preacher to
stay and assist in the meeting, he was unable to do so, and heard
nothing further from it until after he had returned from the war,
when by chance he again passed through the vicinity. He stopped at
the home of a Mrs. Mayfield, on whose farm the camp was located,
to get his dinner and his horse fed. As he was taking his leave,
having paid his bill, he chanced to observe the camp ground a short
distance away. Up to that time he was not aware that he was in the
immediate vicinity of it. He inquired of his hostess concerning the
camp meetings. She told him that but one such meeting had been
held, though the intention was to make it a permanent institution.
The unsettled condition of times during the Rebellion prevented the
plan from being carried out.
“How was that meeting?” Newgent asked, as one who had a
peculiar interest in it.
“Oh, it was a grand success. There was a little Baptist preacher
from near Lafayette happened in and preached one morning, and
just set things on fire. From that time on the meetings were
powerful.”
“What was the fellow’s name?” he asked, but she could not recall
it.
“Was it Newgent?” She said that sounded like it.
“Well,” he said, “I know him. He isn’t considered much of a
preacher up there where he lives, but,” he added, “you are mistaken
about his being a Baptist. He is a United Brethren.”
She looked at him curiously for an instant and said, “I believe you
are the fellow.” And his smile told that she had guessed aright.
His money was returned at once, and she insisted that he stay
and preach at the Methodist church near the camp ground that
night, assuring him that he would have a good hearing as there had
been much talk about the little preacher who had “set the camp
meeting afire.” This he was unable to do, but promised to return at a
later date.
A short while after the camp meeting, he filled an appointment for
his pastor, Rev. J. F. Moore, at the Leatherwood church, which was a
part of the Rockville charge. The pulpit arrangement of this church
was in strict harmony with the fashion of the times. It consisted of a
sort of wall which shut the preacher in almost completely from the
congregation, suggesting a military fortification. Newgent, being
small of stature, could with difficulty peer over the top of the
ramparts. He was led to believe, however, that the fortification was a
necessary precaution, for his artillery had been turned loose but a
short time when it was evident that there was a hearty response.
Bang! Some sort of a missile struck the rampart just in front of him
with a loud report. It was followed immediately by another, and the
bombardment, continued until six discharges were fired. The
preacher withdrew within the breastworks that small fraction of his
anatomy that was exposed, and waited for hostilities to cease. The
congregation was at once thrown into a state of confusion and
excitement. When the preacher finally surveyed the situation after
the heavy batteries were silenced, he saw that a hand-to-hand
skirmish was on between two men in the rear of the room. One was
making a desperate effort to get the other to the door and out of the
house. With the help of the congregation, he succeeded in putting
down the rebellion, and going back to his fortifications he finished
the discourse and the service was concluded in fairly good order. The
difficulty was only a side issue, the culmination of a grudge between
a couple of natives. The missiles were not aimed at the preacher, but
were fired from ambush through the open door; the man for whom
they were intended happened to be sitting in range with the pulpit.
Rev. Mr. Moore resigned the Rockville charge during the year and
Newgent was appointed to serve the unexpired term. This was his
first experience in the pastorate. His brief term of service here was
characterized by a revival of extraordinary results at Otterbein, his
home church. Converts were numbered by the scores and the
community was shaken by such a spiritual upheaval as it had never
known.

REV. ANDREW JACKSON NEWGENT

When he traveled his first circuit.

Another adventure should be chronicled here. It has been said


that there are but three real important events in a man’s life,
namely, his birth, his marriage, and his death. The second of this
great trio in the life of our subject occurred during the period
embraced in this chapter. It is a common saying with him that he
does not believe in early marriages, hence, he deferred this
important step until he was eighteen years old. And on the seventh
of January, 1857, he took to himself a wife in the person of Miss
Katharine Copeland. She proved to be a worthy and sympathetic
companion, heroically assuming her part of the burdens and
responsibilities that belong to the family of an itinerant preacher.
That her lot was not an easy one may be readily assumed when we
consider what the ministerial calling involved in that early day. Its
peculiar hardships fell most heavily upon the wife, yet these she
endured without protest. Brave in heart, gentle in temper, and in
heartiest accord with her husband’s interests, she proved to him a
real helpmeet, and an inspiration to his loftiest endeavors.
Chapter Four.
Conference Membership—Brulitz Creek Ministry—The
Modern Knight and his Steed—Abrupt Closing of
Family Devotions by a Dog on the Preacher—An
Original Marriage Ceremony—A Case of Mistaken
Identity—A Banner Missionary Collection—
Shawnee Prairie Pastorate—A Cold Day in April—
The Redemption of Hell’s Half Acre—Baiting for a
Perverse Fish—An Experience in the Whiskey
Business.

Rev. Mr. Newgent was received into the Upper Wabash Conference
at Milford, Indiana, in the spring of 1859. Bishop David Edwards
presided. The Conference had been formed the preceding year by a
division of the Wabash Conference territory. As a matter of
coincidence he was ordained four years later at the Conference in
session at the same place with the same Bishop presiding. He was
now in his twenty-first year, having been quite prominent in
ministerial labors for about four years, and had a record for zeal,
earnestness, and success in revival work that commended him
favorably to the Conference.
He was appointed by this Conference to the Brulitz Creek Circuit,
which gave him an unlimited field for the exercise of his zeal and
talents. The circuit consisted of eighteen appointments, only two of
which were at church-houses; the others were at school houses and
in private homes. With little or no competition, the circuit-rider was
monarch of all he surveyed, though in most cases when he received
his appointment he found enough already surveyed to tax his time
and energy to the limit. Preaching services were not confined to the
Sabbath, but would fall upon any day of the week, and even then
the intervals between appointments, except during the periodic “big
meeting,” were usually not less than five or six weeks.
The standard mode of travel was by horseback, and the circuit-
rider, in addition to his other qualifications, needed to be efficient in
horsemanship. This was scarcely necessary in Newgent’s case,
however. Not being able to own a horse at this time, he secured the
loan of one from an accommodating neighbor. The horse was as
accommodating as its owner. It was quite well “broke,” having
endured the rigors of some nineteen winters, and was experienced
in the various departments of farm work. It had sowed and reaped—
and eaten—its wild oats, and was absolutely reliable, at least to the
limit of its physical endurance. At any rate the horse had many
acknowledged good points, as a faithful portrait would have
demonstrated. While it may not have been in its real element on
dress parade, it served the more practical purpose of locomotion—to
a somewhat limited extent.
As the rider weighed scarcely a hundred pounds, the horse had no
cause to complain at his burden. And when it came to matters of
appearance, the odds were not so unevenly balanced as might be
supposed. The spare-built, smooth-faced youth, clad in his suit of
homespun, which was made with a reckless disregard of the lines
and proportions of his anatomy, might well have recalled the lines of
Shakespeare:

“Would that he were fatter, but I fear him not;


Yet if my name were liable to fear,
I know of no one whom I would so much avoid.”

Thus, mounted upon his trusty steed, armed with all the weapons
of spiritual warfare, this modern knight errant of the saddle-bags
rode forth valiantly to the scenes of the year’s conflicts and
triumphs. En-route to his first appointment, he found an opportunity
to do some pastoral work which led to an episode, without mention
of which these chronicles would be incomplete. Passing by the home
of one of his prominent members, he stopped for a brief call. The
house stood on the side of a hill, some distance from the road. A
flight of steps led up to the front door. Ascending the steps, he
rapped at the door and was kindly admitted by the good housewife.
All went merry as a marriage bell and the time of his departure was
at hand all too soon. He asked the privilege of bowing with the
family in prayer before going, which was freely granted. The weather
was warm and it was not thought necessary to close the door,
though had it been done in this case, it would have prevented a bit
of embarrassment and incidentally spoiled a good story. As all was
so congenial within, the pastor anticipated no molestation from
without, and so injudiciously knelt with his back to the open door.
As he warmed up to his devotions, he aroused from his slumbers a
large Newfoundland dog, that had evidently not noticed the
approach of the stranger, and up to that time was unaware of his
presence. The aroused canine at once began an investigation, and
when he saw what was going on, seemed much offended that he
had not been consulted about the matter. He bounded up the steps
into the room, and, seizing the preacher by the luxuriant growth of
black hair that covered his dome of thought, affording an excellent
hold for his teeth, he zealously set about the task of removing the
supposed intruder from the premises. The preacher was taken
unawares. Before he could assume a defensive attitude, he and the
dog were rolling pell-mell, higgledy-piggledy over each other, down
the steps, and landed in a confused heap on the ground. Devotions
thus came to an abrupt close; the family came to the preacher’s
rescue. All formalities were dispensed with for the time. By the
united efforts of the family, the dog and preacher were finally
separated without either of them being seriously damaged, and the
new pastor of Brulitz Creek Circuit went on his way to face new
adversaries and new experiences.
Family Devotions Interrupted.

He reached the home of Mr. Jacob Wimsett, in Vermilion County,


on Saturday evening as the sun was dropping below the horizon,
and there put up for the night. This was in the vicinity of his Sunday
morning appointment. It was an old-fashioned home even for that
day; the home atmosphere was more hospitable than conventional.
As the preacher himself was quite democratic in his temperament,
no formalities were required. He noticed among the various
members of the household a young man and a young woman who
seemed as unobtrusive and as awkward as himself. No introductions
being given, he took it for granted that they both were members of
the family and so gave them no particular thought until he was
ready to start to church the next morning. As he was about to take
his leave, the young man approached him rather diffidently and
requested him to wait a few minutes.
“Me an’ the girl,” he explained, pointing to the blushing lass on the
opposite side of the room, “are a goin’ to git married, an’ we want
you to say the words for us before you go.”
“All right,” said Newgent, in a manner that left the impression that
he understood the situation all the while, “give me your license.”
The document was produced and the twain took their place in
front of the preacher, while the rest of the company looked on. Up to
this time he had never served in that capacity and had not the
slightest idea of a marriage ceremony. Examining the document in a
seemingly critical manner for an instant as if to make sure that it
conformed to all requirements, he looked gravely at the trembling
young couple. “If you are agreed to live together,” he said so rapidly
as to render his words scarcely intelligible, “according to the
marriage covenant, join your right hands.” Scarcely had they time to
heed the injunction when he continued, “In the name of God I
pronounce you man and wife.” And the twain were made one.
He then hastened to his morning appointment, reaching the
church before the people began to gather. This was one of the two
church-houses on the circuit, and was called Nicholls’ Chapel.
“Father” Nicholls, one of the wheel-horses of the church, and in
whose honor it was named, was sweeping the floor and putting the
house in order. His task completed, he went home to get ready for
the morning service, without making the acquaintance of the young
stranger. Ere long the people began to arrive. By the time Sunday
school commenced the house was quite well filled. Newgent took his
seat in the rear of the house and received no particular attention. He
was not even invited to a place in a Sunday-school class. However,
his presence incognito gave him a good opportunity for taking notes.
He overheard frequent remarks concerning the new preacher. The
people had heard nothing of him and were expressing doubts about
his being in the neighborhood. And when Sunday school closed
without his presence being made known, their doubts seemed to be
confirmed.
Rev. William Jones, a retired preacher and a member of the local
class, came in just as Sunday school was closing and at once made
inquiry concerning the pastor.
“We haven’t seen or heard anything of him,” was the information
he received from Father Nicholls.
“Why, there he is now,” and Rev. Mr. Jones pointed to the
diminutive lad near the door.
“That fellow?” Father Nicholls was dumfounded. “That fellow has
been here all morning. I supposed he was some hired hand in the
neighborhood that had just happened in.”
Explanations and apologies were freely indulged in, the supposed
hired hand entering heartily into the joke. He was introduced to the
astonished congregation, and the service proceeded to their entire
satisfaction and delight. Father Nicholls treated him kindly; he
piloted him to the afternoon appointment, introducing him to all
whom they chanced to meet, invariably accompanying the
introduction with the story of the forenoon experience.
“If I had been out hunting for preachers,” he would say, in telling
the story, “I would not have snapped a cap at him.”
The year’s work on this field was a most fruitful one. The
membership was doubled, and though the charge was not above the
average in financial strength, he received the largest salary of any
member of the conference.
Little attention was given, at this time, to the cause of missions.
Money was not generally recognized as a vital factor in Christian
service. Salaries were meager and often consisted in provisions
rather than cash. In many places a strong sentiment prevailed
against a paid ministry. Poverty and ignorance were considered
necessary prerequisites to ministerial piety. The General Missionary
Board was only about nine years old, and missionary sentiment had
not taken deep root. But Newgent sowed missionary seed with a
lavish hand, and had the pleasure of reaping at least part of the
harvest. His ability to lead men to loosen their purse strings even
then began to be asserted in a marked degree. More than half of the
missionary contributions of the entire conference that year was
reported from Brulitz Creek Circuit.
His report attracted attention and won him considerable distinction
at the annual conference. According to custom each pastor reported
in person in the open conference relative to the different interests of
his charge. When asked about his missionary offering, Newgent
replied, “Here it is,” and taking a woolen bag, commonly called a
sock, from his pocket he emptied its contents on the table. The
contents consisted of coins of various denominations just as he had
gathered them to the amount of $33.40, the small change giving it
the appearance of a larger sum than he actually had. However, this
was considered remarkable. Most of the pastors reported nothing.
Dr. D. K. Flickinger, the first missionary secretary of the Church, was
occupying a seat on the platform near the Bishop, and joined
heartily with him in applause at the splendid report and the unique
manner of presenting it.
The year’s work placed the “boy preacher” in a most favorable
light, and led to his appointment to the Shawnee Prairie Circuit, the
strongest charge in the Conference. The charge had had the pastoral
service of Rev. Thomas H. Hamilton, a mighty man who stood high
in the counsels of the denomination. It was characterized by more
than the usual amount of wealth and culture, and withal an air of
aristocracy that led to demands upon a pastor that were most
exacting. Rev. Mr. Hamilton was a favorite on the circuit, and the
people had no thought of losing him. His election to the office of
presiding elder, however, necessitated the change, and when the
awkward, and, as they thought, inexperienced lad came among
them, they felt that their aristocratic tastes were outraged. It was a
wet, chilly day in April when he arrived, and the crestfallen spirits of
the people made it still more chilly for him. And when he learned
that the matter of rejecting him was being seriously considered, the
situation was anything but cheerful.
He told the people he would remain until the first quarterly
meeting, when the presiding elder, Rev. Mr. Hamilton, would be
present, and that he would willingly abide by their decision at that
time. This was a judicious step, as it gave him an opportunity to
prove himself. So he went to work with his usual zeal and by the
time of the quarterly meeting he had sixty conversions with about an
equal number of additions to the church. All thought of rejecting the
pastor had completely vanished. In fact they would not have
swapped him off for the “biggest gun they had ever heard fired.”
Such success as the charge had never known crowned the labors of
that year—great revivals at all the appointments, the circuit more
than doubled in strength, and enthusiasm at high tide. Thus their
mourning was turned into laughing. A unanimous demand was made
for his return for another year, but his restless spirit sought new
worlds to conquer. His motto has always been that it is better to go
to a needy field and build it up than to go where further
advancement is impossible. On this ground he asked to be sent to a
new field.
One experience on Shawnee Prairie Circuit is worthy of special
mention. Contiguous to the circuit, near Attica in Fountain County,
was a section of country known as Hell’s Half Acre. Its leading spirit
was an infidel doctor. His influence and teachings had so dominated
the community that it was found impossible to maintain religious
services there. Ministers were considered proud, indolent, and
altogether an undesirable lot. Newgent determined to do some
missionary work in that benighted place, though repeated efforts to
that end had been made in vain.
In order to make a favorable impression and avoid the imprecation
of being proud, he dressed in his everyday clothes and visited the
district school, which was the geographical and social center, and the
only place where meetings could be held. He announced that there
would be services at the school house that evening, to be continued
indefinitely, and urged the children to spread the news.
The announcement, however, did not produce satisfactory results.
The attendance the first three or four evenings did not exceed a
half-dozen. The atmosphere was rather chilly and the spiritual
barometer did not indicate an early change. It soon became
apparent that the old doctor was the key to the situation. If the
people were to be reached, it must be done mainly through him.
How to capture this Goliath was now the problem, and this problem
Newgent set about to solve.
The Sunday services having been no better attended than the
preceding ones, he decided upon a bold move. On Monday
afternoon he called at the doctor’s home. The doctor answered his
knock at the door in person. The old fellow’s rough demeanor and
uncouth appearance, his ancient cob pipe that had long been
entitled to a superannuated relation, the musty, dingy room which
the half-open door disclosed—all seemed in striking harmony with
his attitude toward religion. The preacher introduced himself and
explained that he was holding a revival over at the school house.
The grizzled old sinner looked him over from head to foot, but said
nothing, though the expression on his sin-hardened face seemed to
say more plainly than words, “Well, you little rascal, you had better
be at home with your mother.”
“I understand,” persisted the preacher, ignoring the old
gentleman’s contemptuous frown, “that you are a good singer and a
prominent citizen, and I would like to consult you about the work
and get you to help me.”
“Help in a revival? Why, don’t you know that I don’t believe in the
Bible or churches, or religion of any sort?”
“Well, that needn’t stand in the way. The evenings are long and
the young people want somewhere to go. You can do the singing
and I’ll do the preaching.”
The Boy Preacher Visiting the Infidel.

That put a different complexion on things. Here was a chance for


some fun, and incidentally an outlet for his musical propensities, for
he was well versed in music. The idea seemed to take hold. The
grim features began to relax. The boys were called and told to “put
up the preacher’s horse,” and the preacher was invited into the
house. The invitation was heartily accepted. Newgent understood
fishing; he had fished before. The hook was baited and he now
perceived that he had got a nibble. The afternoon was spent to a
good advantage. Conversation flowed in various channels, but
fought shy of religion—no time for that yet. He waited for his fish to
take the cork under before pulling in. The doctor had a large family
of children, and their appearance bore testimony to the fact that
they were strangers to church and Sunday school. The boys spread
the startling news that “dad was goin’ to help the boy preacher in
the big meetin’.” And such news traveled as it were with seven-
leagued boots.
That was all the advertisement the meeting needed. The infidel
accompanied the preacher to the meeting, taking his place up front,
and led the singing after the droll manner then in vogue. An
earthquake or a man from the dead would not have created more
excitement or comment. From that time the little school house did
not accommodate the crowds.
The sermon that evening was not calculated to create a very
profound impression. It was more saturated with Irish humor than
with real gospel truth. The time for seriousness had not yet arrived.
But the axe was laid at the root of the tree, and the kingdom was
nearer at hand than any of them supposed. As a fisher of men, the
preacher was still baiting for the fish.
The next night he took for his theme the Judgment. This was the
occasion for solemn and serious facts. He turned loose all the
artillery at his command in storming the batteries of infidelity and
sin, and felt the presence of the Spirit in directing the message. As
he neared the close of his discourse, he turned to the doctor. The
wind had been taken out of the old man’s sails; his face was in his
hands and he was weeping bitterly.
“What’s the matter, doctor?” he shouted, in a strong, firm voice,
striving to make his words as impressive as possible.
The doctor did not answer.
“Get down on your knees,” he commanded as one who spoke with
authority.
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!

ebooknice.com

You might also like