'How to pass headers with RabbitMQ request
I have following code which create and IRequestClient client and send request and waiting for the response. here you can see, I have set some headers value as well with GreenPipes
public async Task<CustomerData> GetCustomerData(CustomerDetailsReq request, CHeader headerKey)
{
CustomerData rtnRes = new();
using (var req = _clientCustomerDetailsReq.Create(request))
{
req.UseExecute(x => x.Headers.Set("datetime", headerKey.datetime));
req.UseExecute(x => x.Headers.Set("languageCode", headerKey.languageCode));
req.UseExecute(x => x.Headers.Set("version", headerKey.version));
var response = await req.GetResponse<CustomerData>();
rtnRes = response.Message;
}
return rtnRes;
}
Now, I need my requirement is, I don't need any response from Consumer side, and just wanted to pass the request to consumer with some header value. To achieve that, I just publish the command and forget it. my code as follows,
IPublishEndpoint _publishEndpoint;
public CustomerService(IPublishEndpoint publishEndpoint)
{
_publishEndpoint = publishEndpoint;
}
public async Task<string> TestMethod(CustomerDetailsReq request)
{
string datas = "";
try
{
await _publishEndpoint.Publish<CustomerDetailsReq>(orderRequest);
}
catch (Exception)
{
throw;
}
return datas;
}
But now, my concern is, how can I pass the header values with this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
