You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Vadim Keylis <vk...@gmail.com> on 2013/06/04 09:36:20 UTC

Send multiple messages to multiple topics in one request

Version 7 of Kafka allowed to send messages to multiple topics within one
request. I assume I can do
samething in version 8, am I correct? Does my code piece look correct?
List<KeyedMessage<String, String>> topicsMsgsList = new ArrayList();
KeyedMessage<String, String> data1 = new KeyedMessage<String,
String>(topic1, msg);
KeyedMessage<String, String> data2 = new KeyedMessage<String,
String>(topic2, msg);
topicsMsgsList.add(data1);
topicsMsgsList.add(data2);
 producer.send( topicsMsgsList );

Thanks,
Vadim

Re: Send multiple messages to multiple topics in one request

Posted by Jun Rao <ju...@gmail.com>.
Yes, your understanding is correct.

Thanks,

Jun


On Tue, Jun 4, 2013 at 12:36 AM, Vadim Keylis <vk...@gmail.com> wrote:

> Version 7 of Kafka allowed to send messages to multiple topics within one
> request. I assume I can do
> samething in version 8, am I correct? Does my code piece look correct?
> List<KeyedMessage<String, String>> topicsMsgsList = new ArrayList();
> KeyedMessage<String, String> data1 = new KeyedMessage<String,
> String>(topic1, msg);
> KeyedMessage<String, String> data2 = new KeyedMessage<String,
> String>(topic2, msg);
> topicsMsgsList.add(data1);
> topicsMsgsList.add(data2);
>  producer.send( topicsMsgsList );
>
> Thanks,
> Vadim
>