private void AddToQueue(string RowKey)
        {
            CloudQueue        queue   = QueueHelper.GetQueueReference("vezba");
            CloudQueueMessage message = new CloudQueueMessage(RowKey);

            queue.AddMessage(message);
        }
Example #2
0
        private static List <int> GetCustomerOrderIds(int countMax = 20)
        {
            List <int> customerOrderIds = new List <int>();

            //先尝试从文件中获取订单ID
            List <string> customerOrderIdsFromFile = GetCustomerOrderIdsFromFile();

            if (customerOrderIdsFromFile != null && customerOrderIdsFromFile.Any())
            {
                customerOrderIds.AddRange(customerOrderIdsFromFile.Select(p => Convert.ToInt32(p)));

                Log.Info(string.Format("从文件中获取到订单数:{0}", customerOrderIdsFromFile.Count()));

                return(customerOrderIds);
            }

            do
            {
                var message = QueueHelper.Dequeue(QueueName);
                if (string.IsNullOrWhiteSpace(message))
                {
                    break;
                }

                //记录订单ID到文件
                File.AppendAllText(OrderIdsFile, message + Environment.NewLine);

                customerOrderIds.Add(Convert.ToInt32(message));

                Log.Info(string.Format("获取到订单ID:{0}", message));
            } while (customerOrderIds.Count < countMax);

            return(customerOrderIds);
        }
Example #3
0
 static void InStorageSyncHandler()
 {
     while (true)
     {
         string taskJson = string.Empty;
         try
         {
             Log.Info("获取任务中..");
             taskJson = QueueHelper.Dequeue(WAYBILL_INSTORAGE_QUEUENAME, RABBITMQ_CONFIGKEY);
             if (string.IsNullOrWhiteSpace(taskJson))
             {
                 Log.Info("没有任务.");
                 return;
             }
             var task    = SerializeUtil.FromJson <Task>(taskJson);
             var service = EngineContext.Current.Resolve <IInStorageService>();
             service.CreateInStorageAsync(task);
             Log.Info(string.Format("异步处理完成,运单号:{0}", task.TaskKey));
         }
         catch (Exception ex)
         {
             var x = ex.InnerException == null ? ex : ex.InnerException;
             Log.Error(x.ToString() + "<br/>" + taskJson);
         }
     }
 }
        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();

                var tokens = input.Split(' ');

                if (tokens[0] == "r")
                {
                    QueueHelper.Publish(new AccountRegistered
                    {
                        UserName  = tokens[1],
                        FirstName = tokens[2]
                    }, "pomodoro.account.register");
                }

                if (tokens[0] == "d")
                {
                    QueueHelper.Publish(new AccountDeleted
                    {
                        UserName = tokens[1]
                    }, "pomodoro.account.delete");
                }
            }
        }
