示例#1
0
        public static Task ReceiveAsyn <T>(string code, Action <IMessage <T> > func) where T : class
        {
            try
            {
                if (!s_serverDic.ContainsKey(code))
                {
                    return(Task.FromResult(0));
                }
                ServerInner server = s_serverDic[code];

                s_bus.Advanced.Consume <T>(server.Queue, (data, info) =>
                                           Task.Factory.StartNew(() =>
                {
                    try
                    {
                        func(data);
                    }
                    catch (Exception ex)
                    {
                        m_log.Error(string.Format("调用{0}异常,异常信息:{1}", func.Method.Name, ex.ToString()));
                    }
                }));
            }
            catch (Exception ex)
            {
                m_log.Error("消费消息异常:" + ex.ToString());
            }
            return(Task.FromResult(0));
        }
示例#2
0
        /// <summary>
        /// 泛型支持
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="code"></param>
        /// <param name="data"></param>
        /// <param name="isPersistent"></param>
        public static Task <int> SendAsync <T>(string code, T data, bool isPersistent = false) where T : class
        {
            try
            {
                if (!s_serverDic.ContainsKey(code))
                {
                    return(Task.FromResult(0));
                }

                MessageProperties messageProperties = new MessageProperties();
                messageProperties.DeliveryMode = isPersistent ? (byte)2 : (byte)1;

                ServerInner  server  = s_serverDic[code];
                IMessage <T> message = new Message <T>(data, messageProperties);

                s_bus.Advanced.PublishAsync <T>(server.Exchage, server.RootingKey, false, false, message);
                return(Task.FromResult(0));
            }
            catch (Exception ex)
            {
                m_log.Error("发布消息异常:" + ex.ToString());
                return(Task.FromResult(1));
            }
        }
示例#3
0
 /// <summary>
 /// Creates a new Azure SQL server.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group that contains the resource. You can obtain
 /// this value from the Azure Resource Manager API or the portal.
 /// </param>
 /// <param name='serverName'>
 /// The name of the Azure SQL server.
 /// </param>
 /// <param name='parameters'>
 /// The required parameters for creating or updating a server.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ServerInner> CreateOrUpdateAsync(this IServersOperations operations, string resourceGroupName, string serverName, ServerInner parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#4
0
 ///GENMHASH:FED6CA0448AFD6EE7D63F8D84B7C6C26:4E9D1D31C4E764F2191FF855F590821F
 public SqlServerImpl(string name, ServerInner innerObject, ISqlManager manager) : base(name, innerObject, manager)
 {
     this.sqlADAdminObject         = null;
     this.allowAzureServicesAccess = true;
 }
 /// <summary>
 /// Creates or updates a server.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group that contains the resource. You can obtain
 /// this value from the Azure Resource Manager API or the portal.
 /// </param>
 /// <param name='serverName'>
 /// The name of the server.
 /// </param>
 /// <param name='parameters'>
 /// The requested server resource state.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ServerInner> BeginCreateOrUpdateAsync(this IServersOperations operations, string resourceGroupName, string serverName, ServerInner parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serverName, parameters, SqlManagementClient.SetJsonAcceptHeader(), cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }