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

fix: failing the consumer if publishing without the destination is detected #147

Conversation

aludwiko
Copy link
Contributor

No description provided.

if (consumerDestination.isEmpty) {
val baseMsg = s"Consumer [$componentId] produced a message but no destination is defined."
log.error(baseMsg + " Add @Produce annotation or change the Consumer.Effect outcome.")
Future.successful(new SpiConsumer.ErrorEffect(new SpiConsumer.Error(baseMsg)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initially, I just wanted to log warn/error, but then the consumer will move forward, which is probably not what the user wants when producing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing/holding off sounds good, this would be a code error so needs a new version of the user service deployed.

@@ -96,11 +101,22 @@ private[impl] final class ConsumerImpl[C <: Consumer](

private def toSpiEffect(message: Message, effect: Consumer.Effect): Future[Effect] = {
effect match {
case ProduceEffect(msg, metadata) =>
case ProduceEffect(msg: Done, metadata) =>
Future.successful(
new SpiConsumer.ProduceEffect(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we are missing one more spi effect abstraction, except ProduceEffect, ErrorEffect, and IgnoreEffect.
Sth like: ConsumedEffect or ProcessedEffect to signal that we successfully consumed the message, but we don't want to publish anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, as in produce for some messages but not all? Would possibly need some more changes in eventing/message publishing in the runtime than just being about the consumer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, as in produce for some messages but not all? - this is done with ProduceEffect + IgnoreEffect, but when I just consume sth without producing, I still have to return either ProduceEffect(Done) or IgnoreEffect, which semantically looks strange. It is hidden from the user-facing API, but visible in the SPI API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (consumerDestination.isEmpty) {
val baseMsg = s"Consumer [$componentId] produced a message but no destination is defined."
log.error(baseMsg + " Add @Produce annotation or change the Consumer.Effect outcome.")
Future.successful(new SpiConsumer.ErrorEffect(new SpiConsumer.Error(baseMsg)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing/holding off sounds good, this would be a code error so needs a new version of the user service deployed.

@aludwiko aludwiko merged commit 19cf516 into java-spi Jan 14, 2025
22 checks passed
@aludwiko aludwiko deleted the 3328-consumer-that-produces-without-defined-destination-should-inform-the-user-about-missing-configuration branch January 14, 2025 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants