paramore.brighter.commandprocessor.messaginggateway.restms.Feed.EnsureFeedExists C# (CSharp) Méthode

EnsureFeedExists() public méthode

Ensures the feed exists.
public EnsureFeedExists ( paramore.brighter.commandprocessor.messaginggateway.restms.Model.RestMSDomain domain ) : void
domain paramore.brighter.commandprocessor.messaginggateway.restms.Model.RestMSDomain The domain.
Résultat void
        public void EnsureFeedExists(RestMSDomain domain)
        {
            var feedName = _gateway.Configuration.Feed.Name;
            _logger.Value.DebugFormat("Checking for existence of the feed {0} on the RestMS server: {1}", feedName, _gateway.Configuration.RestMS.Uri.AbsoluteUri);
            var isFeedDeclared = IsFeedDeclared(domain, feedName);
            if (!isFeedDeclared)
            {
                domain = CreateFeed(domain.Href, feedName);
                if (domain == null || !domain.Feeds.Any(feed => feed.Name == feedName))
                {
                    throw new RestMSClientException(string.Format("Unable to create feed {0} on the default domain; see log for errors", feedName));
                }
            }
            FeedUri = domain.Feeds.First(feed => feed.Name == feedName).Href;
        }

Usage Example

        /// <summary>
        /// Sends the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns>Task.</returns>
        public Task Send(Message message)
        {
            var tcs = new TaskCompletionSource <object>();

            try
            {
                feed.EnsureFeedExists(domain.GetDomain());
                SendMessage(Configuration.Feed.Name, message);
            }
            catch (RestMSClientException rmse)
            {
                Logger.ErrorFormat("Error sending to the RestMS server: {0}", rmse.ToString());
                tcs.SetException(rmse);
                throw;
            }
            catch (HttpRequestException he)
            {
                Logger.ErrorFormat("HTTP error on request to the RestMS server: {0}", he.ToString());
                tcs.SetException(he);
                throw;
            }

            tcs.SetResult(new object());
            return(tcs.Task);
        }
All Usage Examples Of paramore.brighter.commandprocessor.messaginggateway.restms.Feed::EnsureFeedExists