paramore.brighter.commandprocessor.messaginggateway.restms.Domain.GetDomain C# (CSharp) Method

GetDomain() public method

Gets the default domain.
public GetDomain ( ) : paramore.brighter.commandprocessor.messaginggateway.restms.Model.RestMSDomain
return paramore.brighter.commandprocessor.messaginggateway.restms.Model.RestMSDomain
        public RestMSDomain GetDomain()
        {
            _logger.Value.DebugFormat("Getting the default domain from the RestMS server: {0}", _gateway.Configuration.RestMS.Uri.AbsoluteUri);

            try
            {
                var response = _gateway.Client().GetAsync(_gateway.Configuration.RestMS.Uri).Result;
                response.EnsureSuccessStatusCode();
                return _gateway.ParseResponse<RestMSDomain>(response);
            }
            catch (AggregateException ae)
            {
                foreach (var exception in ae.Flatten().InnerExceptions)
                {
                    _logger.Value.ErrorFormat("Threw exception getting Domain from RestMS Server {0}", exception.Message);
                }

                throw new RestMSClientException("Error retrieving the domain from the RestMS server, see log for details");
            }
        }
    }

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.Domain::GetDomain