You can write your own system factory class by extending the SystemFactory
interface and implementing its three abstract functions, getConsumer
, getProducer
, and getAdmin
. In each one of the functions, take getConsumer
as an example, you want to create a system customer, an instance of another customized class extending SystemConsumer
and defining how the system should consume. By doing so, your Samza job would know how to get the admin/consumer/producer
of the system when needed.
Example (in Scala):
class YourSystemFactory extends SystemFactory {
override def getConsumer(systemName: String, config: Config, registry: MetricsRegistry): SystemConsumer = {
new YourSystemConsumer(
getAdmin(systemName, config).asInstanceOf[YourSystemAdmin],
config.get("someParam"))
}
override def getAdmin(systemName: String, config: Config): SystemAdmin = {
new YourSystemAdmin(
config.get("someParam"),
config.get("someOtherParam"))
)
}
override def getProducer(systemName: String, config: Config, registry: MetricsRegistry): SystemProducer = {
new YourSystemProducer(
getAdmin(systemName, config).asInstanceOf[YourSystemAdmin],
config.get("someParam"))
}
}
In your config:
# Your system params
systems.your.samza.factory=your.package.YourSystemFactory
systems.your.consumer.param=value
systems.your.producer.param=value