/// <summary>
        /// Optional override to create listeners (e.g., HTTP, Service Remoting, WCF, etc.) for this service replica to handle client or user requests.
        /// </summary>
        /// <remarks>
        /// For more information on service communication, see https://aka.ms/servicefabricservicecommunication
        /// </remarks>
        /// <returns>A collection of listeners.</returns>
        protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners()
        {
            return(new[]
            {
                new ServiceReplicaListener(context =>
                {
                    return new WcfCommunicationListener <ICeModelProviderContract>(context,
                                                                                   this.modelProvider,
                                                                                   WcfUtility.CreateTcpListenerBinding(),
                                                                                   EndpointNames.CeModelProviderServiceEndpoint);
                }, EndpointNames.CeModelProviderServiceEndpoint),

                new ServiceReplicaListener(context =>
                {
                    return new WcfCommunicationListener <ITransactionActorContract>(context,
                                                                                    this.ceTransactionActor,
                                                                                    WcfUtility.CreateTcpListenerBinding(),
                                                                                    EndpointNames.TmsTransactionActorEndpoint);
                }, EndpointNames.TmsTransactionActorEndpoint),

                new ServiceReplicaListener(context =>
                {
                    return new WcfCommunicationListener <INotifyNetworkModelUpdateContract>(context,
                                                                                            this.ceNetworkNotifyModelUpdate,
                                                                                            WcfUtility.CreateTcpListenerBinding(),
                                                                                            EndpointNames.TmsNotifyNetworkModelUpdateEndpoint);
                }, EndpointNames.TmsNotifyNetworkModelUpdateEndpoint),
            });
        }
        public async Task <string> ApplyUpdates(Delta delta)
        {
            Binding binding = WcfUtility.CreateTcpClientBinding(maxMessageSize: 1024 * 1024 * 1024);
            ServicePartitionResolver servicePartitionResolver = new ServicePartitionResolver(() =>
                                                                                             new FabricClient());
            WcfCommunicationClientFactory <INetworkModelGDAContract> communicationClientFactory = new WcfCommunicationClientFactory <INetworkModelGDAContract>(binding, servicePartitionResolver: servicePartitionResolver);

            Uri uri = new Uri("fabric:/LoadFlowApplication/NMSGdaService");
            NetworkModelGdaClient networkModelGdaClient = new NetworkModelGdaClient(communicationClientFactory, uri, new ServicePartitionKey(0));

            string updateResult = "Apply Updates Report:\r\n";

            System.Globalization.CultureInfo culture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            if ((delta != null) && (delta.NumberOfOperations != 0))
            {
                //// NetworkModelService->ApplyUpdates
                //updateResult = GdaQueryProxy.ApplyUpdate(delta).ToString();
                try
                {
                    updateResult = (await networkModelGdaClient.InvokeWithRetryAsync(client => client.Channel.ApplyUpdate(delta))).ToString();
                }
                catch (Exception e)
                {
                    string message = e.Message;
                }
            }

            Thread.CurrentThread.CurrentCulture = culture;
            return(updateResult);
        }
