You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by David Ginzburg <da...@inner-active.com> on 2013/10/09 13:16:01 UTC

DataFileWriter thread safty

Hi,
I am writing a kafka consumer that persists messages into avro record files.
The consumer is a threaded application, but it is unclear to me if DataFileWriter is thread safe, or I need to add some synchronization
code when appending messages ?

Re: DataFileWriter thread safty

Posted by Doug Cutting <cu...@apache.org>.
DataFileWriter#append() is not synchronized.  If you have multiple
threads appending to the same file then you must synchronize.  For
example:

  synchronized (writer) { writer.append(value); }

Doug

On Wed, Oct 9, 2013 at 4:16 AM, David Ginzburg <da...@inner-active.com> wrote:
> Hi,
> I am writing a kafka consumer that persists messages into avro record files.
> The consumer is a threaded application, but it is unclear to me if
> DataFileWriter is thread safe, or I need to add some synchronization
> code when appending messages ?