Listener Action goes into infinite loop

We have a kalix action which listens to an event, on receiving that event the corresponding handler method is executed infinitely.

19:54:47.143 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 0
19:54:47.613 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 1
19:54:48.461 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 2
19:54:50.229 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 3
19:54:53.568 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 4
19:55:00.278 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 5
19:55:10.727 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 6
19:55:21.271 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 7
19:55:32.238 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 8
19:55:42.597 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 9
19:55:53.417 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 10
19:55:53.650 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 11
19:55:54.088 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 12
19:55:54.927 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 13
19:55:56.638 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 14
19:55:59.888 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 15
19:56:06.589 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 16
19:56:16.987 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 17
19:56:27.087 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 18
19:56:37.407 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 19
19:56:47.888 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 20
19:56:58.857 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 21
19:56:59.109 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 22
19:56:59.569 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 23
19:57:00.456 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 24
19:57:02.238 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 25
19:57:05.658 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 26
19:57:12.307 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 27
19:57:22.738 INFO a.c.w.b.d.a.DLMOrganisationFullSearchRequestListenerAction - Response of DLM body 28

One more addition , the action listens to an entity event and when the event occurs, after some processing the action invokes the same entity, can that cause this infinite loop?

When an event handler fails, or returns an error effect, that means it will retry the same event until it suceeds. If it automatically continued it would mean that unexpected failures would lose data as it would move on with the next event and never see that failure causing event again.

If you want to drop events that trigger an error, and not retry processing them, you should catch/recover the exception triggered and return a reply or ignore effect for it.

… can that cause this infinite loop?

You can create an infinite loop with an action subscribing to the events of an entity and when processing those events trigger commands to the same entity leading to new events, yes.

ok, but the events are different not the same event that it’s subsribed to
service DLMOrganisationBasicSearchRequestListener {
option (kalix.codegen) = {
action: {}
};
rpc GetDLMOrganisationBasicSearchAPI(DLMOrganisationBasicSearchRequestedEvent) returns (au.com.westpac.blsop.framework.message.EntityAggregateStateChangeResponse) {
option (kalix.method).eventing.in = {
event_sourced_entity: “customer_external_system_search”
};
}
rpc AnyEventReceived(google.protobuf.Any) returns (google.protobuf.Empty) {
option (kalix.method).eventing.in = {
event_sourced_entity: “customer_external_system_search”,
ignore: true
};
}

for what it is worth, the entity_instance_id was being set as blank and it caused some internal error being thrown. Fixed that and that fixed the infinite loop issue as well