Esempio n. 3
0
        protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners()
        {
            var grpcServices = new[] { GrpcMessageService.BindService(new GrpcMessageServiceImpl(this.Context, ProcessGrpcMessage)) };


            return(new[] {
                //new ServiceReplicaListener(this.CreateServiceRemotingListener, name: "Remoting"),
                new ServiceReplicaListener((ctx) =>
                {
                    //return new FabricTransportServiceRemotingListener(ctx, this, serializationProvider: new ServiceRemotingJsonSerializationProvider());
                    return new FabricTransportServiceRemotingListener(ctx, this);
                }, name: "RemotingV2"),
                new ServiceReplicaListener((ctx) =>
                {
                    return new WcfCommunicationListener <IServiceFour>(
                        wcfServiceObject: this,
                        serviceContext: ctx,
                        endpointResourceName: WcfEndpoint,
                        listenerBinding: WcfUtility.CreateTcpListenerBinding());
                }, name: "WcfTcp"),
                new ServiceReplicaListener((ctx) =>
                {
                    return new WsCommunicationListener(ctx, SocketEndpoint, AppPrefix, this.ProcessWsRequest);
                }, "WebSocket"),
                new ServiceReplicaListener((ctx) => { return new ServiceBusTopicListener(ctx, ProcessTopicMessage, LogError, ServiceBusTopicReceiverType.Performance); }, "PubSub"),
                new ServiceReplicaListener((ctx) => { return new EventHubCommunicationListener(ctx, ProcessEventHubMessage, LogError); }, "EventHub"),
                new ServiceReplicaListener((ctx) => { return new SimpleCommunicationListener(ctx, DotNettySimpleTcpEndpoint, ProcessDotNettyMessage, LogError); }, "DotNettySimpleTcp"),
                new ServiceReplicaListener((ctx) => { return new GrpcCommunicationListener(ctx, grpcServices, LogMessage, GrpcEndpoint); }, "grpc")
            });
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            string hostName = "sfv2.eastus.cloudapp.azure.com";

            Regex ipRex = new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");
            IServicePartitionResolver partitionResolver = new ServicePartitionResolver(hostName + ":19000");
            var binding = WcfUtility.CreateTcpClientBinding();


            var resolveResults = partitionResolver.ResolveAsync(new Uri("fabric:/CalculatorApplication/CalculatorService"),
                                                                ServicePartitionKey.Singleton,
                                                                TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10), new System.Threading.CancellationToken()).Result;

            var endpoint       = resolveResults.GetEndpoint();
            var endpointObject = JsonConvert.DeserializeObject <JObject>(endpoint.Address);
            var addressString  = ((JObject)endpointObject.Property("Endpoints").Value)[""].Value <string>();

            addressString = ipRex.Replace(addressString, hostName, 1);
            var endpointAddress = new EndpointAddress(addressString);
            var channel         = ChannelFactory <ICalculatorService> .CreateChannel(binding, endpointAddress);

            for (int i = 0; i < 10; i++)
            {
                var calculatorServiceCommunicationClient = new WcfCommunicationClient <ICalculatorService>(channel);
                var result = calculatorServiceCommunicationClient.Channel.Add(2, 3).Result;
                Console.WriteLine(result);
            }
        }
        /// <summary>
        /// Optional override to create listeners (e.g., HTTP, Service Remoting, WCF, etc.) for this service replica to handle client or user requests.
        /// </summary>
        /// <remarks>
        /// For more information on service communication, see https://aka.ms/servicefabricservicecommunication
        /// </remarks>
        /// <returns>A collection of listeners.</returns>
        protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners()
        {
            //return new ServiceReplicaListener[0];
            return(new ServiceReplicaListener[]
            {
                //OmsOutageSimulatorEndpoint
                new ServiceReplicaListener(context =>
                {
                    return new WcfCommunicationListener <IOutageSimulatorContract>(context,
                                                                                   this.outageSimulatorProvider,
                                                                                   WcfUtility.CreateTcpListenerBinding(),
                                                                                   EndpointNames.OmsOutageSimulatorEndpoint);
                }, EndpointNames.OmsOutageSimulatorEndpoint),

                //OmsOutageSimulatorUIEndpoint
                new ServiceReplicaListener(context =>
                {
                    return new WcfCommunicationListener <IOutageSimulatorUIContract>(context,
                                                                                     this.outageSimulatorUIProvider,
                                                                                     WcfUtility.CreateTcpListenerBinding(),
                                                                                     EndpointNames.OmsOutageSimulatorUIEndpoint);
                }, EndpointNames.OmsOutageSimulatorUIEndpoint),

                //PubSubNotifySubscriberEndpoint
                new ServiceReplicaListener(context =>
                {
                    return new WcfCommunicationListener <INotifySubscriberContract>(context,
                                                                                    this.notifySubscriberProvider,
                                                                                    WcfUtility.CreateTcpListenerBinding(),
                                                                                    EndpointNames.PubSubNotifySubscriberEndpoint);
                }, EndpointNames.PubSubNotifySubscriberEndpoint),
            });
        }
