You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by "hsy541@gmail.com" <hs...@gmail.com> on 2013/10/15 00:02:22 UTC

Is there a programmatic way to create topic

Hi kafka,

Is there a programmatic way to create topic.
http://stackoverflow.com/questions/16946778/how-can-we-create-a-topic-in-kafka-from-the-ide-using-api/18480684#18480684
is toooooo hacky, plus it's not a sync function.
I'm asking this because I'm writing a test case which will start kafka
server, create topic, produce and consume some message(in separate thread).
 But it fails some time because producer start to produce before the topic
is created. The auto topic creation property won't work either because the
consumer may start get TopicMeta data before the topic is created.
Thanks!

Best,
Siyuan

Re: Is there a programmatic way to create topic

Posted by Neha Narkhede <ne...@gmail.com>.
There are a bunch of examples in the unit tests and it is async.

Thanks,
Neha


On Mon, Oct 14, 2013 at 4:54 PM, hsy541@gmail.com <hs...@gmail.com> wrote:

> Hi Neha,
>
> Thank you, but can you give an example of CreateTopicCommand.createTopic()
> and is it sync or async?
>
> Best,
> Siyuan
>
>
> On Mon, Oct 14, 2013 at 4:45 PM, Neha Narkhede <neha.narkhede@gmail.com
> >wrote:
>
> > In 0.8, the only programmatic way, other than create topic, is to use
> > CreateTopicCommand.createTopic(). This is probably something we can
> improve
> > in the forthcoming releases.
> >
> > Thanks,
> > Neha
> >
> >
> > On Mon, Oct 14, 2013 at 3:02 PM, hsy541@gmail.com <hs...@gmail.com>
> > wrote:
> >
> > > Hi kafka,
> > >
> > > Is there a programmatic way to create topic.
> > >
> > >
> >
> http://stackoverflow.com/questions/16946778/how-can-we-create-a-topic-in-kafka-from-the-ide-using-api/18480684#18480684
> > > is toooooo hacky, plus it's not a sync function.
> > > I'm asking this because I'm writing a test case which will start kafka
> > > server, create topic, produce and consume some message(in separate
> > thread).
> > >  But it fails some time because producer start to produce before the
> > topic
> > > is created. The auto topic creation property won't work either because
> > the
> > > consumer may start get TopicMeta data before the topic is created.
> > > Thanks!
> > >
> > > Best,
> > > Siyuan
> > >
> >
>

Re: Is there a programmatic way to create topic

Posted by "hsy541@gmail.com" <hs...@gmail.com>.
Hi Neha,

Thank you, but can you give an example of CreateTopicCommand.createTopic()
and is it sync or async?

Best,
Siyuan


On Mon, Oct 14, 2013 at 4:45 PM, Neha Narkhede <ne...@gmail.com>wrote:

> In 0.8, the only programmatic way, other than create topic, is to use
> CreateTopicCommand.createTopic(). This is probably something we can improve
> in the forthcoming releases.
>
> Thanks,
> Neha
>
>
> On Mon, Oct 14, 2013 at 3:02 PM, hsy541@gmail.com <hs...@gmail.com>
> wrote:
>
> > Hi kafka,
> >
> > Is there a programmatic way to create topic.
> >
> >
> http://stackoverflow.com/questions/16946778/how-can-we-create-a-topic-in-kafka-from-the-ide-using-api/18480684#18480684
> > is toooooo hacky, plus it's not a sync function.
> > I'm asking this because I'm writing a test case which will start kafka
> > server, create topic, produce and consume some message(in separate
> thread).
> >  But it fails some time because producer start to produce before the
> topic
> > is created. The auto topic creation property won't work either because
> the
> > consumer may start get TopicMeta data before the topic is created.
> > Thanks!
> >
> > Best,
> > Siyuan
> >
>

Re: Is there a programmatic way to create topic

Posted by Neha Narkhede <ne...@gmail.com>.
In 0.8, the only programmatic way, other than create topic, is to use
CreateTopicCommand.createTopic(). This is probably something we can improve
in the forthcoming releases.

Thanks,
Neha


On Mon, Oct 14, 2013 at 3:02 PM, hsy541@gmail.com <hs...@gmail.com> wrote:

> Hi kafka,
>
> Is there a programmatic way to create topic.
>
> http://stackoverflow.com/questions/16946778/how-can-we-create-a-topic-in-kafka-from-the-ide-using-api/18480684#18480684
> is toooooo hacky, plus it's not a sync function.
> I'm asking this because I'm writing a test case which will start kafka
> server, create topic, produce and consume some message(in separate thread).
>  But it fails some time because producer start to produce before the topic
> is created. The auto topic creation property won't work either because the
> consumer may start get TopicMeta data before the topic is created.
> Thanks!
>
> Best,
> Siyuan
>