Skip to content

Commit 2837ec7

Browse files
v-gerasimovmanub
authored andcommitted
Added ability to override default embedded kafka properties (#50)
* Cannot change default embedded kafka properties When you use embedded kafka, you may be want to change default properties e.g. you have integration tests and want to start embedded kafka with integration tests in one network node, but an application starts in another network node. Embedded kafka runs with binding to localhost so you cannot to connect to it from another node. This PR fix this problem and you can change default propeties, so now you can set `host.name` and `advertised.host.name` correctly. * Cannot change default embedded kafka properties Update README
1 parent 85e8d21 commit 2837ec7

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ This works for both `withRunningKafka` and `EmbeddedKafka.start()`
7575

7676
Also, it is now possible to provide custom properties to the broker while starting Kafka. `EmbeddedKafkaConfig` has a
7777
`customBrokerProperties` field which can be used to provide extra properties contained in a `Map[String, String]`.
78-
Those properties will be added to the broker configuration, however some properties are set by the library itself and
79-
in case of conflict the library values will take precedence. Please look at the source code to see what this properties
78+
Those properties will be added to the broker configuration, be careful some properties are set by the library itself and
79+
in case of conflict your values will take precedence. Please look at the source code to see what these properties
8080
are.
8181

8282
## Utility methods

embedded-kafka/src/main/scala/net/manub/embeddedkafka/EmbeddedKafka.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,6 @@ sealed trait EmbeddedKafkaSupport {
278278
val zkAddress = s"localhost:${config.zooKeeperPort}"
279279

280280
val properties: Properties = new Properties
281-
config.customBrokerProperties.foreach {
282-
case (key, value) => properties.setProperty(key, value)
283-
}
284281
properties.setProperty("zookeeper.connect", zkAddress)
285282
properties.setProperty("broker.id", "0")
286283
properties.setProperty("host.name", "localhost")
@@ -289,6 +286,9 @@ sealed trait EmbeddedKafkaSupport {
289286
properties.setProperty("port", config.kafkaPort.toString)
290287
properties.setProperty("log.dir", kafkaLogDir.toAbsolute.path)
291288
properties.setProperty("log.flush.interval.messages", 1.toString)
289+
config.customBrokerProperties.foreach {
290+
case (key, value) => properties.setProperty(key, value)
291+
}
292292

293293
val broker = new KafkaServer(new KafkaConfig(properties))
294294
broker.startup()

0 commit comments

Comments
 (0)