Kinesis consumer recordprocessor factory and record processor threadsafety

379 Views Asked by At

I have a kinesis consumer application using KCL. Kinesis stream has 3 shards and KCL is running on one instance. So there will be three record processor threads running on one instance created using same worker.

These record processors's are created using same recordprocessor factory . Are these record processor's thread safe ?

Say signature of my recordprocessorfactory constructor is

class MyRecordProcessordFactory implements IRecordProcessorFactory{
A a;B b;
MyRecordProcessorFactory(A a , B b)
this.a=a;this.b=b;
}

public IRecordProcessor createProcessor(){
return new MYRecordProcessor(a,b);
}

}

public class MYRecordProcessor implements IRecordProcessor{
A a,B b;
MYRecordProcessor(A a,B b){this.a=a;this.b=b;}

public void processRecords(ProcessRecordInput processRecordInput){
use a ;
use b;
}

}

Is use of a and b in processRecords threadsafe ? If not what to do to make it thread safe . Just making a and b reference final in MyRecordProcessorFactory and MyRecordProcessor will work ??

0

There are 0 best solutions below