@Test public void testCustomPartitionCountOverridesPartitioningIfLarger() throws Exception { byte[] ratherBigPayload = new byte[2048]; Arrays.fill(ratherBigPayload, (byte) 65); KafkaTestBinder binder = (KafkaTestBinder) getBinder(); DirectChannel moduleOutputChannel = new DirectChannel(); QueueChannel moduleInputChannel = new QueueChannel(); Properties producerProperties = new Properties(); producerProperties.put(BinderProperties.MIN_PARTITION_COUNT, "5"); producerProperties.put(BinderProperties.NEXT_MODULE_COUNT, "3"); producerProperties.put(BinderProperties.PARTITION_KEY_EXPRESSION, "payload"); Properties consumerProperties = new Properties(); consumerProperties.put(BinderProperties.MIN_PARTITION_COUNT, "5"); long uniqueBindingId = System.currentTimeMillis(); binder.bindProducer("foo" + uniqueBindingId + ".0", moduleOutputChannel, producerProperties); binder.bindConsumer("foo" + uniqueBindingId + ".0", moduleInputChannel, consumerProperties); Message<?> message = org.springframework.integration.support.MessageBuilder.withPayload(ratherBigPayload) .build(); // Let the consumer actually bind to the producer before sending a msg binderBindUnbindLatency(); moduleOutputChannel.send(message); Message<?> inbound = moduleInputChannel.receive(2000); assertNotNull(inbound); assertArrayEquals(ratherBigPayload, (byte[]) inbound.getPayload()); Collection<Partition> partitions = binder.getCoreBinder().getConnectionFactory().getPartitions("foo" + uniqueBindingId + ".0"); assertThat(partitions, hasSize(5)); binder.unbindProducers("foo" + uniqueBindingId + ".0"); binder.unbindConsumers("foo" + uniqueBindingId + ".0"); }