0
在设置为请求traceId的API Gateway
应用程序中。然后通过HTTP
传递给我的无状态服务。但服务应通过RPC
(使用IServiceRemotingListener
)调用另一项服务。我怎样才能将traceId传递给其他服务?通过RPC与元数据进行服务结构通信
我到目前为止已经进行(根据this):
public interface ICommunicationService : IService
{
Task<string> FooAsync();
}
public class Stateless1 : StatelessService, ICommunicationService
{
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[] { new ServiceInstanceListener(c => this.CreateServiceRemotingListener(c)) };
}
public Task<string> FooAsync()
{
return Task.FromResult("TraceId: " + TraceId);
}
}
,并尝试使用它:
ICommunicationService service = ServiceProxy.Create<ICommunicationService>(new Uri("fabric:/App/Stateless1"));
string message = await service.FooAsync();
我怎么能传递TraceId到其他服务B RPC?
谢谢。是否有其他方式通过IServiceRemotingClient传递CorrelationId? –
是的,请检查:http://stackoverflow.com/questions/34166193/how-to-add-message-header-to-the-request-when-using-default-client-of-azure-serv/34221661# 34221661使用''''IServiceRemotingClient'''和'''ServiceRemotingDispatcher '''的自定义实现。 – LoekD
非常感谢您的联系和帮助 –