Esempio n. 6
0
        public WcfPazienti.PazienteType GetDataById(WcfPazienti.TokenType Token, Guid Id)
        {
            this.CacheDataKey = $"{typeof(WcfPazienti.PazienteType).Name}_{Id}";

            WcfPazienti.PazienteType pazienteType = null;

            // Cerco prima nella cache
            pazienteType = this.CacheData;
            if (pazienteType == null)
            {
                WcfPazienti.PazientiClient wcf = new WcfPazienti.PazientiClient();
                using (wcf)
                {
                    WcfUtility.SetCredentials(wcf);

                    WcfPazienti.PazienteReturn pazienteReturn = wcf.PazienteOttieniPerId(Token, Id);

                    //controllo che non ci siano errori
                    if (pazienteReturn == null || pazienteReturn.Paziente == null || pazienteReturn.Errore != null)
                    {
                        Serilog.Log.Error($"Si è verificato un errore durante la lettura del paziente con id: {Id}");
                        throw new Exception($"PazienteReturn = null per id: {Id}");
                    }
                    else
                    {
                        pazienteType = pazienteReturn.Paziente;

                        //Salvo in Cache
                        this.CacheData = pazienteType;
                    }
                }
            }

            return(pazienteType);
        }
Esempio n. 7
0
        private ICommunicationListener CreateWCFListenerForPlatformAuthentication(StatelessServiceContext context)
        {
            var servicePath     = "Platform/Authentication";
            var serviceUri      = String.Format("net.tcp://{0}:{1}/Services/{2}", wcfDomain, listenerPort, servicePath);
            var metaExchangeUri = String.Format("net.tcp://{0}:{1}/Services/{2}/mex", wcfDomain, metaExchangePort, servicePath);

            var bindings = WcfUtility.CreateTcpListenerBinding(maxMessageSize: 2500000); //<-- Set to 2.5mb for larger packages

            //((System.ServiceModel.NetTcpBinding)binding).MaxReceivedMessageSize = 6000000 <-- Cast as System.ServiceModel.NetTcpBinding to access other properties

            var listener = new WcfCommunicationListener <IPlatformAuthenticationService>(
                context,
                new PlatformAuthenticationService(),
                bindings,
                new EndpointAddress(serviceUri));
            ServiceMetadataBehavior metaDataBehavior = new ServiceMetadataBehavior();

            listener.ServiceHost.Description.Behaviors.Add(metaDataBehavior);

            Binding mexBinding = MetadataExchangeBindings.CreateMexTcpBinding();

            listener.ServiceHost.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, metaExchangeUri, new Uri(metaExchangeUri));

            listener.ServiceHost.Description.Behaviors.Remove(typeof(ServiceDebugBehavior));
            listener.ServiceHost.Description.Behaviors.Add(new ServiceDebugBehavior {
                IncludeExceptionDetailInFaults = true
            });

            return(listener);
        }
        static void Main(string[] args)
        {
            Uri serviceUri = new Uri("fabric:/SimpleStoreApplication/ShoppingCartService");

            Binding binding = WcfUtility.CreateTcpClientBinding();
            IServicePartitionResolver partitionResolver = new ServicePartitionResolver(() => new FabricClient());

            for (int customerId = 0; customerId < 10; customerId++)
            {
                Client shoppingClient = new Client(
                    new WcfCommunicationClientFactory <IShoppingCartService>(binding, null, partitionResolver),
                    serviceUri,
                    customerId);

                shoppingClient.AddItem(new ShoppingCartItem
                {
                    ProductName = "XBOX ONE",
                    UnitPrice   = 329.0,
                    Amount      = 2
                }).Wait();

                PrintPartition(shoppingClient);

                var list = shoppingClient.GetItems().Result;
                foreach (var item in list)
                {
                    Console.WriteLine($"{item.ProductName}: {item.UnitPrice:C2} x {item.Amount} = {item.LineTotal:C2}");
                }
            }

            Console.ReadKey();
        }
