question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PartitionKeyExtractorStrategy instances do not have access to application context

See original GitHub issue

When selecting the partion of a kafka topic using a custom PartitionKeyExtractorStrategy, the instantiated objects are not initialized to use configuration values or beans from the application context. This would be very useful when selecting the partition based on a configurable value.

I have a provided a demo. When starting it, the logging shows that the inserted @Value is null and not properly initialized.

If this is on purpose the documentation should provide more information what is initialized into the this object.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
garyrussellcommented, Jan 23, 2017

Maybe replace it with a beanName ?

This was a carry-over from Spring XD where it was less-easy to add custom beans to the context.

0reactions
mbogoevicicommented, Jan 23, 2017

@garyrussell @ilayaperumalg I am reviewing https://github.com/spring-cloud/spring-cloud-stream/issues/760 - wondering if we should consider deprecating this mechanism in a future release (1.2?) - at the risk of disabling creating such configurations per-binding. The whole mechanism is somewhat un-Spring-like.

Read more comments on GitHub >

github_iconTop Results From Across the Web

8. Inter-Application Communication - Spring
When scaling up Spring Cloud Stream applications, each instance can receive information about how many other instances of the same application exist and ......
Read more >
Getting Spring Application Context - java - Stack Overflow
getApplicationContext()(Singleton pattern) , which returns a instance of new XXXXApplicationContext(XXXX), why it is not work? Why Do I have to autowired it? – ......
Read more >
spring-cloud/spring-cloud-stream - Gitter
Now, when trying to publish messages we get an error, "Magic V1 does not support record headers". So we tried configuring setting type...
Read more >
Super simple approach to accessing Spring beans from non ...
How can I inject Spring managed beans into POJO's and classes not ... can access said instance of ApplicationContext and use that to...
Read more >
Spring Web Contexts - Baeldung
That's an interface extending ApplicationContext with a contract for accessing the ServletContext. Anyway, applications usually should not ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found