I've been building a "stupid" service bus from scratch that gets messages addressed to various different services (with credential tokens in the headers) and needs to relay said messages to the services with the proxy client it has of them.
A short code snippet explaining -
ServiceBus: IServiceBus {
SomeService clientProxy = new SomeService();
clientProxy.OperationThatRequiresTokensHere(); //this is the way the message is relayed.
}
I've been trying to implement IDispatchMessageInspector and to use AfterRequest and BeforeReply to:
A. get the values from the headers and send them as object to BeforeSend.
B. in BeforeSend to insert them in the proxy client message to the correct Service.
Am I misusing IDispatch here? Is this the correct approach? disregard whether my idea of a service bus is correct right now please.
If this isn't the way to go about it, how would you collect the message headers and insert them properly when the proxy message goes to the original service?
You're trying to influence the message flow from an extensibility point in the WCF service model pipeline that is designed to inspect/edit messages. That's not going to work.