You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Event Serialization and PII Data (GDPR)](modelling/event-sourcing/event-sourcing-introduction/persistence-strategy/event-serialization-and-pii-data-gdpr.md)
Copy file name to clipboardExpand all lines: modelling/event-sourcing/event-sourcing-introduction/persistence-strategy/event-serialization-and-pii-data-gdpr.md
+24-16
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
## Event Serialization
4
4
5
5
Ecotone use [Converters](../../../../messaging/conversion/conversion/) in order to convert Events into serializable form. \
6
-
This means we can customize process of serializing and deserializing specific Events and add needed encrypting capabilities. 
6
+
This means we can customize process of serializing and deserializing specific Events, to adjust it to our Application.
7
7
8
8
So let's assume **UserCreated** Event:
9
9
@@ -56,10 +56,13 @@ Then the Event Stream would look like above
56
56
57
57
This basically means we can serialize the Event in the any format we want. 
58
58
59
-
## Advanced Serialization Support with JMS
59
+
{% hint style="success" %}
60
+
Having customized Converters for specific Events, is also useful when we need to adjust some legacy Events to new format. We can hook into the deserialization process, and modify the payload to match new structure.
61
+
{% endhint %}
60
62
61
-
When using [JMS Converter](../../../../modules/jms-converter.md) support, we can even customize how we want to serialize given type globally between Messages. This follows on Ecotone's simplicity to ensure we spend as much as possible time on infrastructure part, and move the focus the business side of things. 
63
+
## Advanced Serialization Support with JMS
62
64
65
+
When using [JMS Converter](../../../../modules/jms-converter.md) support, we can even customize how we want to serialize given class, that is used within Events. \
63
66
For example we could have User Created Event which make use of `UserName` class.
64
67
65
68
```php
@@ -102,7 +105,10 @@ Now if we would serialize it without telling JMS, how to handle this class we wo
102
105
}
103
106
```
104
107
105
-
Now this is not fully safe, as if we would simply change property name in `UserName.value` to `UserName.name` it would break deserialization of our previous Events. Therefore we want to keep take over the serialization of objects, to ensure stability along the time.
108
+
Now this is fine for short-lived applications and testing, however in the long living application this may become a problem. The problem may come from changes, if we would simply change property name in `UserName.value` to `UserName.data` it would break deserialization of our previous Events. \
109
+
As `data` does not exists under `name` key.\
110
+
\
111
+
Therefore we want to keep take over the serialization of objects, to ensure stability along the time.
106
112
107
113
```php
108
114
class UserNameConverter
@@ -135,15 +141,15 @@ With this, with few lines of code we can ensure consistency across different Eve
135
141
136
142
## PII Data (GDPR)
137
143
138
-
In case of storing sensitive data, we may be forced by law to ensure that data should be forgotten (e.g. [GDPR](https://gdpr-info.eu/art-17-gdpr/)). This basically that if Customer will ask to delete his data, we will be obligated by law to ensure that this will happen. 
144
+
In case of storing sensitive data, we may be forced by law to ensure that data should be forgotten (e.g. [GDPR](https://gdpr-info.eu/art-17-gdpr/)). This basically means, if Customer will ask to us to remove his data, we will be obligated by law to ensure that this will happen. 
139
145
140
-
However in case of Event Sourced System we rather do not want to delete events, as this is critical operation which is considered dangerous. Deleting Events could affect running Projections, delete too much may raise inconsistencies in the System, and in some cases we may actually want to drop only part of the data - not everything.\
146
+
However in case of Event Sourced System we rather do not want to delete events, as this is critical operation which is considered dangerous. Deleting Events could affect running Projections, deleting too much may raise inconsistencies in the System, and in some cases we may actually want to drop only part of the data - not everything.\
141
147
Therefore dropping Events from Event Stream is not suitable solution and we need something different. 
142
148
143
-
Solution that we can use is to change the way we serialize the Event. Like we saw in the previous sections, we can hook into serialization process and set up a way to do so. \
144
-
Therefore as Converter as in reality an Service registered in Dependency Container, we may inject anything to them in order to modify the serialization process.
149
+
Solution that we can use, is to change the way we serialize the Event. We can hook into serialization process just as we did for normal serialization, and then customize the process.\
150
+
Converter in reality is an Service registered in Dependency Container, so we may inject anything we want there in order to modify the serialization process.
145
151
146
-
So let's assume that we want to encrypt UserCreated Event:
152
+
So let's assume that we want to encrypt `UserCreated` Event:
147
153
148
154
```php
149
155
final readonly class UserCreatedConverter
@@ -188,10 +194,9 @@ final readonly class UserCreatedConverter
188
194
189
195
So what we do here, is we hook into `serialization/deserialization` process and pass the data to `EncryptionService`. As you can see here, we don't store the payload here, we simply store an reference in form o a key.\
190
196
\
191
-
EncryptionService can as simple as storing this data in the table using key as Primary Key, so we can fetch it easily. It can be stored with plain text or it may be stored with encryption. \
192
-
It all depends on our Domain. \
197
+
EncryptionService can as simple as storing this data in database table using key as Primary Key, so we can fetch it easily. It can also be stored with encryption in some cryptographic service, yet it may also be stored as plain text. It all depends on our Domain. \
193
198
\
194
-
However what is important is that we've provided the resource id to the EncryptionService
199
+
However what is important is that we've provided the resource id to the `EncryptionService`
That that way this Data won't be available in the System anymore.\
221
+
That way this Data won't be available in the System anymore.\
216
222
Now we could just allow Converters fails, if those Events are meant to be deserialized, or we could check if given key exists and then return dummy data instead. 
217
223
218
-
{% hint style="info" %}
219
-
If we allow Converters to fail when Serialization happens, we should ensure that related Projections are using simple arrays instead of classes, and handle those cases during Projecting.
224
+
{% hint style="success" %}
225
+
If we allow Converters to fail when Serialization happens, we should ensure that related Projections are using simple arrays instead of classes, and handle those cases during Projecting.\
226
+
\
227
+
If we decide to return dummy data, we can keep deserializing those Events for Projections, as they will be able to use them. 
Copy file name to clipboardExpand all lines: modelling/event-sourcing/setting-up-projections/choosing-event-streams-for-projection.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ class Logger
39
39
40
40
### From Category
41
41
42
-
In case if using [`Stream Per Aggregate Persistence Strategy`](../event-sourcing-introduction/persistence-strategy/#stream-per-aggregate-strategy) we will need to use categories to target.\
42
+
In case if using [`Stream Per Aggregate Persistence Strategy`](../event-sourcing-introduction/persistence-strategy.md#stream-per-aggregate-strategy) we will need to use categories to target.\
43
43
If we would listen on `Domain\Ticket` stream using `Stream Per Aggregate` then we would not target any event, as the streams that are created are suffixed by the identifier `Domain\Ticket-123`. 
44
44
45
45
In that case we can make use of categories in order to target `Domain\Ticket-*.`
0 commit comments