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

Kafka auto-configuration does not support @SendTo #10669

Closed
garyrussell opened this issue Oct 17, 2017 · 3 comments
Closed

Kafka auto-configuration does not support @SendTo #10669

garyrussell opened this issue Oct 17, 2017 · 3 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@garyrussell
Copy link
Contributor

In order to support @SendTo (replies) in Kafka, the KafkaTemplate (if present) should be injected into the listener container factory...

	@KafkaListener(topics = "rjugUpcase", groupId = "rjug")
	@SendTo("rjug")
	public String upcase(String in) {
		System.out.println("upcase: " + in);
		return in.toUpperCase();
	}
java.lang.IllegalStateException: a KafkaTemplate is required to support replies
	at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.0.0.RELEASE.jar:5.0.0.RELEASE]
	at org.springframework.kafka.config.MethodKafkaListenerEndpoint.createMessageListener(MethodKafkaListenerEndpoint.java:136) ~[spring-kafka-2.0.0.RELEASE.jar:2.0.0.RELEASE]

See AbstractKafkaListenerContainerFactory.setReplyTemplate().

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 17, 2017
@snicoll snicoll added priority: normal type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 18, 2017
@snicoll snicoll self-assigned this Oct 18, 2017
@snicoll snicoll added this to the 2.0.0.M6 milestone Oct 18, 2017
@snicoll snicoll changed the title Kafka Autoconfiguration - inject KafkaTemplate into container factory Kafka auto-configuration does not support @SendTo Oct 18, 2017
@SamD
Copy link

SamD commented Jun 18, 2018

I'm still seeing this with 2.1.7.RELEASE

@snicoll
Copy link
Member

snicoll commented Jun 19, 2018

@SamD 2.1.7.RELEASE is a bit vague (there's no such Spring Boot version so I can only assume that's a Spring Kafka version. Support was added in Spring Boot as of Spring Boot 2.0.0.M6 (see the milestone information on the right).

If you have more questions, please ask on StackOverflow or come chat with us on Gitter.

@SamD
Copy link

SamD commented Jun 19, 2018

@snicoll I went back and reviewed the reference and from that was able to determine the problem

When using @sendto, the ConcurrentKafkaListenerContainerFactory must be configured with a KafkaTemplate in its replyTemplate

It wasn't clear from the error this was the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants