| | |
| | | _connection = _factory.CreateConnection(); |
| | | _sendChannel = _connection.CreateModel(); |
| | | |
| | | |
| | | if (channel == 0) |
| | | { |
| | | _receiveChannel1 = _connection.CreateModel(); |
| | |
| | | } |
| | | |
| | | int num = 0; |
| | | public async Task<string> MESForBasketAsync(string ztype, string zlsn, string zlpn, string zstatus, string zversion, int timeoutMes = 30000) |
| | | public async Task<string> MESForBasketAsync(string ztype, string zlsn, string zlpn, string zstatus, string zversion, int timeoutMes = 60000) |
| | | { |
| | | |
| | | string keystr = ztype + "_" + zlsn + "_" + zlpn + "_" + zstatus; |
| | |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"{keystr}匹配成功"); |
| | | num++; |
| | | //var tem = MSGClasses.FirstOrDefault(u => u.key == keystr); |
| | | var tem = MSGClasses.Where(u => u.key == "1" && !string.IsNullOrEmpty(u.receive)).ToList(); |
| | | //DateTime dt = DateTime.Now; |
| | | var tem = MSGClasses.Where(u => u.key == keystr && !string.IsNullOrEmpty(u.receive)).ToList(); |
| | | if (num < 10) |
| | | { |
| | | //while ((DateTime.Now - dt).TotalMilliseconds < timeoutMes) |
| | | //{ |
| | | if (tem!=null) |
| | | { |
| | | if (tem.Count()>0) |
| | | { |
| | | if (!string.IsNullOrEmpty(tem[0].receive)) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ {keystr}二次接收 返回值正常 {tem[0].receive}"); |
| | | return tem[0].receive; |
| | | } |
| | | Thread.Sleep(1000); |
| | | //} |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | num = 0; |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ超时处理次数超过十次"); |
| | | //return null; |
| | | } |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"RabbitMQ二次接收数据接收为空"); |
| | | //return null; |
| | | } |
| | | |
| | | var guid = Guid.NewGuid().ToString(); |
| | |
| | | _sendChannel.BasicPublish("", "auto_line_mac_queue", null, body); |
| | | |
| | | var completed = await Task.WhenAny(tcs.Task, Task.Delay(timeoutMes)); |
| | | |
| | | |
| | | _pendingTask1.TryRemove(guid, out _); |
| | | if (completed == tcs.Task) |
| | |
| | | |
| | | string zr = DefectCodeMap.TryGetValue(pro.Result, out var code) ? code : DefaultErrorCode; |
| | | |
| | | |
| | | |
| | | var msgObj = new AutoLineMacBarcodeQueue |
| | | { |
| | | zbguid = guid, |
| | |
| | | public class MSGClass |
| | | { |
| | | public string key { get; set; } |
| | | |
| | | public string zguid { get; set; } |
| | | |
| | | public string receive { get; set; } |
| | | |
| | | } |
| | | |
| | | |