0

My incoming event contains userId property. I'd like to be able to read the parameter value according to userId from the CQEngine. Should I implement this as extension of FunctionExecutor and use it like:

define stream cseEventStream (userId string, symbol string, price long, volume long);
@info(name = 'query1')
from cseEventStream [price < custom:cache(userId)]
select *
insert into Output

or is there some better way how to do it. The problem is that before first use of CQEngine I need to initialize it with data. Probably "start" method of the FunctionExecutor could be used for this purpose?

yshadow
  • 77
  • 4

1 Answers1

0

You can go ahead with a FunctionExecutor and implement initialization logic within either init() or start(). Both will be called once per function usage. Calling order is init() followed by start(). However, as per API doc, it's advised to use start() to acquire required resources for the processing element. and stop() to release acquired resources.

Grainier
  • 1,634
  • 2
  • 17
  • 30
  • Hi Grainier. Thank you for your response. In the meantime I've managed to implement it and it works. However do you have any idea how to inject some spring framework bean into the FunctionExecutor extension? The only way coming to my mind is some service locator. Do you have any other idea how to do it? Thank you. – yshadow Sep 21 '16 at 15:50