-
Notifications
You must be signed in to change notification settings - Fork 47
Description
I am trying to use rebus in an integration project between different partners, using the configuration that I report below.
(It is a configuration in order to use topics to manage the publication)
services.AddRebus(conf =>
conf.Serialization((s) =>
{
s.UseNewtonsoftJson(new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.None,
});
s.UseCustomMessageTypeNames().AddWithCustomName<Message<OMIssue>>("omissue");
})
.Options(o =>
{
o.Decorate<ITopicNameConvention>(c =>
{
var messageTypeNameConvention = c.Get<IMessageTypeNameConvention>();
return new TopicNameConvention(messageTypeNameConvention);
});
})
.Transport(t =>
{
var options = t.UseRabbitMq($"amqps://localhost/host", "input-queue")
.ExchangeNames("directs", "topics")
.Declarations(declareExchanges: false)
.Ssl(new Rebus.RabbitMq.SslSettings(false, ""))
.CustomizeConnectionFactory(factory =>
{
var scoppes = string.Join(" ", [
"orange-bus.read:orange/topics/omissue",
"orange-bus.read:orange/directs/*",
"orange-bus.write:orange/directs/*",
$"orange-bus.read:orange/input-queue/*",
$"orange-bus.write:orange/input-queue/*",
$"orange-bus.configure:orange/input-queue/*",
$"orange-bus.write:orange/error/*",
$"orange-bus.configure:orange/error/*"
]);
var authclient = new OAuth2ClientBuilder("username", "password", new Uri("https://identityserver/connect/token"))
.SetScope(scoppes)
.Build();
factory.ClientProvidedName = "SubscriberExample";
factory.CredentialsProvider = new OAuth2ClientCredentialsProvider("orange", authclient);
return factory;
});
}),
onCreated: async bus =>
{
await bus.Subscribe<Message<OMIssue>>();
},
isDefaultBus: true
);
Rebus rightly provides for the use of these two custom headers for the deserialization of messages in order to know the type. Unfortunately, however, I cannot ask partners (who use other tools, to insert these specific headers)
["rbs2-content-type"] = "application/json",
["rbs2-msg-type"] = "my-topics-routing-key"
I therefore wanted to ask you if it is possible to add a Callback to be able to access the exchange information (BasicDeliverEventArgs) in order to be able to alter the TransportMessage and add the headers that are needed
return CreateTransportMessage(result.BasicProperties, result.Body.ToArray()); |
Alternatively, I ask you if it is possible to make the method
internal static TransportMessage CreateTransportMessage(IBasicProperties basicProperties, byte[] body)
overridable (making it protected not static) and with access to the BasicDeliverEventArgs so that by creating a decorator of the Transport you can implement custom logic
Thank you