kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Blake Matheny <bl...@tumblr.com>
Subject Thread Safety of Producer
Date Thu, 28 Jul 2011 18:04:05 GMT
I'm using a producer in an actor and wondering about the thread safety
of Producer (and Sync/Async Producer). Pseudo-code is something like:

class OurProducer(properties:Properties) extends Actor {
  val config = new ProducerConfig(properties)
  val producer = new Producer[Long, String](config)

  def act() = {
    loop {
      react {
        case msg:QueueMessage => producer.send(new ProducerData[Long,
String](queueName, id, Array(msg.toString))
        case _ => println("Unsupported message type")
      }
    }
  }

}

The service that uses this class instantiates just one instance, and
repeatedly sends QueueMessage's to it. There is a single Producer
instance available for use.

So, are there any potential concerns either with Producer.send or the
producer itself, being used in this way?

Thanks in advance,

-Blake

-- 
Blake Matheny

Mime
View raw message