Exemple #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="bufferSize">BufferSize can't excess <c>MaxBufferSize = 2000</c></param>
 public SyncQueue(uint bufferSize)
 {
     //synchQ = new Queue();
     bool exist = false;
     /*mReadOnlyQueue = new P2PMessageQueue(true, "rfidQueue", 24, 0, out exist);
     mWriteOnlyQueue = new P2PMessageQueue(false, "rfidQueue", 24, 0, out exist);*/
     mReadOnlyQueue = new MessageQueueReader("rfidMessageQueue", 0, 128);
     mWriteOnlyQueue = new MessageQueueWriter("rfidMessageQueue", 0, 128);
     _cnn = new SQLiteConnection();
     _cnn.ConnectionString = databaseName;
     this.BufferSize = bufferSize;
 }
Exemple #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public SyncQueue()
 {
     //synchQ = new Queue();
     bool exist = false;
     /*mReadOnlyQueue = new P2PMessageQueue(true, "rfidQueue", 24, 0, out exist);
     mReadOnlyQueue.DataOnQueueChanged += new EventHandler(mReadOnlyQueue_DataOnQueueChanged);
     mWriteOnlyQueue = new P2PMessageQueue(false, "rfidQueue", 24, 0, out exist);*/
     mReadOnlyQueue = new MessageQueueReader("rfidMessageQueue", 0, 128);
     mWriteOnlyQueue = new MessageQueueWriter("rfidMessageQueue", 0, 128);
     _cnn = new SQLiteConnection();
     _cnn.ConnectionString = databaseName;
 }
        /// <summary>
        /// Create the message queues and system event.
        /// </summary>
        public void InitQueueEndPoints()
        {
            //Create out reader and writer queues.  Since this queue has a name it is accessible
            // by other programs.
            _writer = new MessageQueueWriter(QueueEndpointName, maxItems, maxMessageSize);

            if (_isReader)
            {
                _reader = new MessageQueueReader(QueueEndpointName, maxItems, maxMessageSize);

                //Create an unnamed event.  This will be used to unblock the read thread
                //when the program is terminating.
                _readerWaitEvent = new SystemEvent(null, false, true);

                Thread readThread = new Thread(new ThreadStart(ReaderThread));
                readThread.IsBackground = true;
                readThread.Start();
            }
        }
        /// <summary>
        /// Create the message queues and system event. 
        /// </summary>
        public void InitQueueEndPoints()
        {
            //Create out reader and writer queues.  Since this queue has a name it is accessible
            // by other programs.
            _writer = new MessageQueueWriter(QueueEndpointName, maxItems, maxMessageSize);

            if (_isReader)
            {
                _reader = new MessageQueueReader(QueueEndpointName, maxItems, maxMessageSize);

                //Create an unnamed event.  This will be used to unblock the read thread
                //when the program is terminating.
                _readerWaitEvent = new SystemEvent(null, false, true);

                Thread readThread = new Thread(new ThreadStart(ReaderThread));
                readThread.IsBackground = true;
                readThread.Start();
            }
        }
Exemple #5
0
        public void MessageQueueMessageQueueWriterMethodWriteMessages()
        {
            var mockMsmqRepository = new Moq.Mock <IMsmqRepository>();

            mockMsmqRepository.Setup(x => x.Exists(It.IsAny <string>())).Returns(true);
            mockMsmqRepository.Setup(x => x.Create(It.IsAny <string>(), It.IsAny <bool>()));
            mockMsmqRepository.Setup(x => x.WriteMessage(
                                         It.IsAny <string>(),
                                         It.IsAny <object>(),
                                         It.IsAny <bool>(),
                                         It.IsAny <bool>(),
                                         It.IsAny <System.Messaging.IMessageFormatter>()));

            var mockFileSystemRepository = new Moq.Mock <IFileSystemRepository>();

            mockFileSystemRepository.Setup(x => x.WriteFile(It.IsAny <string>(), It.IsAny <object>()));

            // add mock repositories to the container
            ServiceLocator.Container.RegisterInstance <IMsmqRepository>(mockMsmqRepository.Object);
            ServiceLocator.Container.RegisterInstance <IFileSystemRepository>(mockFileSystemRepository.Object);

            string             serverName         = Environment.MachineName;
            MessageQueueWriter messageQueueWriter = new MessageQueueWriter(
                "private$\\Testing", true, serverName);

            messageQueueWriter.MessageFormatter = new BinaryMessageFormatter();

            int i = 0;

            do
            {
                messageQueueWriter.WriteQueue("message " + i.ToString());
                i++;
            }while (i < 5);

            messageQueueWriter = new MessageQueueWriter("private$\\Testing", false, serverName);
            messageQueueWriter.WriteQueue("message ");

            Assert.IsTrue(i > 0);
        }
 public HubSubscriptionListener(ILoggingService loggingService)
 {
     _loggingService = loggingService;
     _queueWriter    = new MessageQueueWriter(Config.MessageWriterQueue, _loggingService);
 }
 public HubSubscriptionListener(ILoggingService loggingService)
 {
     _loggingService = loggingService;
     _queueWriter = new MessageQueueWriter(Config.MessageWriterQueue, _loggingService);
 }