• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SubscriptionClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SubscriptionClient的典型用法代码示例。如果您正苦于以下问题:C# SubscriptionClient类的具体用法?C# SubscriptionClient怎么用?C# SubscriptionClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SubscriptionClient类属于命名空间,在下文中一共展示了SubscriptionClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Init

        public async void Init(MessageReceived messageReceivedHandler) {
            this.random = new Random();

            //ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect;
            
            // Tcp mode does not work when I run in a VM (VirtualBox) and the host 
            // is using a wireless connection. Hard coding to Http.
            ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;

            string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            this.factory = MessagingFactory.CreateFromConnectionString(connectionString);
            this.namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            if (!namespaceManager.TopicExists(topicName)) {
                namespaceManager.CreateTopic(topicName);
            }

            this.subscriptionName = Guid.NewGuid().ToString();

            // Not needed really, it's a GUID...
            if (!namespaceManager.SubscriptionExists(topicName, subscriptionName)) {
                namespaceManager.CreateSubscription(topicName, subscriptionName);
            }

            this.topicClient = factory.CreateTopicClient(topicName);

            this.subClient = factory.CreateSubscriptionClient(topicName, subscriptionName);

            while (true) {
                await ReceiveMessageTaskAsync(messageReceivedHandler);
            }
        }
开发者ID:DonKarlssonSan,项目名称:CumulusChat,代码行数:32,代码来源:ChatApplication.cs


示例2: InitialiseTopic

        public void InitialiseTopic()
        {
            ServicePointManager.DefaultConnectionLimit = 12;

            string connectionString = CloudConfigurationManager.GetSetting("ServiceBus.TopicConnectionString");
            _topicClient = SubscriptionClient.CreateFromConnectionString(connectionString, "recreateindex", "WebRoles");

            Task.Run(() =>
            {
                _topicClient.OnMessage(async receivedMessage =>
                {
                    var sequenceNumber = receivedMessage.SequenceNumber;
                    try
                    {
                        await _throttling.Execute(async () => ReCreateSearcher());
                    }
                    catch (Exception ex)
                    {
                        //no idea why it does not work but well, log it
                        Trace.TraceWarning("Exception occurred during the read of message '" + sequenceNumber + "': " + ex.Message);
                    }
                }, new OnMessageOptions {
                    AutoComplete = true
                });

                _completedEvent.WaitOne();
            });
        }
开发者ID:robstoll,项目名称:farmfinder,代码行数:28,代码来源:Global.asax.cs


示例3: InitServiceBusConnection

        private void InitServiceBusConnection()
        {
            string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");

            // Initialize clients
            _client = SubscriptionClient.CreateFromConnectionString(connectionString, "channel_sava", "twitter_follower_email");
        }
开发者ID:varadzhakov,项目名称:work,代码行数:7,代码来源:WorkerRole.cs


示例4: ReliableSubscriptionClient

 public ReliableSubscriptionClient(string sbNamespace, TokenProvider tokenProvider, string path, string name, RetryPolicy<ServiceBusTransientErrorDetectionStrategy> policy)
     : base(sbNamespace, tokenProvider, path, policy)
 {
     //create the queue if it doesn't exist
     bool needsCreation = false;
     try
     {
         needsCreation = !mRetryPolicy.ExecuteAction<bool>(() => mNamespaceManager.SubscriptionExists(path,name));
     }
     catch (MessagingEntityNotFoundException)
     {
         needsCreation = true;
     }
     if (needsCreation)
     {
         try
         {
             mRetryPolicy.ExecuteAction<SubscriptionDescription>(() => mNamespaceManager.CreateSubscription(path,name));
         }
         catch (MessagingEntityAlreadyExistsException)
         {
             //ignore this exception because queue already exists
         }
     }
     mRetryPolicy.ExecuteAction(() => mSubscriptionClient = mMessagingFactory.CreateSubscriptionClient(path,name));
 }
开发者ID:HaishiBai,项目名称:ReliableServiceBusClients,代码行数:26,代码来源:ReliableSubscriptionClient.cs


示例5: Initialize

 public static void Initialize()
 {
     if (null == OrdersTopicClient)
     {
         try
         {
             string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBusTopics.ConnectionString");
             // string connectionString = RoleEnvironment.GetConfigurationSettingValue("Microsoft.ServiceBusTopics.ConnectionString");
             var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
             if (!namespaceManager.TopicExists("OrderTopic"))
             {
                 namespaceManager.CreateTopic("OrderTopic");
             }
             if (!namespaceManager.SubscriptionExists("OrderTopic", "OrderMessages"))
             {
                 namespaceManager.CreateSubscription("OrderTopic", "OrderMessages");
             }
             // Initialize the connection to Service Bus Topics
             OrdersTopicClient = TopicClient.CreateFromConnectionString(connectionString, "OrderTopic");
             SubClient = SubscriptionClient.CreateFromConnectionString(connectionString, "OrderTopic", "OrderMessages");
            
         }
         catch (Exception ex)
         {
             string str = ex.Message;
         }
     }
 }
