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

Publish().ToXXX() ignores the specified endpoint #1099

Closed
richardszalay opened this issue Oct 24, 2024 · 0 comments
Closed

Publish().ToXXX() ignores the specified endpoint #1099

richardszalay opened this issue Oct 24, 2024 · 0 comments

Comments

@richardszalay
Copy link
Contributor

richardszalay commented Oct 24, 2024

Describe the bug
Using the Publish().MessagesFromXXX().ToYYY() syntax ignores whatever was specified by ToYYY(). The equivalent Action overload Publish(p => p.MessagesFromXXX().ToYYY()) does work as expected.

As far as I can tell, it comes down to Publish() not assigning AutoAddSubscriptions = true, though based on that method's description it appears intentional. The problem is that, without AutoAddSubscriptions, the subscription is never added to the endpoint because the only other method that does so is AttachSubscriptions which is not public and is not called as part of the Publish().MessagesFromXX().ToYYY() chain (though it is called from the Action overload, which explains why that works).

The result of this appears to depend on the endpoint:

  • cascading messages returned by an HTTP endpoint (as additional tuple values) get added to the LocalRouting source and so are routed locally
  • cascading messages returned by regular message handlers don't appear in any routing source and so are ignored (via EmptyMessageRouter)

My initial reaction was to submit a PR that adds AutoAddSubcriptions = true to Publish() since there's no other way for the subscriptions to be added to the endpoint, but the wording of the code comments gave me pause. I am confused as to what use cases require the subscription never being added to the endpoint, though.

I'll leave it with you to provide direction, but I'm still happy to actually make the PR.

To Reproduce

It's worth noting that typeof(SomeType).Assembly is not the entrypoint assembly in my usecase (just in case there's some auto wiring of entry messages that would prevent this issue from being reproducable)

This does not work:

opts.Publish().MessagesFromAssembly(typeof(SomeType).Assembly)
    .ToKafkaTopic("test"); // Though it doesn't appear specific to Kafka

This works:

opts.Publish(publish =>
{
    publish
        .MessagesFromAssembly(typeof(SomeType).Assembly)
        .ToKafkaTopic("test"));
});

Expected behavior
I'd expect the two above snippets to be functionally equivalent

@richardszalay richardszalay changed the title Publish().ToXXX() is not routing messages Publish().ToXXX() ignores the specified endpoint Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant