Example #1
0
        public void ThreadMQPublishServer()
        {
            try
            {
                using (PublisherSocket publishSocket = new PublisherSocket())
                {
                    publishSocket.Bind(MQConfig.PublishServer);

                    try
                    {
                        while (!_cancellationTokenSource.IsCancellationRequested)
                        {
                            KeyData item;
                            if (MQPublishQueue.TryTake(out item))
                            {
                                publishSocket.PublisherSend(item);
                            }
                        }
                    }
                    catch (TerminatingException)
                    {
                    }
                    catch (Exception ex)
                    {
                        MQThreadExceptionHandler?.Invoke(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                MQThreadExceptionHandler?.Invoke(ex);
            }
        }