Esempio n. 9
0
        public static TResult Invoke <TResult>(Func <WcfCommunicationClient <T>, TResult> method, string serviceName)
        {
            lock (locker)
            {
                factory = new WcfCommunicationClientFactory <T>(clientBinding: WcfUtility.CreateTcpClientBinding(),
                                                                servicePartitionResolver: new ServicePartitionResolver());
                proxy = new ServicePartitionClient <WcfCommunicationClient <T> >(
                    communicationClientFactory: factory,
                    serviceUri: ServiceFabricManager.ServiceFabricMapper[serviceName].ServiceFabricUri,
                    listenerName: ServiceFabricManager.ServiceFabricMapper[serviceName].ContractListenerMapper[typeof(T)]);

                try
                {
                    var result = proxy.InvokeWithRetry(method);
                    return(result);
                }
                catch (TimeoutException e)
                {
                    Trace.TraceError("WCF Client Timeout Exception " + e.Message);
                    throw;
                }
                catch (CommunicationException e)
                {
                    Trace.TraceError("WCF Client Communication Exception " + e.Message);
                    throw;
                }
                catch (Exception e)
                {
                    Trace.TraceError("WCF Client Exception " + e.Message);
                    throw;
                }
            }
        }
        private static void CallCloud()
        {
            var binding           = WcfUtility.CreateTcpClientBinding();
            var partitionResolver = new ServicePartitionResolver("ilrprocessingsfpoc.uksouth.cloudapp.azure.com:777", "ilrprocessingsfpoc.uksouth.cloudapp.azure.com:19000");
            var wcfClientFactory  =
                new WcfCommunicationClientFactory <IValidationServiceStateful>(binding,
                                                                               servicePartitionResolver: partitionResolver);
            var serviceUri = new Uri("fabric:/DCT.ILR.Processing.POC/DCT.ILR.VadationServiceStateful");
            var client     = new ValidationServiceClient(wcfClientFactory, serviceUri, new ServicePartitionKey(LongRandom()));

            var resolved = partitionResolver.ResolveAsync(new Uri("fabric:/DCT.ILR.Processing.POC/DCT.ILR.VadationServiceStateful"),
                                                          new ServicePartitionKey(9223372036854775807), CancellationToken.None).Result;

            do
            {
                var correlationId = Guid.NewGuid();
                Console.WriteLine(client.Validation(new Models.Models.IlrContext()
                {
                    CorrelationId      = correlationId,
                    ContainerReference = "ilr-files",
                    Filename           = "ILR-10006341-1718-20171107-113456-01.xml",
                    //Filename = "ILR-10006148-1718-20170203-144336-03.xml",
                    IsShredAndProcess = false
                }).Result);
                Console.ReadKey();
            } while (true);
        }
        static async Task Main(string[] args)
        {
            if (args == null || !args.Any())
            {
                Console.WriteLine("Debe especificar el identificador del producto");
                return;
            }

            var id         = args[0];
            var serviceUri = new Uri("fabric:/LinkedInLearning/Products");

            var binding = WcfUtility.CreateTcpClientBinding();

            var servicePartitionResolver = ServicePartitionResolver.GetDefault();

            var wcfCommunicationClientFactory = new WcfCommunicationClientFactory <IProductsService>(binding, null, servicePartitionResolver);

            var servicePartitionClient = new ServicePartitionClient <WcfCommunicationClient <IProductsService> >(wcfCommunicationClientFactory, serviceUri);

            Console.WriteLine($"Consultando {id} ...");

            var result = await servicePartitionClient.InvokeWithRetryAsync(client => client.Channel.GetProductAsync(id));

            Console.WriteLine($"{result.Id} {result.Nombre}");
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            Uri serviceUri = new Uri("fabric:/SimpleStoreApplication/ShoppingCartService");
            IServicePartitionResolver serviceResolver = ServicePartitionResolver.GetDefault();
            Binding binding          = WcfUtility.CreateTcpClientBinding();
            var     wcfClientFactory =
                new WcfCommunicationClientFactory <IShoppingCartService>(
                    clientBinding: binding, servicePartitionResolver: serviceResolver);

            for (int i = 1; i <= 3; i++)
            {
                // var shoppingClient = new Client(wcfClientFactory, serviceUri, i);
                var shoppingClient = new Client(wcfClientFactory, serviceUri, "Customer " + i);

                shoppingClient.AddItem(new ShoppingCartItem
                {
                    ProductName = "XBOX ONE",
                    UnitPrice   = 329.0,
                    Amount      = 2
                }).Wait();

                PrintPartition(shoppingClient);

                var list = shoppingClient.GetItems().Result;
                foreach (var item in list)
                {
                    Console.WriteLine(string.Format("{0}: {1:C2} X {2} = {3:C2}",
                                                    item.ProductName,
                                                    item.UnitPrice,
                                                    item.Amount,
                                                    item.LineTotal));
                }
            }
            Console.ReadKey();
        }
 /// <summary>
 ///     Creates a V2 service remoting listener for remoting the actor interfaces.
 /// </summary>
 /// <param name="actorService">
 ///     The implementation of the actor service that hosts the actors whose interfaces
 ///     needs to be remoted.
 /// </param>
 /// <returns>
 ///     An <see cref="IServiceRemotingListener"/>
 ///     for the specified actor service.
 /// </returns>
 public override IServiceRemotingListener CreateServiceRemotingListenerV2(ActorService actorService)
 {
     return(new Actors.Remoting.V2.Wcf.Runtime.WcfActorServiceRemotingListener(
                actorService,
                WcfUtility.CreateTcpListenerBinding(
                    maxMessageSize: this.GetMaxMessageSize(),
                    openTimeout: this.GetOpenTimeout(),
                    closeTimeout: this.GetCloseTimeout())));
 }
 private static ICommunicationListener CreateTcpListener(IRedisConnectionService service, StatelessServiceContext context)
 {
     return(new WcfCommunicationListener <IRedisConnectionService>(
                wcfServiceObject: service,
                serviceContext: context,
                endpointResourceName: "RedisConnectionService",
                listenerBinding: WcfUtility.CreateTcpListenerBinding()
                ));
 }