Example #5
0
        public async Task <string> CreateTransferContract(string userAddress, string coinAdapterAddress)
        {
            ITransferContract contract = await GetTransferContract(userAddress, coinAdapterAddress);

            if (contract != null)
            {
                throw new ClientSideException(ExceptionType.EntityAlreadyExists, $"Transfer account for {userAddress} - {coinAdapterAddress} already exists");
            }

            ICoin coin = await GetCoinWithCheck(coinAdapterAddress);

            string queueName = QueueHelper.GenerateQueueNameForContractPool(coinAdapterAddress);
            ITransferContractQueueService transferContractQueueService = _transferContractQueueServiceFactory.Get(queueName);
            ITransferContract             transferContract             = await transferContractQueueService.GetContract();

            transferContract.UserAddress = userAddress;

            await _transferContractRepository.SaveAsync(transferContract);

            await _transferContractUserAssignmentQueueService.PushContract(new TransferContractUserAssignment()
            {
                TransferContractAddress = transferContract.ContractAddress,
                UserAddress             = userAddress,
                CoinAdapterAddress      = coin.AdapterAddress
            });

            return(transferContract.ContractAddress);
        }
        public void AttemptsExceededMitigation(MessageWrapper wrappedMessage)
        {
            //clear the CustomObjectToAudit audit point from the dictionary
            //log a fatal

            Remove(wrappedMessage);

            try
            {
                _log.Fatal("Attempts to Write Audit Point to AuditDBWriterMSMQ have been exceeded, number of tries:  "
                           + _configuredNumberOfAttempts.ToString());
                _log.Info("Attempting to Write to the Central Audit Database Directly, this is a last Ditch Effort for recovery");
                AuditDatabase auditDataAccess = new AuditDatabase();
                auditDataAccess.WriteAudit(wrappedMessage.WrappedCustomObjectToAuditAuditPoint);
                _log.Info("Attempt to Write Directly to the Central Store Audit Database was Successful, There are still issues with the AuditDBWriterMSMQ that need to be resolved");
            }

            catch (Exception)
            {
                _log.Fatal("Attempt to Write Directly to the Central Store Audit Database Directly was UnSuccessful");
                _log.Fatal("Attempts to Write Audit Point to Audit database have been exceeded, number of tries:  "
                           + _configuredNumberOfAttempts.ToString());
                QueueHelper <MessageWrapper> queueHelper = new QueueHelper <MessageWrapper>();
                _log.Fatal(queueHelper.GetStringMessage(wrappedMessage));
            }
        }
        public async Task Post([FromBody] News value)
        {
            value.Created = DateTime.Now;
            value.Author  = "Anonymous";

            // STAGE5 - Odkomentowac
            if (ClaimsPrincipal.Current.Identity.IsAuthenticated)
            {
                string AuthorIdentifier = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
                string AuthorName       = ClaimsPrincipal.Current.FindFirst("name").Value;
                value.Author = AuthorName;

                // STAGE4 - Zakomentowac
                //await DocumentDbRepository<News>.CreateItemAsync(value);

                // STAGE4 - Odkomentowac
                QueueHelper <News> queueHelper = new QueueHelper <News>();
                queueHelper.Initialize(
                    ConfigurationManager.AppSettings["asConnectionString"],
                    ConfigurationManager.AppSettings["asQueueName"]
                    );
                await queueHelper.SendMessageAsync(value);

                // STAGE5 - Odkomentowac
            }
            else
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }
        }
Example #8
0
        public async Task CheckRegisterNewDoctor()
        {
            //System.Diagnostics.Debugger.Launch();
            var repo     = new FakeRepo(_context);
            var fakeUser = repo.FakeSingleUser();

            var fakeQueue     = repo.FakeSingleQueue();
            var expectedQueue = _mapper.Map <WebApp.Models.Queue>(fakeQueue);

            var connection = MakeHubConnection();

            MakeDoctorFullNameReceive(connection);
            MakeQueueNoReceive(connection);
            MakeQueueAdditionalMessageReceive(connection);

            await connection.StartAsync();

            await connection.InvokeAsync("RegisterDoctor", fakeUser.Id, fakeUser.RoomNo);

            fakeQueue = _context.Queue.FindByCondition(q => q.UserId == fakeUser.Id).SingleOrDefault();

            string expected = QueueHelper.GetDoctorFullName(fakeUser);

            Assert.True(fakeQueue.IsActive);

            Assert.Equal(expected, HubResponse.ReceiveDoctorFullName);
            Assert.Equal(fakeUser.Id, HubResponse.ReceiveUserId);

            Assert.Equal(expectedQueue.QueueNoMessage, HubResponse.ReceiveQueueNo);
            Assert.Equal(expectedQueue.AdditionalMessage, HubResponse.ReceiveAdditionalMessage);

            await connection.DisposeAsync();
        }
