# 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/4b280287bd55b99b44db2dd849f02d66c89534d5/libs/community/langchain_community/chat_message_histories/kafka.py#L42)