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? ----------------------------------------------- *Amol Suryawanshi* Java Developer [hidden email] *iProgrammer Solutions Pvt. Ltd.* *Office 103, 104, 1st Floor Pride Portal,Shivaji Housing Society, Bahiratwadi,Near Hotel JW Marriott, Off Senapati Bapat Road, Pune - 411016, MH, INDIA.**Phone: +91 9689077510 | Skype: amols_iprogrammer* www.iprogrammer.com <[hidden email]> ------------------------------------------------ |
Hi Amol,
The implementation of the RichSinkFunction probably contains a field that is not serializable. To avoid serializable exception, you can: 1. Marking the field as transient. This makes the serialization mechanism skip the field. 2. If the field is part of the object's persistent state, the type of the field must implement Serializable. Furthermore, you can remove some fields to locate the problem fields. Best, Hequn On Thu, Jul 5, 2018 at 5:23 PM, Amol S - iProgrammer <[hidden email]> 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? > > ----------------------------------------------- > *Amol Suryawanshi* > Java Developer > [hidden email] > > > *iProgrammer Solutions Pvt. Ltd.* > > > > *Office 103, 104, 1st Floor Pride Portal,Shivaji Housing Society, > Bahiratwadi,Near Hotel JW Marriott, Off Senapati Bapat Road, Pune - 411016, > MH, INDIA.**Phone: +91 9689077510 | Skype: amols_iprogrammer* > www.iprogrammer.com <[hidden email]> > ------------------------------------------------ > |
In reply to this post by Amol S - iProgrammer
Hi Amol,
> On Jul 5, 2018, at 2:23 AM, Amol S - iProgrammer <[hidden email]> 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 http://www.scaleunlimited.com Custom big data solutions & training Flink, Solr, Hadoop, Cascading & Cassandra |
Free forum by Nabble | Edit this page |