When you change a service’s class factory to pooled and set the parameter to preinitialize the pool to true, you get an exception when trying to run the server application, though the service’s EventRepository property is set.
Exception: ‘NewService.EventRepository property is not assigned’
To reproduce, you can create an empty server application from template, e.g. combo service, add in-memory session manager and event repository, set the service’s properties and change the class factory to
Thx, it is known issue. in some cases service instance can’t correctly assign properties from datamodule.
usually it appears in console applications.
as a workaround, pls initialize them manually, like
Yes, I think it was me who reported this issue 6 or 7 years ago
As I mentioned above, it happens in a blank application created from combo server template, not a console application. Explicitly assigning the session manager and event repository worked in the past, but not this time.
at moment of creating pooled class factory, server datamodule isn’t created. it is a reason for this problem.
as a workaround, you can create server datamodule before creating polled classfactory:
initialization
Application.CreateForm(TServerDataModule, ServerDataModule); /// moved from .dpr
fClassFactory := TROPooledClassFactory.Create('NewService', {$IFDEF FPC}@{$ENDIF}Create_NewService, TNewService_Invoker,5, pbWait, True);