# ensure_topic_exists

> **Function** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/chat_message_histories/kafka/ensure_topic_exists)

Create topic if it doesn't exist, and return the number of partitions.
If the topic already exists, we don't change the topic configuration.

## Signature

```python
ensure_topic_exists(
    admin_client: AdminClient,
    topic_name: str,
    replication_factor: int,
    partition: int,
    ttl_ms: int,
) -> int
```

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/7c10a5fa327f6aaaf7c932822a9e5d144891406e/libs/community/langchain_community/chat_message_histories/kafka.py#L42)