Esempio n. 15
0
 /// <summary>
 ///     Creates a V1 service remoting client factory that can be used by the
 ///     <see cref="Microsoft.ServiceFabric.Services.Remoting.Client.ServiceProxyFactory"/>
 ///     to create a proxy for the remoted interface of the service.
 /// </summary>
 /// <param name="callbackClient">
 ///     Client implementation where the callbacks should be dispatched.
 /// </param>
 /// <returns>
 ///     A <see cref="Microsoft.ServiceFabric.Services.Remoting.V1.Wcf.Client.WcfServiceRemotingClientFactory"/>.
 /// </returns>
 public override V1.Client.IServiceRemotingClientFactory CreateServiceRemotingClientFactory(
     V1.IServiceRemotingCallbackClient callbackClient)
 {
     return(new V1.Wcf.Client.WcfServiceRemotingClientFactory(
                WcfUtility.CreateTcpClientBinding(
                    this.GetMaxMessageSize(),
                    this.GetOpenTimeout(),
                    this.GetCloseTimeout()),
                callbackClient));
 }
Esempio n. 16
0
 /// <summary>
 ///     Creates a service remoting client factory to connect to the remoted actor interfaces.
 /// </summary>
 /// <param name="callbackClient">
 ///     Client implementation where the callbacks should be dispatched.
 /// </param>
 /// <returns>
 ///     A <see cref="Microsoft.ServiceFabric.Services.Remoting.Wcf.Client.WcfServiceRemotingClientFactory"/>
 ///     as <see cref="Microsoft.ServiceFabric.Services.Remoting.Client.IServiceRemotingClientFactory"/>
 ///     that can be used with <see cref="Microsoft.ServiceFabric.Actors.Client.ActorProxyFactory"/> to
 ///     generate actor proxy to talk to the actor over remoted actor interface.
 /// </returns>
 public override IServiceRemotingClientFactory CreateServiceRemotingClientFactory(
     IServiceRemotingCallbackClient callbackClient)
 {
     return(new WcfActorRemotingClientFactory(
                WcfUtility.CreateTcpClientBinding(
                    maxMessageSize: this.GetMaxMessageSize(),
                    openTimeout: this.GetOpenTimeout(),
                    closeTimeout: this.GetCloseTimeout()),
                callbackClient));
 }
Esempio n. 17
0
 /// <summary>
 ///     Creates a service remoting client factory that can be used by the
 ///     <see cref="Microsoft.ServiceFabric.Services.Remoting.Client.ServiceProxyFactory"/>
 ///     to create a proxy for the remoted interface of the service.
 /// </summary>
 /// <param name="callbackMessageHandler">
 ///     Client implementation where the callbacks should be dispatched.
 /// </param>
 /// <returns>
 ///     A <see cref="Microsoft.ServiceFabric.Services.Remoting.V2.Wcf.Client.WcfServiceRemotingClientFactory"/>.
 /// </returns>
 public override V2.Client.IServiceRemotingClientFactory CreateServiceRemotingClientFactoryV2(
     IServiceRemotingCallbackMessageHandler callbackMessageHandler)
 {
     return(new Services.Remoting.V2.Wcf.Client.WcfServiceRemotingClientFactory(
                WcfUtility.CreateTcpClientBinding(
                    this.GetMaxMessageSize(),
                    this.GetOpenTimeout(),
                    this.GetCloseTimeout()),
                callbackMessageHandler));
 }
