Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KafkaDispatcher changes to ingest message greater than 1MB #79

Open
wants to merge 1 commit into
base: release-3.6.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ object KafkaDispatcher extends IDispatcher {
val topic = config.getOrElse("topic", null).asInstanceOf[String]
val batchSize = config.getOrElse("batchSize", 100).asInstanceOf[Integer];
val lingerMs = config.getOrElse("lingerMs", 10).asInstanceOf[Integer];
val maxRequestSize = config.getOrElse("max_request_size", 1000000).asInstanceOf[Integer]
if (null == brokerList) {
throw new DispatcherException("brokerList parameter is required to send output to kafka")
}
Expand All @@ -53,7 +54,7 @@ object KafkaDispatcher extends IDispatcher {
}

events.foreachPartition((partitions: Iterator[String]) => {
val kafkaSink = KafkaSink(_getKafkaProducerConfig(brokerList, batchSize, lingerMs));
val kafkaSink = KafkaSink(_getKafkaProducerConfig(brokerList, batchSize, lingerMs, maxRequestSize));
partitions.foreach { message =>
try {
kafkaSink.send(topic, message, new Callback {
Expand All @@ -80,7 +81,7 @@ object KafkaDispatcher extends IDispatcher {

}

private def _getKafkaProducerConfig(brokerList: String, batchSize: Integer, lingerMs: Integer): HashMap[String, Object] = {
private def _getKafkaProducerConfig(brokerList: String, batchSize: Integer, lingerMs: Integer, maxRequestSize: Integer): HashMap[String, Object] = {
val props = new HashMap[String, Object]()
props.put(ProducerConfig.BATCH_SIZE_CONFIG, batchSize);
props.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, 60000.asInstanceOf[Integer]);
Expand All @@ -89,6 +90,7 @@ object KafkaDispatcher extends IDispatcher {
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer")
props.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, "snappy")
props.put(ProducerConfig.LINGER_MS_CONFIG, lingerMs)
props.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, maxRequestSize)
props
}

Expand Down