예제 #1
0
        public async Task should_support_out_of_order_ZebusV2_acks_and_messages()
        {
            var messageBytes = new byte[512];

            new Random().NextBytes(messageBytes);
            var timestamp = DateTime.UtcNow;
            var messageId = new MessageId(MessageIdV2.CreateNewSequentialId(timestamp.Ticks));
            var peerId    = "Abc.Peer.0";

            await _storage.Write(new List <MatcherEntry> {
                MatcherEntry.Ack(new PeerId(peerId), messageId)
            });

            await Task.Delay(50);

            await _storage.Write(new List <MatcherEntry> {
                MatcherEntry.Message(new PeerId(peerId), messageId, MessageTypeId.PersistenceStopping, messageBytes)
            });

            var retrievedMessage = DataContext.PersistentMessages.Execute().ExpectedSingle();

            retrievedMessage.TransportMessage.ShouldBeNull();
            retrievedMessage.BucketId.ShouldEqual(GetBucketIdFromDateTime(timestamp));
            retrievedMessage.IsAcked.ShouldBeTrue();
            retrievedMessage.PeerId.ShouldEqual(peerId);
            retrievedMessage.UniqueTimestampInTicks.ShouldEqual(timestamp.Ticks);
        }
예제 #2
0
        public async Task should_write_ZebusV2_ack_entry_fields_to_cassandra()
        {
            var timestamp = DateTime.UtcNow;
            var messageId = new MessageId(MessageIdV2.CreateNewSequentialId(timestamp.Ticks));
            var peerId    = "Abc.Peer.0";

            await _storage.Write(new List <MatcherEntry> {
                MatcherEntry.Ack(new PeerId(peerId), messageId)
            });

            var retrievedMessage = DataContext.PersistentMessages.Execute().ExpectedSingle();

            retrievedMessage.TransportMessage.ShouldBeNull();
            retrievedMessage.BucketId.ShouldEqual(GetBucketIdFromDateTime(timestamp));
            retrievedMessage.IsAcked.ShouldBeTrue();
            retrievedMessage.PeerId.ShouldEqual(peerId);
            retrievedMessage.UniqueTimestampInTicks.ShouldEqual(timestamp.Ticks);
            var writeTimeRow = DataContext.Session.Execute("SELECT WRITETIME(\"IsAcked\") FROM \"PersistentMessage\";").ExpectedSingle();

            writeTimeRow.GetValue <long>(0).ShouldEqual(ToUnixMicroSeconds(timestamp) + 1);
        }
예제 #3
0
        public async Task should_write_ZebusV2_message_entry_fields_to_cassandra()
        {
            var messageBytes = new byte[512];

            new Random().NextBytes(messageBytes);
            var timestamp = DateTime.UtcNow;
            var messageId = new MessageId(MessageIdV2.CreateNewSequentialId(timestamp.Ticks));
            var peerId    = "Abc.Peer.0";

            await _storage.Write(new List <MatcherEntry> {
                MatcherEntry.Message(new PeerId(peerId), messageId, MessageTypeId.PersistenceStopping, messageBytes)
            });

            var retrievedMessage = DataContext.PersistentMessages.Execute().ExpectedSingle();

            retrievedMessage.TransportMessage.ShouldBeEquivalentTo(messageBytes, true);
            retrievedMessage.BucketId.ShouldEqual(GetBucketIdFromDateTime(timestamp));
            retrievedMessage.IsAcked.ShouldBeFalse();
            retrievedMessage.PeerId.ShouldEqual(peerId);
            retrievedMessage.UniqueTimestampInTicks.ShouldEqual(timestamp.Ticks);
            var writeTimeRow = DataContext.Session.Execute("SELECT WRITETIME(\"IsAcked\") FROM \"PersistentMessage\";").ExpectedSingle();

            writeTimeRow.GetValue <long>(0).ShouldEqual(ToUnixMicroSeconds(timestamp));
        }