Example #9
0
        public override SkillResponse Process(IntentRequest request)
        {
            var responseText = new StringBuilder();

            //We will use SSML as reponse format
            //https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html
            responseText.Append("<speak>");

            var helper = new QueueHelper <Appointment>(
                System.Environment.GetEnvironmentVariable("AppointmentQueueConnection", System.EnvironmentVariableTarget.Process));
            var appointment = helper.Receive();

            if (appointment != null)
            {
                responseText.Append("<audio src = 'https://s3.amazonaws.com/ask-soundlibrary/ui/gameshow/amzn_ui_sfx_gameshow_positive_response_01.mp3'/>");
                responseText.Append(Ssml.SayAs(appointment.Subject, "interjection"));
                responseText.Append(Ssml.SayAs(appointment.Start, true));
                responseText.Append("<break/>");
            }
            else
            {
                responseText.Append("<audio src='soundbank://soundlibrary/cartoon/amzn_sfx_boing_long_1x_01'/>");
                responseText.Append(Ssml.SayAs("You got all appointments! Get to work!", "interjection"));
                responseText.Append("<break/>");
            }

            responseText.Append("</speak>");
            SsmlOutputSpeech speech = new SsmlOutputSpeech();

            speech.Ssml = responseText.ToString();
            return(ResponseBuilder.Tell(speech));
        }
Example #10
0
        public async Task ProcessAccountStopout(AccountStopoutBackendContract stopout)
        {
            var queueName = QueueHelper.BuildQueueName(_settings.MarginTradingFront.RabbitMqQueues.AccountStopout.ExchangeName, _settings.MarginTradingFront.Env);

            _consoleWriter.WriteLine($"Get account stopout from {queueName} queue for clientId = {stopout.ClientId}");

            var notificationId = await _clientNotificationService.GetNotificationId(stopout.ClientId);

            var userTopic = _realm.Services.GetSubject <NotifyResponse <AccountStopoutClientContract> >($"user.{notificationId}");

            var response = new NotifyResponse <AccountStopoutClientContract>
            {
                Entity = stopout.ToClientContract(),
                Type   = NotifyEntityType.AccountStopout
            };

            userTopic.OnNext(response);

            _operationsLog.AddLog($"topic user.{notificationId} (account stopout)", stopout.ClientId, response.Entity.AccountId, null, response.ToJson());
            _consoleWriter.WriteLine($"topic user.{notificationId} (account stopout) for clientId = {stopout.ClientId}");

            var userUpdateTopic         = _realm.Services.GetSubject <NotifyResponse>($"user.updates.{notificationId}");
            var userUpdateTopicResponse = new NotifyResponse {
                Account = null, Order = null, AccountStopout = response.Entity
            };

            userUpdateTopic.OnNext(userUpdateTopicResponse);

            _operationsLog.AddLog($"topic user.updates.{notificationId} (account stopout)", stopout.ClientId, response.Entity.AccountId, null, userUpdateTopicResponse.ToJson());
            _consoleWriter.WriteLine($"topic user.updates.{notificationId} (account stopout) for clientId = {stopout.ClientId}");
        }
