Hey sgg, You have two options for cleaning up:
1. Implement ClosableTask with your StreamTask. 2. Use TaskLifecycleListener. ClosableTask is useful for cleaning up stuff that's been created inside StreamTask (task-level variables). For example, if your StreamTask has a client that talks to MongoDB, you can use ClosableTask to call close on the client. TaskLifecycleListener is useful for managing stuff that's independent of the task (container-level variables). Generally, this means anything that's a static variable or globally shared object shared among all tasks in the Samza container. At LinkedIn, for example, we use it to manage some static classes we have that control a unique ID that gets tagged with every RPC request we make from a Samza container. We reset the ID to a new one before every process method invocation (beforeProcess). You almost always want to use (1). If you still want to use (2), I've updated the docs to provide more detail on how to use it: http://samza.incubator.apache.org/learn/documentation/0.7.0/container/event -loop.html Cheers, Chris On 12/17/13 7:57 AM, "sgg" <[email protected]> wrote: >Does anyone have an example task lifecycle listener and corresponding >factory? I would like to take a look at how to set it up. It is not >clear (to me at least) from the documentation how to set one up. > >Basically I would like to hook the before close event so I can clean up >after my code invoked by samza. > >thanks in advance >sgg
