# Query deadletter queue with businessKey

**URL:** <https://forum.flowable.org/t/query-deadletter-queue-with-businesskey/8228>\
**Category:** Flowable Engine\
**Created:** [August 8, 2021, 7:08pm UTC](https://forum.flowable.org/t/query-deadletter-queue-with-businesskey/8228 "2021-08-08T19:08:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mykeul](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@mykeul](https://forum.flowable.org/u/mykeul)\
**Post date:** [August 8, 2021, 7:08pm UTC](https://forum.flowable.org/t/query-deadletter-queue-with-businesskey/8228/1 "2021-08-08T19:08:59Z")

</div>

Continuing the discussion from [How to avoid all activities to be rolled back on Flowable Exception](https://forum.flowable.org/t/how-to-avoid-all-activities-to-be-rolled-back-on-flowable-exception/4058/10):

Hi,

@joram said:

> The deadletter job has executionId, processInstanceId and processDefinitionId

Is there a way to query the deadletter queue with a businessKey?  
If no, how can we achieve that? By looking in the runtime/history the mapping between businessKey and processInstanceId?  
When the process goes to the deadletter queue, is it removed from the runtime? Is it in the history?

Thanks,  
Michel

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [August 11, 2021, 12:45pm UTC](https://forum.flowable.org/t/query-deadletter-queue-with-businesskey/8228/2 "2021-08-11T12:45:12Z")

</div>

Hey @mykeul,

No there is no way to query the deadletter jobs with a businessKey.

> [@mykeul](#):
>
> When the process goes to the deadletter queue, is it removed from the runtime? Is it in the history?

A process does not go to the deadletter queue, a job goes. The process stays in the runtime and the history.

The runtime tables contain a subset of the history tables (unless you have disabled history).

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![mykeul](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@mykeul](https://forum.flowable.org/u/mykeul)\
**Post date:** [August 11, 2021, 1:53pm UTC](https://forum.flowable.org/t/query-deadletter-queue-with-businesskey/8228/3 "2021-08-11T13:53:40Z")

</div>

Thank you @filiphr  
So I can retrieve the processInstanceId by querying the runtimeService with the businessKey, then checking the deadLetterQueue to see if a job with such id exists there.  
My goal is to reply to clients that ask for process status and I want to check that the process is not in an error state.  
Thanks.

---

<div class="post-metadata">

**Author:** ![filiphr](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/filiphr/32/315_2.png) [@filiphr](https://forum.flowable.org/u/filiphr)\
**Post date:** [August 11, 2021, 2:12pm UTC](https://forum.flowable.org/t/query-deadletter-queue-with-businesskey/8228/4 "2021-08-11T14:12:30Z")

</div>

> [@mykeul](#):
>
> So I can retrieve the processInstanceId by querying the runtimeService with the businessKey, then checking the deadLetterQueue to see if a job with such id exists there.

Yes you can do this.

> [@mykeul](#):
>
> My goal is to reply to clients that ask for process status and I want to check that the process is not in an error state.

This makes a lot of sense. You could achieve this with what you proposed.

Cheers,  
Filip

---

<div class="post-metadata">

**Author:** ![mykeul](https://avatars.discourse-cdn.com/v4/letter/m/977dab/32.png) [@mykeul](https://forum.flowable.org/u/mykeul)\
**Post date:** [August 11, 2021, 2:31pm UTC](https://forum.flowable.org/t/query-deadletter-queue-with-businesskey/8228/5 "2021-08-11T14:31:36Z")

</div>

Perfect. Thanks a lot Filip.