Example #11
0
        public async Task ProcessOrderChanged(OrderContract order)
        {
            var queueName = QueueHelper.BuildQueueName(_settings.MarginTradingFront.RabbitMqQueues.OrderChanged.ExchangeName, _settings.MarginTradingFront.Env);

            _consoleWriter.WriteLine($"Get order change from {queueName} queue for clientId = {order.ClientId}");

            var notificationId = await _clientNotificationService.GetNotificationId(order.ClientId);

            var userTopic = _realm.Services.GetSubject <NotifyResponse <OrderClientContract> >($"user.{notificationId}");

            var notifyResponse = new NotifyResponse <OrderClientContract>
            {
                Entity = order.ToClientContract(),
                Type   = NotifyEntityType.Order
            };

            userTopic.OnNext(notifyResponse);

            _operationsLog.AddLog($"topic user.{notificationId} (position changed)", order.ClientId, order.AccountId, null, notifyResponse.ToJson());
            _consoleWriter.WriteLine($"topic user.{notificationId} (order changed) for clientId = {order.ClientId}");

            var userUpdateTopic         = _realm.Services.GetSubject <NotifyResponse>($"user.updates.{notificationId}");
            var userUpdateTopicResponse = new NotifyResponse {
                Account = null, Order = notifyResponse.Entity
            };

            userUpdateTopic.OnNext(userUpdateTopicResponse);

            _operationsLog.AddLog($"topic user.updates.{notificationId} (position changed)", order.ClientId, notifyResponse.Entity.AccountId, null, userUpdateTopicResponse.ToJson());
            _consoleWriter.WriteLine($"topic user.updates.{notificationId} (order changed) for clientId = {order.ClientId}");
        }
        public async Task Execute()
        {
            await _logger.WriteInfoAsync("PoolRenewJob", "Execute", "", "PoolRenewJob has been started ", DateTime.UtcNow);

            await _coinRepository.ProcessAllAsync(async (coins) =>
            {
                foreach (var coin in coins)
                {
                    try
                    {
                        string coinPoolQueueName = QueueHelper.GenerateQueueNameForContractPool(coin.AdapterAddress);
                        ITransferContractQueueService transferContractQueueService =
                            _transferContractQueueServiceFactory.Get(coinPoolQueueName);
                        var count = await transferContractQueueService.Count();

                        for (int i = 0; i < count; i++)
                        {
                            var contract = await transferContractQueueService.GetContract();
                            if (contract == null)
                            {
                                return;
                            }
                            await transferContractQueueService.PushContract(contract);
                        }

                        await _logger.WriteInfoAsync("PoolRenewJob", "Execute", "", $"PoolRenewJob has been finished for {count} contracts in {coinPoolQueueName} ", DateTime.UtcNow);
                    }
                    catch (Exception e)
                    {
                        await _logger.WriteErrorAsync("PoolRenewJob", "Execute", "", e);
                    }
                }
            });
        }
        public static async Task DequeueQueue()
        {
            CloudQueue queue = await QueueHelper.GetCloudQueue();

            Console.WriteLine("Get the queue length");

            await queue.FetchAttributesAsync();

            int?cachedMessageCount = queue.ApproximateMessageCount;

            Console.WriteLine("Number of messages in queue: {0}", cachedMessageCount);
            QueueRequestOptions options          = new QueueRequestOptions();
            OperationContext    operationContext = new OperationContext();

            if (cachedMessageCount == null)
            {
                Console.WriteLine("No Message Present in Queue");
                return;
            }

            foreach (CloudQueueMessage message in await queue.GetMessagesAsync(cachedMessageCount.Value,
                                                                               new TimeSpan(0, 0, 5, 0), options, operationContext))
            {
                // Process all messages in less than 5 minutes, deleting each message after processing.

                Console.WriteLine("Processing {0} Message", message.AsString);
                await queue.DeleteMessageAsync(message);
            }
        }
        private static async Task AddMessage()
        {
            CloudQueue queue = await QueueHelper.GetCloudQueue();

            for (int i = 0; i < MessageCount; i++)
            {
                var content = "Hello World" + "\t" + i;
                await queue.AddMessageAsync(new CloudQueueMessage(content));
            }
            Console.WriteLine("Peek at the next message");
            CloudQueueMessage queueMessage = await queue.PeekMessageAsync();

            if (queueMessage != null)
            {
                Console.WriteLine("The peeked message is: {0}", queueMessage.AsString);
            }

            Console.WriteLine("De-queue the next message");
            CloudQueueMessage cloudQueueMessage = await queue.GetMessageAsync();

            if (cloudQueueMessage != null)
            {
                Console.WriteLine("Processing & deleting message with content: {0}", cloudQueueMessage.AsString);
                await queue.DeleteMessageAsync(cloudQueueMessage);
            }
        }