Esempio n. 18
0
        private WcfClient <IFEPServiceAsync> BuildClient()
        {
            Binding binding = WcfUtility.CreateTcpClientBinding();
            IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault();
            var wcfClientFactory = new WcfCommunicationClientFactory <IFEPServiceAsync>(clientBinding: binding, servicePartitionResolver: partitionResolver);
            var ServiceUri       = new Uri(_uri);
            var client           = new WcfClient <IFEPServiceAsync>(wcfClientFactory, ServiceUri);

            return(client);
        }
 /// <summary>
 ///     Creates a service remoting client factory to connect to the remoted actor interfaces.
 /// </summary>
 /// <param name="callbackClient">
 ///     Client implementation where the callbacks should be dispatched.
 /// </param>
 /// <returns>
 ///     A <see cref="Microsoft.ServiceFabric.Actors.Remoting.V1.Wcf.Client.WcfActorRemotingClientFactory"/>
 ///     as <see cref="Microsoft.ServiceFabric.Services.Remoting.V1.Client.IServiceRemotingClientFactory"/>
 ///     that can be used with <see cref="ActorProxyFactory"/> to
 ///     generate actor proxy to talk to the actor over remoted actor interface.
 /// </returns>
 public override Microsoft.ServiceFabric.Services.Remoting.V1.Client.IServiceRemotingClientFactory CreateServiceRemotingClientFactory(
     Microsoft.ServiceFabric.Services.Remoting.V1.IServiceRemotingCallbackClient callbackClient)
 {
     return(new Microsoft.ServiceFabric.Actors.Remoting.V1.Wcf.Client.WcfActorRemotingClientFactory(
                WcfUtility.CreateTcpClientBinding(
                    maxMessageSize: this.GetMaxMessageSize(),
                    openTimeout: this.GetOpenTimeout(),
                    closeTimeout: this.GetCloseTimeout()),
                callbackClient));
 }
Esempio n. 20
0
        private WcfClient <IScadaStorageService> BuildClient()
        {
            Binding binding = WcfUtility.CreateTcpClientBinding();
            IServicePartitionResolver partitionResolver = ServicePartitionResolver.GetDefault();
            var wcfClientFactory = new WcfCommunicationClientFactory <IScadaStorageService>(clientBinding: binding, servicePartitionResolver: partitionResolver);
            var ServiceUri       = new Uri(_uri);
            var client           = new WcfClient <IScadaStorageService>(wcfClientFactory, ServiceUri, new Microsoft.ServiceFabric.Services.Client.ServicePartitionKey(1));

            return(client);
        }
Esempio n. 21
0
 protected override IEnumerable <ServiceInstanceListener> CreateServiceInstanceListeners()
 {
     return(new[]
     {
         new ServiceInstanceListener(context => new WcfCommunicationListener <ICalculatorService>(
                                         serviceContext: context,
                                         wcfServiceObject: this,
                                         listenerBinding: WcfUtility.CreateTcpListenerBinding(),
                                         endpointResourceName: "ServiceEndpoint"))
     });
 }
Esempio n. 22
0
        private ICommunicationListener CreateHiCommunicationListener(StatefulServiceContext context)
        {
            var listener = new WcfCommunicationListener <IHiContract>(
                wcfServiceObject: new Hi(),
                serviceContext: context,
                endpointResourceName: "HiEndpoint",
                listenerBinding: WcfUtility.CreateTcpListenerBinding()
                );

            return(listener);
        }
Esempio n. 23
0
        private ICommunicationListener CreateDuplexListener(StatelessServiceContext context)
        {
            var listener = new WcfCommunicationListener <IDuplexContract>(
                wcfServiceObject: new WcfDuplexImplementation(),
                serviceContext: context,
                endpointResourceName: "WCFDuplexEndpoint",
                listenerBinding: WcfUtility.CreateTcpListenerBinding()
                );

            return(listener);
        }
