Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering ServiceStack

You're reading from   Mastering ServiceStack Utilize ServiceStack as the rock solid foundation of your distributed system

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher Packt
ISBN-13 9781783986583
Length 216 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Andreas Niedermair Andreas Niedermair
Author Profile Icon Andreas Niedermair
Andreas Niedermair
Arrow right icon
View More author details
Toc

Intercepting requests and responses


A very basic scenario that is perfectly applicable amongst multiple services in a distributed environment is the need for a global identifier that travels from top to bottom of every request. This is often needed to determine which request to one API caused which request to another API; for example, to trace all the operations caused by a certain button-click in the UI.

This can be achieved by generating an identifier in the first service call and storing it along with the request. Whenever a service boundary is crossed, for example by forwarding the request to another service, the current identifier needs to be injected into that call.

First, we will define an interface that can be implemented by requests and responses to pass the identifier outside the scope of HTTP boundaries (in essence for MQ scenarios):

public interface IHasRequestIdentifier
{
  string RequestIdentifier { get; set; }
}

Additionally to this storage, we will also attach the identifier...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image