Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Data Contract Serialization for Remoting Exceptions #629

Merged
merged 9 commits into from
Nov 9, 2023
9 changes: 9 additions & 0 deletions src/Hosting.Services.Remoting/RemotingListenerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ protected RemotingListenerBuilder(
string name,
FabricTransportRemotingListenerSettings? settings = null)
{
if (settings == null)
Pr1ynka marked this conversation as resolved.
Show resolved Hide resolved
{
if (!FabricTransportRemotingListenerSettings.TryLoadFrom("TransportSettings", out settings))
{
settings = new FabricTransportRemotingListenerSettings();
}
}

settings.ExceptionSerializationTechnique = FabricTransportRemotingListenerSettings.ExceptionSerialization.Default;
Name = name;
Settings = settings;
}
Expand Down
16 changes: 14 additions & 2 deletions src/Services.Remoting/Client/OmexServiceProxyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Microsoft.ServiceFabric.Services.Remoting.Client;
using Microsoft.ServiceFabric.Services.Remoting.FabricTransport;
using Microsoft.ServiceFabric.Services.Remoting.FabricTransport.Runtime;
using Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Client;

namespace Microsoft.Omex.Extensions.Services.Remoting.Client
Expand All @@ -20,16 +21,27 @@ namespace Microsoft.Omex.Extensions.Services.Remoting.Client
public static class OmexServiceProxyFactory
{
private static ServiceProxyFactory s_serviceProxyFactory = new(handler =>
new OmexServiceRemotingClientFactory(
{
FabricTransportRemotingSettings remotingSettings;
if (!FabricTransportRemotingSettings.TryLoadFrom("TransportSettings", out remotingSettings))
{
remotingSettings = new FabricTransportRemotingSettings();
}

remotingSettings.ExceptionDeserializationTechnique = FabricTransportRemotingSettings.ExceptionDeserialization.Default;
return new OmexServiceRemotingClientFactory(
new FabricTransportServiceRemotingClientFactory(
remotingCallbackMessageHandler: handler)));
remotingCallbackMessageHandler: handler,
remotingSettings: remotingSettings));
});

/// <summary>
/// Binds custom transport settings to the service proxy factory.
/// If non-default secure remoting configuration is required, call this before calling OmexServiceProxyFactory.Instance.
/// </summary>
public static void WithCustomTransportSettings(FabricTransportRemotingSettings transportSettings)
{
transportSettings.ExceptionDeserializationTechnique = FabricTransportRemotingSettings.ExceptionDeserialization.Default;
Pr1ynka marked this conversation as resolved.
Show resolved Hide resolved
s_serviceProxyFactory = new ServiceProxyFactory(handler =>
new OmexServiceRemotingClientFactory(
new FabricTransportServiceRemotingClientFactory(
Expand Down