Hi, John
Thanks a lot for valuable information.
I looked at KafkaAdminClient and I see that it offers createTopics method that
indeed seems suitable.
I still have a couple of questions:
1. In the documentation it is not mentioned what is the expected behavior if
the specified topic already exists.
Will it fail?
Will it throw TopicExistsException exception?
If topic existed before createTopics was called will it remain unchanged?
The behavior is not easily deduced from KafkaAdminClient code alone, I did
try....
2. I see that AdminClient is supported for a while now but API is still marked
as Evolving.
From version notes it seems that its basic functionality (like
createTopics) remains pretty stable.
Is it considered stable enough for production?
Thanks,
Victoria
On 16/02/2020, 20:15, "John Roesler" <[email protected]> wrote:
Hi Victoria,
I’ve used the AdminClient for this kind of thing before. It’s the official
java client for administrative actions like creating topics. You can create
topics with any partition count, replication, or any other config.
I hope this helps,
John
On Sat, Feb 15, 2020, at 22:41, Victoria Zuberman wrote:
> Hi,
>
> I have an application based on Kafka Streams.
> It reads from Kafka topic (I call this topic “input topic”).
> That topic has many partitions and their number varies based on the env
> in which application is running.
> I don’t want to create different input topics manually.
> Configuration of auto.create.topics.enable and num.partitions is not
> enough for me.
> The solution I am looking to implement is to check during application
> init whether the input topic exists and if not to create it with
> relevant partition number and replication factor.
>
> I found the following example that uses kafka.admin.AdminUtils and it
> seems to be suitable:
>
https://www.codota.com/code/java/methods/kafka.admin.AdminUtils/createTopic
>
> Please advise whether using AdminUtils is considered a good practice.
> Is AdminUtils functionality considered stable and reliable?
> If there are other solutions, I would appreciate to hear about them.
>
> Thanks,
> Victoria
>
> -------------------------------------------
> NOTICE:
> This email and all attachments are confidential, may be proprietary,
> and may be privileged or otherwise protected from disclosure. They are
> intended solely for the individual or entity to whom the email is
> addressed. However, mistakes sometimes happen in addressing emails. If
> you believe that you are not an intended recipient, please stop reading
> immediately. Do not copy, forward, or rely on the contents in any way.
> Notify the sender and/or Imperva, Inc. by telephone at +1 (650)
> 832-6006 and then delete or destroy any copy of this email and its
> attachments. The sender reserves and asserts all rights to
> confidentiality, as well as any privileges that may apply. Any
> disclosure, copying, distribution or action taken or omitted to be
> taken by an unintended recipient in reliance on this message is
> prohibited and may be unlawful.
> Please consider the environment before printing this email.
>
-------------------------------------------
NOTICE:
This email and all attachments are confidential, may be proprietary, and may be
privileged or otherwise protected from disclosure. They are intended solely for
the individual or entity to whom the email is addressed. However, mistakes
sometimes happen in addressing emails. If you believe that you are not an
intended recipient, please stop reading immediately. Do not copy, forward, or
rely on the contents in any way. Notify the sender and/or Imperva, Inc. by
telephone at +1 (650) 832-6006 and then delete or destroy any copy of this
email and its attachments. The sender reserves and asserts all rights to
confidentiality, as well as any privileges that may apply. Any disclosure,
copying, distribution or action taken or omitted to be taken by an unintended
recipient in reliance on this message is prohibited and may be unlawful.
Please consider the environment before printing this email.