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)); }
public void ControlReleaseSkippedWhenBatchIsDisabled() { // register the batch again so as to disable it BatchAdapter.RegisterBatch(_envelopeSpecName, null, false, 3); BatchAdapter.AddPart(_envelopeSpecName, null, ActivityId.NewActivityId(), "<data>some-value</data>"); BatchAdapter.CreateReleaseMessage(_envelopeSpecName, null).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); 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)); 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)); Assert.That(BatchAdapter.QueuedControlledReleases.Count(), Is.EqualTo(0)); }
public void AddPartToPartitionedBatch() { 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 && p.Value3 == "partition-z"); process.SingleMessagingStep( s => s.Name == BizTalkFactoryApplication.ReceiveLocation <UnitTestBatchAddPartReceiveLocation>().Name && s.MessageType == new SchemaMetadata <Any>().MessageType && s.Status == TrackingStatus.Received && _envelopeSpecName.StartsWith(s.Value1, StringComparison.Ordinal) && s.Value3 == "partition-z"); var addPartMessage = process.SingleMessagingStep( s => s.Name == BizTalkFactoryApplication.SendPort <BatchAddPartSendPort>().Name && s.MessageType == new SchemaMetadata <Any>().MessageType && s.Status == TrackingStatus.Sent && _envelopeSpecName.StartsWith(s.Value1, StringComparison.Ordinal) && s.Value3 == "partition-z"); var part = BatchAdapter.Parts.Single(); Assert.That(part.MessagingStepActivityId, Is.EqualTo(addPartMessage.ActivityID)); Assert.That(part.Partition, Is.EqualTo("partition-z")); }
public void TearDown() { // ensure the batch is enabled BatchAdapter.RegisterBatch(_envelopeSpecName, null, true, 3); BatchAdapter.ClearQueuedReleases(); BatchAdapter.ClearParts(); }
public void TestFixtureTearDown() { BatchAdapter.UnregisterBatch("e-one", "p-two"); BatchAdapter.UnregisterBatch("e-one", "p-one"); BatchAdapter.UnregisterBatch("e-one", null); BatchAdapter.UnregisterBatch(_envelopeSpecName, "p-count-limit"); BatchAdapter.UnregisterBatch(_envelopeSpecName, "p-two"); BatchAdapter.UnregisterBatch(_envelopeSpecName, "p-one"); BatchAdapter.UnregisterBatch(_envelopeSpecName, null); }
public void TestFixtureSetUp() { BatchAdapter.RegisterBatch(_envelopeSpecName, null, true, 3); BatchAdapter.RegisterBatch(_envelopeSpecName, "p-one", true, 3); BatchAdapter.RegisterBatch(_envelopeSpecName, "p-two", true, 3); BatchAdapter.RegisterBatch(_envelopeSpecName, "p-count-limit", true, 3, true); BatchAdapter.RegisterBatch("e-one", null, true, 10); BatchAdapter.RegisterBatch("e-one", "p-one", true, 10); BatchAdapter.RegisterBatch("e-one", "p-two", true, 10); }
public void BatchReleaseIsRuledBySpecificPartitionPolicy() { // insert parts for an envelope that does have a partition-specific release policy BatchAdapter.AddPart(_envelopeSpecName, "p-one", ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); BatchAdapter.AddPart(_envelopeSpecName, "p-one", ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); var sut = BatchAdapter.ReleasePolicies.Single(); Assert.That(sut.EnvelopeId, Is.EqualTo(BatchAdapter.Envelopes.Single(e => e.SpecName == _envelopeSpecName).Id)); Assert.That(sut.Partition, Is.EqualTo("p-one")); Assert.That(sut.Enabled, Is.False); Assert.That(sut.ReleaseOnItemCount, Is.EqualTo(7)); }
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>")); }
public void ControlReleaseOneEnvelopeAndAllPartitions() { BatchAdapter.AddPart(_envelopeSpecName, null, ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); BatchAdapter.AddPart(_envelopeSpecName, "p-one", ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); BatchAdapter.AddPart(_envelopeSpecName, "p-two", ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); BatchAdapter.AddPart(_envelopeSpecName, "p-six", ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); BatchAdapter.AddPart("e-one", null, ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); BatchAdapter.AddPart("e-one", "p-one", ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); BatchAdapter.AddPart("e-one", "p-two", ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); BatchAdapter.AddPart("e-one", "p-six", ActivityId.NewActivityId(), "<data>some-partitioned-value</data>"); BatchAdapter.CreateReleaseMessage(_envelopeSpecName, "*").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 && p.Status == TrackingStatus.Completed && _envelopeSpecName.StartsWith(p.Value1) && p.Value3 == "*"); 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 == "*"); 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 == "*"); var queuedControlledReleases = BatchAdapter.QueuedControlledReleases.ToArray(); Assert.That( queuedControlledReleases.Count(), Is.EqualTo(4)); Assert.That( queuedControlledReleases.Select(qcr => qcr.EnvelopeId).Distinct().Single(), Is.EqualTo(BatchAdapter.Envelopes.Single(e => e.SpecName == _envelopeSpecName).Id)); Assert.That( queuedControlledReleases.Select(qcr => qcr.Partition), Is.EquivalentTo(new[] { "0", "p-one", "p-two", "p-six" })); }
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)); }
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"); }
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); }
public void TearDown() { BatchAdapter.ClearParts(); BatchAdapter.UnregisterBatch(_envelopeSpecName, null); }
public void Setup() { BatchAdapter.RegisterBatch(_envelopeSpecName, null, true, 3); }
public void Setup() { BatchAdapter.RegisterBatch(_envelopeSpecName, null, true, 3); BatchAdapter.RegisterBatch(_envelopeSpecName, "p-one", false, 7); }