Example #15
0
        public Task <HttpResponseMessage> GetBigImage(BigImage bigImage)
        {
            ResponseBase <string> response = new ResponseBase <string>();

            try
            {
                UploadFileObj uploadFileObj = new UploadFileObj()
                {
                    MsgId          = bigImage.MsgId,
                    MsgType        = 3,
                    WxId           = bigImage.WxId,
                    ToWxId         = bigImage.ToWxId,
                    LongDataLength = bigImage.LongDataLength,
                };
                string objName = QueueHelper <UploadFileObj> .Work(uploadFileObj);

                response.Data = objName;
            }
            catch (ExpiredException ex)
            {
                response.Success = false;
                response.Code    = "401";
                response.Message = ex.Message;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Code    = "500";
                response.Message = ex.Message;
            }
            return(response.ToHttpResponseAsync());
        }
        public async Task DataCleanup_DeleteQueues_ShouldWork()
        {
            // Setup
            QueueClient queueClient = await SetupTestQueue();

            var queueHelper = new QueueHelper(StorageConnectionString);

            (await queueHelper.GetQueues()).Should().HaveCountGreaterOrEqualTo(1);

            var parameters = new DataCleanupParameters()
            {
                StorageConnectionString = StorageConnectionString
            };
            var content = new StringContent(JsonSerializer.Serialize(parameters), Encoding.UTF8, "application/json");

            // Act
            HttpResponseMessage response = await _clientFixture.GetClient().PostAsync(_UrlDeleteQueues, content);

            // Verify
            response.StatusCode.Should().Be(HttpStatusCode.OK);
            bool queueExists = await queueClient.ExistsAsync();

            queueExists.Should().BeFalse();
            (await queueHelper.GetQueues()).Should().HaveCount(0);
        }
        static void SendMessage(TopicType topic)
        {
            // Create a transaction because we are using a transactional queue.
            using (var trn = new MessageQueueTransaction())
            {
                try
                {
                    // Create queue object
                    using (var queue = QueueHelper.GetQueueReference(@".\private$\mbp.message"))
                    {
                        queue.Formatter = new XmlMessageFormatter();

                        // push message onto queue (inside of a transaction)
                        trn.Begin();
                        queue.Send(String.Format("{0} message", topic), topic.ToString(), trn);
                        trn.Commit();

                        Console.WriteLine("===============================");
                        Console.WriteLine("{0} message queued", topic);
                        Console.WriteLine("===============================");
                        Console.WriteLine();
                    }
                }
                catch
                {
                    trn.Abort(); // rollback the transaction
                }
            }
        }
        static void Main()
        {
            // Create an instance of MessageQueue. Set its formatter.
            MessageQueue mq = QueueHelper.GetQueueReference(@".\private$\mbp.inventory");

            mq.Formatter = new XmlMessageFormatter(new[] { typeof(String) });

            // Add an event handler for the PeekCompleted event.
            mq.PeekCompleted += OnPeekCompleted;

            // Begin the asynchronous peek operation.
            mq.BeginPeek();

            Console.WriteLine("Inventory processor listening on queue");

            Console.ReadLine();

            Console.WriteLine("Closing inventory processor...");

            // Remove the event handler before closing the queue
            mq.PeekCompleted -= OnPeekCompleted;
            mq.Close();
            mq.Dispose();

            Console.WriteLine("Inventory processor closed. Press any key to exit.");
            Console.ReadLine();
        }
        private bool ProcessCommand(Message message, TopicType topic)
        {
            // get the subscribers
            var           subscriptions = new SubscriptionManager();
            List <string> subscribers   = subscriptions.GetSubscribers(topic);

            // loop through the subscribers and send the message
            using (var trn = new MessageQueueTransaction())
            {
                foreach (var subscriberQueue in subscribers)
                {
                    try
                    {
                        // Create queue object
                        using (var queue = QueueHelper.GetQueueReference(subscriberQueue))
                        {
                            queue.Formatter = new XmlMessageFormatter();

                            // push message onto queue (inside of a transaction)
                            trn.Begin();
                            queue.Send((string)message.Body, topic.ToString(), trn);
                            trn.Commit();

                            Console.WriteLine("{0} message queued on {1}", topic, subscriberQueue);
                        }
                    }
                    catch
                    {
                        trn.Abort(); // rollback the transaction
                        return(false);
                    }
                }
            }
            return(true); // successfully sent the message on to subscribers
        }
