/// <summary>
 /// Creates a new default instance.
 /// </summary>
 public BrokerServiceLocator(Uri brokerServiceUri = null, IHashingHelper hashingHelper = null, IProxyFactories proxyFactories = null)
 {
     _hashingHelper    = hashingHelper ?? new HashingHelper();
     _fabricClient     = new FabricClient();
     _proxyFactories   = proxyFactories ?? new ProxyFactories();
     _brokerServiceUri = brokerServiceUri;
 }
示例#2
0
 public override Task PublishAsync(MessageWrapper message, IProxyFactories proxyFactories)
 {
     if (_isBroken)
     {
         throw new Exception("The subscriber threw an exception");
     }
     return(Task.CompletedTask);
 }
示例#3
0
        /// <inheritdoc />
        public override Task PublishAsync(MessageWrapper message, IProxyFactories proxyFactories)
        {
            if (ShouldDeliverMessage(message))
            {
                var client = proxyFactories.CreateServiceProxy <ISubscriberService>(ServiceReference);

                return(client.ReceiveMessageAsync(message));
            }

            return(Task.FromResult(true));
        }
示例#4
0
        /// <inheritdoc />
        public override Task PublishAsync(MessageWrapper message, IProxyFactories proxyFactories)
        {
            if (ShouldDeliverMessage(message))
            {
                var actor = proxyFactories.CreateActorProxy <ISubscriberActor>(ActorReference);

                return(actor.ReceiveMessageAsync(message));
            }

            return(Task.FromResult(true));
        }
        /// <summary>
        /// Creates a new instance using the provided context and registers this instance for automatic discovery if needed.
        /// </summary>
        /// <param name="serviceContext"></param>
        /// <param name="enableAutoDiscovery"></param>
        /// <param name="brokerEventsManager"></param>
        protected BrokerService(StatefulServiceContext serviceContext, bool enableAutoDiscovery = true, IBrokerEventsManager brokerEventsManager = null, IProxyFactories proxyFactories = null)
            : base(serviceContext)
        {
            if (enableAutoDiscovery)
            {
                new BrokerServiceLocator(Context.ServiceName).RegisterAsync()
                .ConfigureAwait(false)
                .GetAwaiter()
                .GetResult();
            }

            _brokerEventsManager = brokerEventsManager ?? new DefaultBrokerEventsManager();
            _subscriptionFactory = new SubscriptionFactory(StateManager);
            _proxyFactories      = proxyFactories ?? new ProxyFactories();
        }
示例#6
0
 public async Task DeliverMessageAsync(MessageWrapper messageWrapper, IProxyFactories proxyFactories)
 {
     await SubscriptionDetails.ServiceOrActorReference.PublishAsync(messageWrapper, proxyFactories);
 }
 /// <summary>
 /// Attempts to publish the message to a listener.
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public abstract Task PublishAsync(MessageWrapper message, IProxyFactories proxyFactories);