Messaging Patterns: Change Detection Events

Listen to a stream of events and produce a new event when a value changes.

Published on 23 May 2019 by @mathiasverraes

Change Detection Events

Listen to a stream of events and produce a new event when a value changes.

Problem

A consumer is interested in an event stream, but the consumer only wants to know when a particular value changes, and doesn’t care about the events where that value didn’t change. Optionally, the consumer only cares when the value changes more than a given interval.

Solution

A second intermediary consumer is placed in front of the original consumer. It acts as a filter, emitting Change Detection Events when the observed value is different from the previous event. It may also ignore changes that are too small for the original consumer.

Change Detection Events are often used in combination with Ephemeral Events.

Example

The producer emits TemperatureWasMeasured multiple times per second. A consumer is only interested in changes of 1°C or more. An intermediate consumer listens to the TemperatureWasMeasured events. When an event arrives, it compares the temperature with the temperature from the previous event. If it differs by more than 1°C, it emits a TemperatureHasChanged event.

Follow @mathiasverraes on Twitter.



Upcoming

Have a look at our upcoming workshops
Past agenda entries...

Blog

2019

2016

2015

2014

2013

2012

2011

Creative Commons License This work by Mathias Verraes is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.