Documentation suggests to use property, which is marked internal (Routings)
On the documentation page about IMessageRoutingConvention, there is a code sample which shows how to set the routing key via convention.
Unfortunately this code sample doesn't work, because the Routings property which the sample uses is internal.
This code line: var routing = exchange.Routings[routingKey];
Is there an alternative on how to set the routing key, or should the property be public?
Oh and if I just set it via reflection anyway, it still doesn't work. I get this exception:
ArgumentOutOfRangeException: Endpoint rabbitmq://exchange/my-producer/routing/my-routing-key does not have an active sending agent. Message type: MyMessage (Parameter 'endpoint')
Wolverine.Runtime.Routing.MessageRoute..ctor(Type messageType, Endpoint endpoint, IReplyTracker replies) in MessageRoute.cs
Wolverine.Runtime.MessageRoutingConventions+<>c__DisplayClass0_0.<FindRoutes>b__1(Endpoint e) in WolverineRuntime.Routing.cs
System.Linq.Enumerable+IteratorSelectIterator<TSource, TResult>.MoveNext()
System.Collections.Generic.List<T>.AddRange(IEnumerable<T> collection)
Wolverine.Runtime.WolverineRuntime.findRoutes(Type messageType) in WolverineRuntime.Routing.cs
Wolverine.Runtime.WolverineRuntime.RoutingFor(Type messageType) in WolverineRuntime.Routing.cs
Wolverine.Runtime.MessageBus.PublishAsync<T>(T message, DeliveryOptions options) in MessageBus.cs
Program+<>c+<<<Main>$>b__0_2>d.MoveNext() in Program.cs
+
await bus.PublishAsync(message);
Microsoft.AspNetCore.Http.RequestDelegateFactory.<ExecuteTaskOfT>g__ExecuteAwaited|132_0<T>(Task<T> task, HttpContext httpContext, JsonTypeInfo<T> jsonTypeInfo)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
I honestly don't have a real suggestion. What are you trying to do? The built in conventional routing for Rabbit MQ just cheats and makes the binding name the same as the exchange name.
I tried to make an attribute for the message DTOs, where I can set the exchange and routing key to use. Exchange would be the same for most messages, but routing key would be different. It would probably equal the message type (Which is not equal to the .NET type, because we will communicate between at least 4 different programming languages).
I've been trying to do the exact same thing; sending to a specific routing key (or topic) based on a property in the message. I am surprised this is not permitted or has even been considered in Wolverine.
My topic names are dynamic for this particular exchange and so I cannot simply create more types sub-types of the same message.
I've just hit up against this too, this documentation for IMessageRoutingConvention is both confusing and incorrect.