Example #20
0
        public async Task ProcessUserUpdates(UserUpdateEntityBackendContract userUpdate)
        {
            var queueName = QueueHelper.BuildQueueName(_settings.MarginTradingFront.RabbitMqQueues.UserUpdates.ExchangeName, _settings.MarginTradingFront.Env);

            _consoleWriter.WriteLine($"Get user update from {queueName} queue for {userUpdate.ClientIds.Length} clients");

            foreach (var clientId in userUpdate.ClientIds)
            {
                try
                {
                    var notificationId = await _clientNotificationService.GetNotificationId(clientId);

                    var userTopic =
                        _realm.Services.GetSubject <NotifyResponse <UserUpdateEntityClientContract> >(
                            $"user.{notificationId}");

                    var response = new NotifyResponse <UserUpdateEntityClientContract>
                    {
                        Entity = userUpdate.ToClientContract(),
                        Type   = NotifyEntityType.UserUpdate
                    };

                    userTopic.OnNext(response);

                    var eventType = string.Empty;

                    if (userUpdate.UpdateAccountAssetPairs)
                    {
                        eventType = "account assets";
                    }

                    if (userUpdate.UpdateAccounts)
                    {
                        eventType = "accounts";
                    }

                    _operationsLog.AddLog($"topic user.{notificationId} ({eventType} changed)", clientId, null, null,
                                          response.ToJson());
                    _consoleWriter.WriteLine(
                        $"topic user.{notificationId} ({eventType} changed) for clientId = {clientId}");

                    var userUpdateTopic         = _realm.Services.GetSubject <NotifyResponse>($"user.updates.{notificationId}");
                    var userUpdateTopicResponse = new NotifyResponse {
                        UserUpdate = response.Entity
                    };

                    userUpdateTopic.OnNext(userUpdateTopicResponse);

                    _operationsLog.AddLog($"topic user.updates.{notificationId} ({eventType} changed)", clientId, null,
                                          null, userUpdateTopicResponse.ToJson());
                    _consoleWriter.WriteLine(
                        $"topic user.updates.{notificationId} (account assets changed) for clientId = {clientId}");
                }
                catch (Exception ex)
                {
                    await _log.WriteErrorAsync(nameof(RabbitMqHandler), nameof(ProcessUserUpdates), clientId, ex);
                }
            }
        }
Example #21
0
        public async Task Post([FromBody] AddProductCommand command)
        {
            var uri = $"{_rabbitMqOptions.Uri}/{QueueHelper.GetQueueName<AddProductCommand>()}";

            var endpoint = await _bus.GetSendEndpoint(new Uri(uri));

            await endpoint.Send(command);
        }
Example #22
0
        public bool SetCurrentQueueItem(string mediaId)
        {
            // set the current index on queue from the music Id:
            int index = QueueHelper.GetMusicIndexOnQueue(playingQueue, mediaId);

            SetCurrentQueueIndex(index);
            return(index >= 0);
        }
Example #23
0
 /// <summary>
 /// Creates a default instance.
 /// </summary>
 public Provider()
 {
     this.outgoingEvents = new QueueHelper<hEvents.HookEventArgs>(this.SendEvents);
     this.aoProcessPollerThread = new Thread(this.AoProcessPoller);
     this.aoProcessPollerThread.IsBackground = true;
     this.aoProcessPollerThread.Name = "Provider->AoProcessPoller()";
     HookInterface.BridgeEvent += new BridgeEventDelegate(this.ProcessBridgeEvents);
 }
Example #24
0
        public void NotifyAccountUpdated(IMarginTradingAccount account)
        {
            _rabbitMqNotifyService.AccountUpdated(account);
            var queueName = QueueHelper.BuildQueueName(_marginSettings.RabbitMqQueues.AccountChanged.ExchangeName, _marginSettings.Env);

            _consoleWriter.WriteLine($"send account changed to queue {queueName}");
            _operationsLogService.AddLog($"queue {queueName}", account.ClientId, account.Id, null, account.ToJson());
        }
Example #25
0
        public void NotifyOrderChanged(Order order)
        {
            _rabbitMqNotifyService.OrderChanged(order);
            var queueName = QueueHelper.BuildQueueName(_marginSettings.RabbitMqQueues.OrderChanged.ExchangeName, _marginSettings.Env);

            _consoleWriter.WriteLine($"send order changed to queue {queueName}");
            _operationsLogService.AddLog($"queue {queueName}", order.ClientId, order.AccountId, null, order.ToJson());
        }
Example #26
0
 /// <summary>
 /// Creates a default instance.
 /// </summary>
 public Provider()
 {
     this.outgoingEvents        = new QueueHelper <hEvents.HookEventArgs>(this.SendEvents);
     this.aoProcessPollerThread = new Thread(this.AoProcessPoller);
     this.aoProcessPollerThread.IsBackground = true;
     this.aoProcessPollerThread.Name         = "Provider->AoProcessPoller()";
     HookInterface.BridgeEvent += new BridgeEventDelegate(this.ProcessBridgeEvents);
 }
        public async Task SendAsync <TContract, TConsumer>(object values, QueuePriority priority = QueuePriority.Normal, CancellationToken cancellationToken = default)
            where TContract : class
            where TConsumer : class, IConsumer <TContract>
        {
            var endpoint = await _sendEndpointProvider.GetSendEndpoint(QueueHelper.GetQueueUri <TConsumer>(priority));

            await endpoint.Send <TContract>(values);
        }
Example #28
0
        public void NotifyAccountStopout(string clientId, string accountId, int positionsCount, decimal totalPnl)
        {
            _rabbitMqNotifyService.AccountStopout(clientId, accountId, positionsCount, totalPnl);
            var queueName = QueueHelper.BuildQueueName(_marginSettings.RabbitMqQueues.AccountStopout.ExchangeName, _marginSettings.Env);

            _consoleWriter.WriteLine($"send account stopout to queue {queueName}");
            _operationsLogService.AddLog($"queue {queueName}", clientId, accountId, null,
                                         new { clientId = clientId, accountId = accountId, positionsCount = positionsCount, totalPnl = totalPnl }.ToJson());
        }
Example #29
0
 private RabbitMqSubscriptionSettings GetRabbitMqSubscriptionSettings()
 {
     return(new RabbitMqSubscriptionSettings
     {
         ConnectionString = Settings.MtRabbitMqConnString,
         QueueName = QueueHelper.BuildQueueName(ExchangeName, Settings.Env, QueuePostfix),
         ExchangeName = ExchangeName,
         IsDurable = true
     });
 }
Example #30
0
        public void AllAlternateMitigationPathsFailure(CustomObjectToAuditAuditPoint CustomObjectToAuditAuditPoint)
        {
            //clear the CustomObjectToAudit audit point from the dictionary
            //log a fatal

            _log.Fatal("Attempts to Write Audit Point to Audit Service have been exhausted, Multiple System Failure");
            QueueHelper <CustomObjectToAuditAuditPoint> queueHelper = new QueueHelper <CustomObjectToAuditAuditPoint>();

            _log.Fatal("Message That was Not Able to Be Processed:  " + queueHelper.GetStringMessage(CustomObjectToAuditAuditPoint));
        }
 /// <summary>
 ///     Override the OnOpening handler and validate any queues based on whether there's an apropriate endpoint associated
 ///     with the service host
 /// </summary>
 protected override void OnOpening()
 {
     foreach (
         ServiceEndpoint endpoint in
         Description.Endpoints.Where(endpoint => endpoint.Binding.Scheme == "net.msmq"))
     {
         QueueHelper.ValidateQueue(endpoint.Contract.ContractType);
     }
     base.OnOpening();
 }