# How do correlation identifiers work?

**URL:** <https://forum.confluent.io/t/how-do-correlation-identifiers-work/2864>\
**Category:** Architecture and Design\
**Created:** [22 September 2021 07:39 UTC](https://forum.confluent.io/t/how-do-correlation-identifiers-work/2864 "2021-09-22T07:39:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmalc](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@mmalc](https://forum.confluent.io/u/mmalc)\
**Post date:** [22 September 2021 07:39 UTC](https://forum.confluent.io/t/how-do-correlation-identifiers-work/2864/1 "2021-09-22T07:39:02Z")

</div>

Hi, I’ve been looking at the documentation at [Correlation Identifier (confluent.io)](https://developer.confluent.io/patterns/event/correlation-identifier) and while I think I get it, the second code snippet doesn’t make sense to me. It says:

```auto
ProducerRecord<String, String> responseEvent = new ProducerRecord<>("response-event-key", "response-event-value"); 
requestEvent.headers().add("requestID", requestEvent.headers().lastHeader("requestID").value());
requestEvent.send(producerRecord);

```

Here it’s creating a responseEvent but never using it, which seems wrong to me, however I want to be sure I’m not missing some fundamental piece of understanding as I would have thought it should read:

```auto
ProducerRecord<String, String> responseEvent = new ProducerRecord<>("response-event-key", "response-event-value"); 
responseEvent.headers().add("requestID", requestEvent.headers().lastHeader("requestID").value());
responseEvent.send(producerRecord);

```

Can someone clarify for me please?

---

<div class="post-metadata">

**Author:** ![miguno](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/miguno/32/171_2.png) [@miguno](https://forum.confluent.io/u/miguno)\
**Post date:** [22 September 2021 09:03 UTC](https://forum.confluent.io/t/how-do-correlation-identifiers-work/2864/2 "2021-09-22T09:03:23Z")

</div>

Yeah, I think that’s a typo indeed. The first line (of the second code snippet) creates a `responseEvent`, and the next two lines should then operate on that `responseEvent` (= it should be like the second code snippet you shared in your post).

Probably a copy-paste error while writing up the pattern description. We’ll get that fixed. Thanks for reporting. @mmalc !

---

<div class="post-metadata">

**Author:** ![miguno](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/miguno/32/171_2.png) [@miguno](https://forum.confluent.io/u/miguno)\
**Post date:** [22 September 2021 09:07 UTC](https://forum.confluent.io/t/how-do-correlation-identifiers-work/2864/3 "2021-09-22T09:07:44Z")

</div>

Pull request up at [Use responseEvent to configure response by miguno · Pull Request #254 · confluentinc/event-streaming-patterns · GitHub](https://github.com/confluentinc/event-streaming-patterns/pull/254) (just for reference)

---

<div class="post-metadata">

**Author:** ![mmalc](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@mmalc](https://forum.confluent.io/u/mmalc)\
**Post date:** [22 September 2021 10:10 UTC](https://forum.confluent.io/t/how-do-correlation-identifiers-work/2864/4 "2021-09-22T10:10:47Z")

</div>

Cool, I figured that was the case. Just wanted to be sure.  
Thanks for responding so quickly.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [29 September 2021 10:10 UTC](https://forum.confluent.io/t/how-do-correlation-identifiers-work/2864/5 "2021-09-29T10:10:59Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
