예제 #1
0
        public void TrackBatchReleasedOnPollingWhenNoMessagingStepActivityIds()
        {
            BatchAdapter.AddPart(_envelopeSpecName, "partition-z", null, "<data>some-partitioned-value</data>");
            BatchAdapter.AddPart(_envelopeSpecName, "partition-z", null, "<data>some-partitioned-value</data>");
            BatchAdapter.AddPart(_envelopeSpecName, "partition-z", null, "<data>some-partitioned-value</data>");

            BatchReleasePort.Enable();

            // batch content handling process
            var process = TrackingRepository.SingleProcess(
                p => p.Name == Default.Processes.Unidentified &&
                p.BeginTime > StartTime &&
                p.Status == TrackingStatus.Completed &&
                _envelopeSpecName.StartsWith(p.Value1) &&
                p.Value3 == "partition-z");
            var releaseProcessBatchMessagingStep = process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.ReceiveLocation <BatchReceiveLocation>().Name
                // TODO && s.MessageType == new SchemaMetadata<BatchContent>().MessageType
                && s.Status == TrackingStatus.Received);

            process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.SendPort <UnitTestBatchReleaseSendPort>().Name &&
                s.Status == TrackingStatus.Sent &&
                s.MessageType == new SchemaMetadata <Envelope>().MessageType &&
                _envelopeSpecName.StartsWith(s.Value1) &&
                s.Value3 == "partition-z");

            // no batch release process has been created as no parts provide a MessagingStepActivityId that could be used to link a part to its batch
            Assert.That(releaseProcessBatchMessagingStep.Processes.Count(p => p.Name == Factory.Areas.Batch.Processes.Release && p.BeginTime > StartTime), Is.EqualTo(0));
        }
예제 #2
0
        public void ControlReleaseOneEnvelopeAndOnePartition()
        {
            BatchAdapter.AddPart(_envelopeSpecName, "partition-z", ActivityId.NewActivityId(), "<data>some-partitioned-value</data>");
            BatchAdapter.CreateReleaseMessage(_envelopeSpecName, "partition-z").DropToFolder(DropFolders.INPUT_FOLDER, "release_batch.xml");

            // batch controlled release process
            var process = TrackingRepository.SingleProcess(
                p => p.Name == Factory.Areas.Batch.Processes.Release &&
                p.BeginTime > StartTime &&
                p.Status == TrackingStatus.Completed &&
                _envelopeSpecName.StartsWith(p.Value1) &&
                p.Value3 == "partition-z");

            process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.ReceiveLocation <UnitTestInputMessageReceiveLocation>().Name &&
                s.MessageType == new SchemaMetadata <Schemas.Xml.Batch.Release>().MessageType &&
                s.Status == TrackingStatus.Received &&
                _envelopeSpecName.StartsWith(s.Value1) &&
                s.Value3 == "partition-z");
            process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.SendPort <BatchQueueControlledReleaseSendPort>().Name &&
                s.MessageType == new SchemaMetadata <Schemas.Xml.Batch.Release>().MessageType &&
                s.Status == TrackingStatus.Sent &&
                _envelopeSpecName.StartsWith(s.Value1) &&
                s.Value3 == "partition-z");

            Assert.That(BatchAdapter.QueuedControlledReleases.Count(), Is.EqualTo(1));
            BatchReleasePort.Enable();

            // batch content handling process
            process = TrackingRepository.SingleProcess(
                p => p.Name == Default.Processes.Unidentified &&
                p.BeginTime > StartTime &&
                p.Status == TrackingStatus.Completed &&
                _envelopeSpecName.StartsWith(p.Value1) &&
                p.Value3 == "partition-z");
            process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.ReceiveLocation <BatchReceiveLocation>().Name
                // TODO && s.MessageType == new SchemaMetadata<BatchContent>().MessageType
                && s.Status == TrackingStatus.Received);
            var envelopeMessagingStep = process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.SendPort <UnitTestBatchReleaseSendPort>().Name &&
                s.Status == TrackingStatus.Sent &&
                s.MessageType == new SchemaMetadata <Envelope>().MessageType &&
                _envelopeSpecName.StartsWith(s.Value1) &&
                s.Value3 == "partition-z");

            Assert.That(
                envelopeMessagingStep.Message.Body,
                Is.EqualTo("<ns0:Envelope xmlns:ns0=\"urn:schemas.stateless.be:biztalk:envelope:2013:07\"><data>some-partitioned-value</data></ns0:Envelope>"));
        }
예제 #3
0
        public void PollForAvailableBatchesWithItemCountSizeLimit()
        {
            // drop more items than twice the item count limit, which is 3, so as to release two batches
            for (var i = 0; i < 8; i++)
            {
                BatchAdapter.AddPart(_envelopeSpecName, "p-count-limit", ActivityId.NewActivityId(), string.Format("<data>count-limit-value-{0}</data>", i));
            }

            BatchReleasePort.Enable();

            // batch content handling processes
            var processesQuery = TrackingRepository.Processes.Where(
                p => p.Name == Default.Processes.Unidentified &&
                p.BeginTime > StartTime &&
                p.Status == TrackingStatus.Completed &&
                _envelopeSpecName.StartsWith(p.Value1) &&
                p.Value3 == "p-count-limit");

            // 2 processes have been tracked as more items than twice the item count limit have been accumulated
            Assert.That(() => processesQuery.Count(), Is.EqualTo(2).After(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(1)));
            var processes = processesQuery.ToArray();

            // ensure the 2 processes are issued from the same polling, thereby validating that all available batches are
            // released in one shot (i.e., in DEV, one within one second of the other, when polling every 5 seconds)
            Assert.That(processes[0].BeginTime, Is.EqualTo(processes[1].BeginTime).Within(TimeSpan.FromSeconds(1)));

            // each batch is made of 3 parts
            var envelopeMessage1 = processes[0].MessagingSteps.Single(
                s => s.Name == BizTalkFactoryApplication.SendPort <UnitTestBatchReleaseSendPort>().Name &&
                s.MessageType == new SchemaMetadata <Envelope>().MessageType &&
                s.Status == TrackingStatus.Sent &&
                _envelopeSpecName.StartsWith(s.Value1) &&
                s.Value3 == "p-count-limit");

            Assert.That(Regex.Matches(envelopeMessage1.Message.Body, @"<data>count-limit-value-\d</data>").Count, Is.EqualTo(3));
            var envelopeMessage2 = processes[1].MessagingSteps.Single(
                s => s.Name == BizTalkFactoryApplication.SendPort <UnitTestBatchReleaseSendPort>().Name &&
                s.MessageType == new SchemaMetadata <Envelope>().MessageType &&
                s.Status == TrackingStatus.Sent &&
                _envelopeSpecName.StartsWith(s.Value1) &&
                s.Value3 == "p-count-limit");

            Assert.That(Regex.Matches(envelopeMessage2.Message.Body, @"<data>count-limit-value-\d</data>").Count, Is.EqualTo(3));

            // 2 parts have been left in the database
            Assert.That(BatchAdapter.Parts.Count(), Is.EqualTo(2));
        }
예제 #4
0
        public void PollForAvailableBatchesToRelease()
        {
            // create three-item partitioned batches, so as to trigger an automatic release via polling receive-location
            BatchAdapter.AddPart(_envelopeSpecName, "one", ActivityId.NewActivityId(), "<data>some-one-partitioned-value</data>");
            BatchAdapter.AddPart(_envelopeSpecName, "one", ActivityId.NewActivityId(), "<data>some-one-partitioned-value</data>");
            BatchAdapter.AddPart(_envelopeSpecName, "one", ActivityId.NewActivityId(), "<data>some-one-partitioned-value</data>");

            BatchAdapter.AddPart(_envelopeSpecName, "two", ActivityId.NewActivityId(), "<data>some-two-partitioned-value</data>");
            BatchAdapter.AddPart(_envelopeSpecName, "two", ActivityId.NewActivityId(), "<data>some-two-partitioned-value</data>");
            BatchAdapter.AddPart(_envelopeSpecName, "two", ActivityId.NewActivityId(), "<data>some-two-partitioned-value</data>");

            BatchAdapter.AddPart(_envelopeSpecName, "six", ActivityId.NewActivityId(), "<data>some-six-partitioned-value</data>");
            BatchAdapter.AddPart(_envelopeSpecName, "six", ActivityId.NewActivityId(), "<data>some-six-partitioned-value</data>");
            BatchAdapter.AddPart(_envelopeSpecName, "six", ActivityId.NewActivityId(), "<data>some-six-partitioned-value</data>");

            BatchReleasePort.Enable();

            // batch content handling processes
            TrackingRepository.SingleProcess(
                p => p.Name == Default.Processes.Unidentified &&
                p.BeginTime > StartTime &&
                p.Status == TrackingStatus.Completed &&
                _envelopeSpecName.StartsWith(p.Value1) &&
                p.Value3 == "one");
            TrackingRepository.SingleProcess(
                p => p.Name == Default.Processes.Unidentified &&
                p.BeginTime > StartTime &&
                p.Status == TrackingStatus.Completed &&
                _envelopeSpecName.StartsWith(p.Value1) &&
                p.Value3 == "two");
            TrackingRepository.SingleProcess(
                p => p.Name == Default.Processes.Unidentified &&
                p.BeginTime > StartTime &&
                p.Status == TrackingStatus.Completed &&
                _envelopeSpecName.StartsWith(p.Value1) &&
                p.Value3 == "six");
        }