开发者ID:Kgabo707,项目名称:azure-guidance,代码行数:28,代码来源:ServiceBusTopicHelper.cs


示例6: OnStart

        public override bool OnStart()
        {
            ServicePointManager.DefaultConnectionLimit = 12;

            var connectionString = CloudConfigurationManager.GetSetting("topicConnectionString");
            var topicName = CloudConfigurationManager.GetSetting("topicName");

            _nsMgr = NamespaceManager.CreateFromConnectionString(connectionString);

            if (!_nsMgr.TopicExists(topicName))
            {
                _nsMgr.CreateTopic(topicName);
            }

            if (!_nsMgr.SubscriptionExists(topicName, "audit"))
            {
                _nsMgr.CreateSubscription(topicName, "audit");
            }

            _client = SubscriptionClient.CreateFromConnectionString(connectionString, topicName, "audit", ReceiveMode.ReceiveAndDelete);

            var result = base.OnStart();

            Trace.TraceInformation("NTM.Auditing has been started");

            return result;
        }
开发者ID:jplane,项目名称:AzureATLMeetup,代码行数:27,代码来源:WorkerRole.cs


示例7: GetSubscriptionClient

        private async Task<SubscriptionClient> GetSubscriptionClient()
        {
            if (_subscriptionClient != null) return _subscriptionClient;

            _subscriptionClient = await _queueManager.CreateSubscriptionReceiver(_topicPath, _subscriptionName);
            _subscriptionClient.PrefetchCount = ConcurrentHandlerLimit;
            return _subscriptionClient;
        }
开发者ID:Joshscorp,项目名称:Nimbus,代码行数:8,代码来源:NimbusSubscriptionMessageReceiver.cs


示例8: GetSubscriptionClient

        private async Task<SubscriptionClient> GetSubscriptionClient()
        {
            if (_subscriptionClient != null) return _subscriptionClient;

            _subscriptionClient = await _queueManager.CreateSubscriptionReceiver(_topicPath, _subscriptionName);
            _subscriptionClient.PrefetchCount = _prefetchCountSetting;
            return _subscriptionClient;
        }
开发者ID:Royal-Jay,项目名称:Zombus,代码行数:8,代码来源:OnReceiveSubscriptionMessageReceiver.cs


示例9: Create

		public SubscriptionObserver Create(IServiceBus bus, SubscriptionRouter router)
		{
			string path = bus.ControlBus.Endpoint.Address.Uri.AbsolutePath;


			var client = new SubscriptionClient(bus, router, _subscriptionServiceUri, _timeout);

			return client;
		}
开发者ID:vinayreddym,项目名称:MassTransit,代码行数:9,代码来源:SubscriptionClientConfiguratorImpl.cs


示例10: CanUnregisterProviderIfRegistered

        public void CanUnregisterProviderIfRegistered()
        {
            var mockHandler = CreateMockHandler(() => CreateResponseMessageWithStatus(HttpStatusCode.OK));

            ISubscriptionClient client = new SubscriptionClient(subscriptionData, mockHandler);
            bool worked = client.UnregisterResourceType("someResource");

            Assert.IsTrue(worked);
        }
开发者ID:Viachaslau,项目名称:azure-sdk-tools,代码行数:9,代码来源:SubscriptionsClientTest.cs


