コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TopicSender"/> class, 
        /// automatically creating the given topic if it does not exist.
        /// </summary>
        protected TopicSender(MessagingSettings settings, string topic, RetryStrategy retryStrategy)
        {
            this.settings = settings;
            this.topic = topic;

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

            try
            {
                new NamespaceManager(this.serviceUri, this.tokenProvider)
                    .CreateTopic(
                        new TopicDescription(topic)
                        {
                            RequiresDuplicateDetection = true,
                            DuplicateDetectionHistoryTimeWindow = TimeSpan.FromMinutes(30)
                        });
            }
            catch (MessagingEntityAlreadyExistsException)
            { }

            // TODO: This could be injected.
            this.retryPolicy = new RetryPolicy<ServiceBusTransientErrorDetectionStrategy>(retryStrategy);
            this.retryPolicy.Retrying +=
                (s, e) =>
                {
                    Trace.TraceError("An error occurred in attempt number {1} to send a message: {0}", e.LastException.Message, e.CurrentRetryCount);
                };

            var factory = MessagingFactory.Create(this.serviceUri, this.tokenProvider);
            this.topicClient = factory.CreateTopicClient(this.topic);
        }
コード例 #2
0
 public given_a_sender_and_receiver()
 {
     this.settings = InfrastructureSettings.ReadMessaging("Settings.xml");
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TopicSender"/> class, 
 /// automatically creating the given topic if it does not exist.
 /// </summary>
 public TopicSender(MessagingSettings settings, string topic)
     : this(settings, topic, GetRetryStrategy())
 {
 }
コード例 #4
0
 public TestableSubscriptionReceiver(MessagingSettings settings, string topic, string subscription, RetryStrategy background, RetryStrategy blocking)
     : base(settings, topic, subscription, background, blocking)
 {
     this.DoReceiveMessageDelegate = base.DoReceiveMessage;
 }