[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Facing issue in RichSinkFunction

Hi Amol,

> On Jul 5, 2018, at 2:23 AM, Amol S - iProgrammer <amols@xxxxxxxxxxxxxxx> wrote:
> Hello folks,
> I am trying to write my streaming result into mongodb using
> RIchSinkFunction as below.
> gonogoCustomerApplicationStream.addSink(mongoSink)
> where mongoSink is Autowired i.e. injected object and it is giving me below
> error.
> The implementation of the RichSinkFunction is not serializable. The object
> probably contains or references non serializable fields.
> what is solution on this?

Once you figure out which field(s) contain references to non-serializable objects, you mark those as transient.

Then, in the RichSinkFunction.open() <https://ci.apache.org/projects/flink/flink-docs-master/api/java/org/apache/flink/api/common/functions/AbstractRichFunction.html#open-org.apache.flink.configuration.Configuration-> method, you create those objects using settings from other (serializable) fields that aren’t transient.

— Ken

Ken Krugler
+1 530-210-6378
Custom big data solutions & training
Flink, Solr, Hadoop, Cascading & Cassandra