示例11: Subscribe

        public async Task Subscribe(Subscriber subscriber, MessageType messageType, ContextBag context)
        {
            //When the subscriber is running V6 and UseLegacyMessageDrivenSubscriptionMode is enabled at the subscriber the 'subcriber.Endpoint' value is null
            var endpoint = subscriber.Endpoint ?? subscriber.TransportAddress.Split('@').First();
            var subscriptionClient = new SubscriptionClient { TransportAddress = subscriber.TransportAddress, Endpoint = endpoint };

            var attempts = 0;

            //note: since we have a design that can run into concurrency exceptions we perform a few retries
            // we should redesign this in the future to use a separate doc per subscriber and message type
            do
            {
                try
                {
                    using (var session = OpenAsyncSession())
                    {
                        var subscriptionDocId = Subscription.FormatId(messageType);

                        var subscription = await session.LoadAsync<Subscription>(subscriptionDocId).ConfigureAwait(false);

                        if (subscription == null)
                        {
                            subscription = new Subscription
                            {
                                Id = subscriptionDocId,
                                MessageType = messageType,
                                Subscribers = new List<SubscriptionClient>()
                            };

                            await session.StoreAsync(subscription).ConfigureAwait(false);
                        }

                        if (!subscription.Subscribers.Contains(subscriptionClient))
                        {
                            subscription.Subscribers.Add(subscriptionClient);
                        }
                        else
                        {
                            var savedSubscription = subscription.Subscribers.Single(s => s.Equals(subscriptionClient));
                            if (savedSubscription.Endpoint != subscriber.Endpoint)
                            {
                                savedSubscription.Endpoint = subscriber.Endpoint;
                            }
                        }

                        await session.SaveChangesAsync().ConfigureAwait(false);
                    }

                    return;
                }
                catch (ConcurrencyException)
                {
                    attempts++;
                }
            } while (attempts < 5);
        }
开发者ID:areicher,项目名称:NServiceBus.RavenDB,代码行数:56,代码来源:SubscriptionPersister.cs


示例12: DiscardSubscriptionClient

        private void DiscardSubscriptionClient()
        {
            var subscriptionClient = _subscriptionClient;
            _subscriptionClient = null;

            if (subscriptionClient == null) return;
            if (subscriptionClient.IsClosed) return;

            subscriptionClient.Close();
        }
开发者ID:Royal-Jay,项目名称:Zombus,代码行数:10,代码来源:OnReceiveSubscriptionMessageReceiver.cs


示例13: Start

        /// <summary>
        /// 
        /// </summary>
        /// <param name="address"></param>
        /// <param name="tryProcessMessage"></param>
        public void Start(Address address, Action<BrokeredMessage> tryProcessMessage)
        {
            _cancelRequested = false;

            _tryProcessMessage = tryProcessMessage;

            _subscriptionClient = SubscriptionClientCreator.Create(address, EventType);

            if (_subscriptionClient != null) _subscriptionClient.BeginReceiveBatch(BatchSize, TimeSpan.FromSeconds(ServerWaitTime), OnMessage, null);
        }
开发者ID:afyles,项目名称:NServiceBus,代码行数:15,代码来源:AzureServiceBusTopicNotifier.cs


示例14: AzureServiceBusEventDispatcherReceiver

        public AzureServiceBusEventDispatcherReceiver(string connectionString, IEventDispatcher innerEventDispatcher, IEventStore eventStore, string topicName, string subscriptionName)
        {
            _innerEventDispatcher = innerEventDispatcher;
            _eventStore = eventStore;

            AzureHelpers.EnsureTopicExists(connectionString, topicName);
            AzureHelpers.EnsureSubscriptionExists(connectionString, topicName, subscriptionName);

            _subscriptionClient = SubscriptionClient.CreateFromConnectionString(connectionString, topicName, subscriptionName);

            _workerThread = new Thread(DoWork);
        }
开发者ID:RichieYang,项目名称:Cirqus,代码行数:12,代码来源:AzureServiceBusEventDispatcherReceiver.cs


示例15: CanGetListOfRegisteredProviders

        public void CanGetListOfRegisteredProviders()
        {
            string[] knownResourceTypes = {"website", "mobileservice"};

            var mockHandler = CreateMockHandler(() => CreateListResourcesResponseMessage(
                new ProviderResource {Type = "Website", State = "Unregistered"},
                new ProviderResource {Type = "Mobileservice", State = "Registered"}
                ));

            ISubscriptionClient client = new SubscriptionClient(subscriptionData, mockHandler);
            IEnumerable<ProviderResource> actualResourceTypes = client.ListResources(knownResourceTypes);

            CollectionAssert.AreEquivalent(knownResourceTypes, actualResourceTypes.Select(rt => rt.Type.ToLower()).ToList());
        }
开发者ID:Viachaslau,项目名称:azure-sdk-tools,代码行数:14,代码来源:SubscriptionsClientTest.cs


示例16: QueueCacheDependency

        //private SubscriptionClient _subscriptionClient = null;
        //private string _entityPath = null;
        //public QueueCacheDependency(string key, string guid, TokenProvider tokenProvider, Uri uri, string queueName)
        //{
        //    _key = key;
        //    _guid = guid;
        //    //_tokenProvider = tokenProvider;
        //    //_uri = uri;
        //    //_entityPath = entityPath;
        //    var factory = MessagingFactory.Create(uri, tokenProvider);
        //    _receiver = factory.CreateMessageReceiver(queueName);
        //    WaitCallback callback = new WaitCallback(WaitForMessage);
        //    ThreadPool.QueueUserWorkItem(callback);
        //}
        public QueueCacheDependency(string key, SubscriptionClient subscriptionClient, string crc)
        {
            Trace.TraceInformation("QueueCacheDependency created: {0}", key);
            //_subscriptionClient = subscriptionClient;
            //_guid = guid;
            _key = key;
            _crc = crc;

            subscriptionClient.BeginReceive(
                TimeSpan.MaxValue,
                ReceiveDone,
                subscriptionClient
            );
        }