Esempio n. 24
0
 /// <summary>
 ///     Creates a V2 service remoting listener for remoting the service interface.
 /// </summary>
 /// <param name="serviceContext">
 ///     The context of the service for which the remoting listener is being constructed.
 /// </param>
 /// <param name="serviceImplementation">
 ///     The service implementation object.
 /// </param>
 /// <returns>
 ///     A <see cref=" V2.Wcf.Runtime.WcfServiceRemotingListener"/> for the specified service.
 /// </returns>
 public override IServiceRemotingListener CreateServiceRemotingListenerV2(
     ServiceContext serviceContext, IService serviceImplementation)
 {
     return(new V2.Wcf.Runtime.WcfServiceRemotingListener(
                serviceContext,
                serviceImplementation,
                WcfUtility.CreateTcpListenerBinding(
                    this.GetMaxMessageSize(),
                    this.GetOpenTimeout(),
                    this.GetCloseTimeout())));
 }
 CreateServiceInstanceListeners()
 {
     return(new[]
     {
         new ServiceInstanceListener(context =>
                                     new WcfCommunicationListener <ICalculatorService>(
                                         wcfServiceObject: this,
                                         serviceContext: context,
                                         endpointResourceName: "ServiceEndpoint",
                                         listenerBinding: WcfUtility.CreateTcpListenerBinding()))
     });
 }
Esempio n. 26
0
 /// <summary>
 /// Optional override to create listeners (e.g., HTTP, Service Remoting, WCF, etc.) for this service replica to handle client or user requests.
 /// </summary>
 /// <remarks>
 /// For more information on service communication, see https://aka.ms/servicefabricservicecommunication
 /// </remarks>
 /// <returns>A collection of listeners.</returns>
 protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners()
 {
     return(new[]
     {
         new ServiceReplicaListener(context =>
                                    new WcfCommunicationListener <IShoppingCartService>(
                                        wcfServiceObject: this,
                                        serviceContext: context,
                                        endpointResourceName: "ServiceEndpoint",
                                        listenerBinding: WcfUtility.CreateTcpListenerBinding()))
     });
 }
        static void Main(string[] args)
        {
            Uri serviceUri = new Uri("fabric:/CalculatorApplication3/CalculatorService");
            IServicePartitionResolver serviceResolver = ServicePartitionResolver.GetDefault();
            Binding binding          = WcfUtility.CreateTcpClientBinding();
            var     wcfClientFactory = new WcfCommunicationClientFactory <ICalculatorService>(
                clientBinding: binding, servicePartitionResolver: serviceResolver);
            var calcClient = new Client(wcfClientFactory, serviceUri);

            Console.WriteLine(calcClient.Add(3, 5).Result);
            Console.ReadKey();
        }
Esempio n. 28
0
 /// <summary>
 /// Optional override to create listeners (e.g., HTTP, Service Remoting, WCF, etc.) for this service replica to handle client or user requests.
 /// </summary>
 /// <remarks>
 /// For more information on service communication, see https://aka.ms/servicefabricservicecommunication
 /// </remarks>
 /// <returns>A collection of listeners.</returns>
 protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners()
 {
     return(new List <ServiceReplicaListener>()
     {
         new ServiceReplicaListener(context =>
         {
             return new WcfCommunicationListener <INotifySubscriberContract>(context,
                                                                             this.callTracker,
                                                                             WcfUtility.CreateTcpListenerBinding(),
                                                                             EndpointNames.PubSubNotifySubscriberEndpoint);
         }, EndpointNames.PubSubNotifySubscriberEndpoint)
     });
 }
Esempio n. 29
0
 /// <summary>
 /// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests.
 /// </summary>
 /// <returns>A collection of listeners.</returns>
 protected override IEnumerable <ServiceReplicaListener> CreateServiceReplicaListeners()
 {
     return(new List <ServiceReplicaListener>
     {
         new ServiceReplicaListener(context =>
         {
             return new WcfCommunicationListener <ITopologyAnalyzer>(context,
                                                                     this,
                                                                     WcfUtility.CreateTcpListenerBinding(),
                                                                     endpointResourceName: "TopologyAnalyzerServiceEndpoint");
         }, "TopologyAnalyzerServiceEndpoint")
     });
 }
Esempio n. 30
0
		/// <summary>
		/// Optional override to create listeners (e.g., TCP, HTTP) for this service replica to handle client or user requests.
		/// </summary>
		/// <returns>A collection of listeners.</returns>
		protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
		{
			return new List<ServiceInstanceListener>(1)
			{
				new ServiceInstanceListener(context =>
				{
					 return new WcfCommunicationListener<ILoadFlowContract>(context,
																			   this.loadFlowEngine,
																			   WcfUtility.CreateTcpListenerBinding(),
																			   EndpointNames.CeLoadFlowServiceEndpoint);
				}, EndpointNames.CeLoadFlowServiceEndpoint)
			};
		}