[keycloak-dev] Concurrency & EventsListener SPI

Poiffaut Romain romain.poiffaut at elca.ch
Thu Oct 5 05:25:30 EDT 2017


Thanks a lot for your answer.

Romain

-----Original Message-----
From: Marek Posolda [mailto:mposolda at redhat.com] 
Sent: mercredi 4 octobre 2017 20:38
To: Poiffaut Romain <romain.poiffaut at elca.ch>; keycloak-dev at lists.jboss.org
Subject: Re: [keycloak-dev] Concurrency & EventsListener SPI

Factory is typically application-scoped when provider is typically request-scoped (hence single-threaded). Different threads can use more providers concurrently. In other words, provider doesn't need to be thread-safe (EG. if you are using collection scoped just to the lifecycle of single provider instance), but factory should be.

For your use-case, your collection needs to be concurrency-safe if I understand correctly, as it's shared for whole factory and it's possible that more providers (requests/threads) will concurrently update it.

Marek

On 04/10/17 16:54, Poiffaut Romain wrote:
> Hi,
>
> I am writing a provider for eventsListener SPI.
> Could anyone tell me if the provider and its provider factory need to be thread safe ?
> With more details, I need to store some events. To do so, I am using a collection created by the factory and a reference to this collection is passed to the constructor to update it.
> Does my collection needs to be concurrency-safe or is it not needed?
>
> Best regards,
> Romain
> _______________________________________________
> keycloak-dev mailing list
> keycloak-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-dev





More information about the keycloak-dev mailing list