예제 #5
0
        public void TrackBatchReleasedOnPolling()
        {
            BatchAdapter.CreatePartMessage(_envelopeSpecName, "partition-z").DropToFolder(DropFolders.INPUT_FOLDER, "part.xml.part");
            var process = TrackingRepository.SingleProcess(
                p => p.Name == Factory.Areas.Batch.Processes.Aggregate &&
                p.BeginTime > StartTime);
            var addPartMessage1 = process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.SendPort <BatchAddPartSendPort>().Name &&
                s.MessageType == new SchemaMetadata <Any>().MessageType &&
                s.Status == TrackingStatus.Sent &&
                _envelopeSpecName.StartsWith(s.Value1) &&
                s.Value3 == "partition-z");

            BatchAdapter.CreatePartMessage(_envelopeSpecName, "partition-z").DropToFolder(DropFolders.INPUT_FOLDER, "part.xml.part");
            process = TrackingRepository.SingleProcess(
                p => p.Name == Factory.Areas.Batch.Processes.Aggregate
                // ReSharper disable once AccessToModifiedClosure
                && p.BeginTime > process.EndTime);
            var addPartMessage2 = process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.SendPort <BatchAddPartSendPort>().Name &&
                s.MessageType == new SchemaMetadata <Any>().MessageType &&
                s.Status == TrackingStatus.Sent &&
                _envelopeSpecName.StartsWith(s.Value1) &&
                s.Value3 == "partition-z");

            BatchAdapter.CreatePartMessage(_envelopeSpecName, "partition-z").DropToFolder(DropFolders.INPUT_FOLDER, "part.xml.part");
            process = TrackingRepository.SingleProcess(
                p => p.Name == Factory.Areas.Batch.Processes.Aggregate
                // ReSharper disable once AccessToModifiedClosure
                && p.BeginTime > process.EndTime);
            var addPartMessage3 = process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.SendPort <BatchAddPartSendPort>().Name &&
                s.MessageType == new SchemaMetadata <Any>().MessageType &&
                s.Status == TrackingStatus.Sent &&
                _envelopeSpecName.StartsWith(s.Value1) &&
                s.Value3 == "partition-z");

            BatchReleasePort.Enable();

            // batch controlled release process
            process = TrackingRepository.SingleProcess(
                p => p.Name == Factory.Areas.Batch.Processes.Release &&
                p.BeginTime > StartTime &&
                p.Status == TrackingStatus.Completed);
            // 1st part
            process.SingleMessagingStep(s => s.ActivityID == addPartMessage1.ActivityID);
            // 2nd part
            process.SingleMessagingStep(s => s.ActivityID == addPartMessage2.ActivityID);
            // 3rd part
            process.SingleMessagingStep(s => s.ActivityID == addPartMessage3.ActivityID);
            // batch content
            var releaseProcessBatchMessagingStep = process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.ReceiveLocation <BatchReceiveLocation>().Name
                // TODO && s.MessageType == new SchemaMetadata<BatchContent>().MessageType
                && s.Status == TrackingStatus.Received);

            // batch content handling process
            process = TrackingRepository.SingleProcess(
                p => p.Name == Default.Processes.Unidentified &&
                p.BeginTime > StartTime &&
                p.Status == TrackingStatus.Completed &&
                _envelopeSpecName.StartsWith(p.Value1) &&
                p.Value3 == "partition-z");
            var handlingProcessBatchMessagingStep = process.SingleMessagingStep(
                s => s.Name == BizTalkFactoryApplication.ReceiveLocation <BatchReceiveLocation>().Name
                // TODO && s.MessageType == new SchemaMetadata<BatchContent>().MessageType
                && s.Status == TrackingStatus.Received);

            Assert.That(releaseProcessBatchMessagingStep.ActivityID, Is.EqualTo(handlingProcessBatchMessagingStep.ActivityID));

            // a part is linked to both its aggregate and release processes
            Assert.That(addPartMessage1.Processes.Count(), Is.EqualTo(2));
            Assert.That(addPartMessage1.Processes.SingleOrDefault(p => p.Name == Factory.Areas.Batch.Processes.Aggregate), Is.Not.Null);
            Assert.That(addPartMessage1.Processes.SingleOrDefault(p => p.Name == Factory.Areas.Batch.Processes.Release), Is.Not.Null);

            // a batch is linked to both its release and handling processes
            Assert.That(releaseProcessBatchMessagingStep.Processes.Count(), Is.EqualTo(2));
            Assert.That(releaseProcessBatchMessagingStep.Processes.SingleOrDefault(p => p.Name == Factory.Areas.Batch.Processes.Release), Is.Not.Null);
            Assert.That(releaseProcessBatchMessagingStep.Processes.SingleOrDefault(p => p.Name == Default.Processes.Unidentified), Is.Not.Null);
        }