开发者ID:jonhenning,项目名称:CodeEndeavors-ResourceManager,代码行数:28,代码来源:QueueCacheDependency.cs


示例17: EventTopicSubscriber

        public EventTopicSubscriber(string connectionString, string topicName, string subscriptionName, 
            OnMessageOptions options, IEventDispatcher eventDispatcher, ILogger logger)
        {
            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

            if (!namespaceManager.SubscriptionExists(topicName, subscriptionName))
                namespaceManager.CreateSubscription(topicName, subscriptionName);

            _client = SubscriptionClient.CreateFromConnectionString(connectionString, topicName, subscriptionName);
            _options = options;
            _eventDispatcher = eventDispatcher;
            _logger = logger;
            _stopEvent = new ManualResetEvent(false);
        }
开发者ID:RagtimeWilly,项目名称:Astro.CQRS,代码行数:14,代码来源:EventTopicSubscriber.cs


示例18: given_a_topic_sender

        public given_a_topic_sender()
        {
            this.sut = new TestableTopicSender(this.Settings, this.Topic, new Incremental(1, TimeSpan.Zero, TimeSpan.Zero));

            var tokenProvider = TokenProvider.CreateSharedSecretTokenProvider(this.Settings.TokenIssuer, this.Settings.TokenAccessKey);
            var serviceUri = ServiceBusEnvironment.CreateServiceUri(this.Settings.ServiceUriScheme, this.Settings.ServiceNamespace, this.Settings.ServicePath);

            var manager = new NamespaceManager(serviceUri, tokenProvider);
            manager.CreateSubscription(this.Topic, "Test");

            var messagingFactory = MessagingFactory.Create(serviceUri, tokenProvider);
            this.subscriptionClient = messagingFactory.CreateSubscriptionClient(this.Topic, "Test");

        }
开发者ID:AlexShkorParalect,项目名称:cqrs-journey-code,代码行数:14,代码来源:TopicSenderIntegration.cs


示例19: ServiceBusMessageBus

        public ServiceBusMessageBus(string connectionString, string topicName, ISerializer serializer = null) {
            _topicName = topicName;
            _serializer = serializer ?? new JsonNetSerializer();
            _subscriptionName = "MessageBus";
            _namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
            if (!_namespaceManager.TopicExists(_topicName))
                _namespaceManager.CreateTopic(_topicName);

            _topicClient = TopicClient.CreateFromConnectionString(connectionString, _topicName);
            if (!_namespaceManager.SubscriptionExists(_topicName, _subscriptionName))
                _namespaceManager.CreateSubscription(_topicName, _subscriptionName);

            _subscriptionClient = SubscriptionClient.CreateFromConnectionString(connectionString, _topicName, _subscriptionName, ReceiveMode.ReceiveAndDelete);
            _subscriptionClient.OnMessageAsync(OnMessageAsync, new OnMessageOptions { AutoComplete = true });
        }
开发者ID:jmkelly,项目名称:Foundatio,代码行数:15,代码来源:ServiceBusMessageBus.cs


示例20: AzureServiceBusMessageBus

        public AzureServiceBusMessageBus(string connectionString, string topicName, ISerializer serializer = null, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
            _serializer = serializer ?? new JsonNetSerializer();

            var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
            if (!namespaceManager.TopicExists(topicName))
                namespaceManager.CreateTopic(topicName);

            _topicClient = TopicClient.CreateFromConnectionString(connectionString, topicName);

            const string subscriptionName = "MessageBus";
            if (!namespaceManager.SubscriptionExists(topicName, subscriptionName))
                namespaceManager.CreateSubscription(topicName, subscriptionName);

            _subscriptionClient = SubscriptionClient.CreateFromConnectionString(connectionString, topicName, subscriptionName, ReceiveMode.ReceiveAndDelete);
            _subscriptionClient.OnMessageAsync(OnMessageAsync, new OnMessageOptions { AutoComplete = true });
        }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:16,代码来源:AzureServiceBusMessageBus.cs



注:本文中的SubscriptionClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SubscriptionRequest类代码示例发布时间:2022-05-24
下一篇:
C# Subscription类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap