org.apache.kafka.streams.processor.StreamPartitioner Java Examples

The following examples show how to use org.apache.kafka.streams.processor.StreamPartitioner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KStreamBinder.java    From spring-cloud-stream-binder-kafka with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void to(boolean isNativeEncoding, String name,
				KStream<Object, Object> outboundBindTarget, Serde<Object> keySerde,
				Serde<Object> valueSerde, KafkaStreamsProducerProperties properties) {
	final Produced<Object, Object> produced = Produced.with(keySerde, valueSerde);
	StreamPartitioner streamPartitioner = null;
	if (!StringUtils.isEmpty(properties.getStreamPartitionerBeanName())) {
		streamPartitioner = getApplicationContext().getBean(properties.getStreamPartitionerBeanName(),
				StreamPartitioner.class);
	}
	if (streamPartitioner != null) {
		produced.withStreamPartitioner(streamPartitioner);
	}
	if (!isNativeEncoding) {
		LOG.info("Native encoding is disabled for " + name
				+ ". Outbound message conversion done by Spring Cloud Stream.");
		outboundBindTarget.filter((k, v) -> v == null)
				.to(name, produced);
		this.kafkaStreamsMessageConversionDelegate
				.serializeOnOutbound(outboundBindTarget)
				.to(name, produced);
	}
	else {
		LOG.info("Native encoding is enabled for " + name
				+ ". Outbound serialization done at the broker.");
		outboundBindTarget.to(name, produced);
	}
}
 
Example #2
Source File: ShareableStreamsMetadataProvider.java    From kiqr with Apache License 2.0 4 votes vote down vote up
public <K> StreamsMetadata metadataForKey(final String storeName,
                                          final K key,
                                          final StreamPartitioner<? super K, ?> partitioner) {
    return streamsClient.metadataForKey(storeName, key, partitioner);
}
 
Example #3
Source File: KafkaStreamsBinderWordCountFunctionTests.java    From spring-cloud-stream-binder-kafka with Apache License 2.0 4 votes vote down vote up
@Bean
public StreamPartitioner<String, WordCount> streamPartitioner() {
	return (t, k, v, n) -> k.equals("foo") ? 0 : 1;
}