From 16733dd60984f1a1369c8e395fb8a2c710c731ff Mon Sep 17 00:00:00 2001 From: SzymonPobiega Date: Wed, 10 Aug 2016 16:27:16 +0200 Subject: [PATCH] Updated to new recoverability design in the core. --- .../When_sending_a_non_durable_message.cs | 53 --- .../PipelineExt/FilteringWhatGetsAudited.cs | 167 ------- .../PipelineExt/MutingHandlerExceptions.cs | 115 ----- .../When_performing_slr_with_custom_policy.cs | 86 ---- .../When_dispatching_transport_operations.cs | 78 ---- .../When_sending_to_non_durable_endpoint.cs | 63 --- .../When_extending_sendoptions.cs | 0 .../When_extending_the_publish_api.cs | 0 .../Audit/When_a_message_is_audited.cs | 0 .../Audit/When_a_replymessage_is_audited.cs | 0 .../Audit/When_audit_is_overridden_in_code.cs | 0 .../Audit/When_auditing.cs | 0 ..._auditing_message_with_TimeToBeReceived.cs | 0 .../Basic/When_aborting_the_behavior_chain.cs | 0 .../Basic/When_deferring_to_non_local.cs | 0 .../Basic/When_depending_on_typed_feature.cs | 76 +++ .../When_depending_on_untyped_feature.cs | 76 +++ .../Basic/When_extending_behavior_context.cs | 0 .../When_handling_current_message_later.cs | 4 +- ...ng_message_with_several_messagehandlers.cs | 0 .../Basic/When_multiple_mappings_exists.cs | 0 .../Basic/When_no_content_type.cs | 0 ...ving_with_catch_all_handlers_registered.cs | 0 .../When_registering_handlers_explicitly.cs | 0 .../Basic/When_sending_from_a_send_only.cs | 0 .../Basic/When_sending_to_another_endpoint.cs | 0 .../Basic/When_sending_with_conventions.cs | 42 +- .../Basic/When_using_a_greedy_convention.cs | 11 +- .../BestPractices/When_publishing_command.cs | 0 ...blishing_command_bestpractices_disabled.cs | 6 +- ...mand_bestpractices_disabled_on_endpoint.cs | 8 +- .../BestPractices/When_sending_event.cs | 0 ...n_sending_events_bestpractices_disabled.cs | 5 +- ...ents_bestpractices_disabled_on_endpoint.cs | 6 +- .../When_subscribing_to_command.cs | 0 ...mand_bestpractices_disabled_on_endpoint.cs | 10 +- .../When_unsubscribing_to_command.cs | 0 ...mand_bestpractices_disabled_on_endpoint.cs | 6 +- .../Causation/When_a_message_is_audited.cs | 0 .../Causation/When_a_message_is_faulted.cs | 2 - .../Causation/When_a_message_is_sent.cs | 0 ...injecting_message_session_into_handlers.cs | 45 ++ ..._only_abstract_config_override_is_found.cs | 6 +- .../Config/When_startup_is_complete.cs | 0 .../ConfigureEndpointInMemoryPersistence.cs | 0 .../ConfigureEndpointMsmqTransport.cs | 2 +- .../ConventionEnforcementTests.cs | 0 ..._received_message_without_correlationid.cs | 0 .../When_sending_with_no_correlation_id.cs | 0 .../When_using_a_custom_correlation_id.cs | 0 .../When_raising_critical_error.cs | 0 .../When_sending_databus_properties.cs | 0 .../DataBus/When_using_custom_IDataBus.cs | 0 .../When_TimeoutManager_is_disabled.cs | 0 .../When_timeout_dispatch_fails.cs | 13 +- ..._dispatch_fails_on_timeout_data_removal.cs | 10 +- .../When_timeout_storage_fails.cs | 6 +- .../When_Deferring_a_message.cs | 0 .../When_deferring_a_message_to_the_past.cs | 0 .../DeterministicGuid.cs | 0 .../When_using_Rijndael_with_config.cs | 0 .../When_using_Rijndael_with_custom.cs | 0 .../When_using_Rijndael_with_multikey.cs | 0 ...ijndael_without_incoming_key_identifier.cs | 0 ...en_using_encryption_with_custom_service.cs | 0 .../EndpointTemplates/ConfigureExtensions.cs | 0 .../EndpointTemplates/DefaultPublisher.cs | 0 .../EndpointTemplates/DefaultServer.cs | 9 +- ...intCustomizationConfigurationExtensions.cs | 0 ...rverWithNoDefaultPersistenceDefinitions.cs | 5 +- .../When_ForwardReceivedMessagesTo_is_set.cs | 0 .../Hosting/When_a_message_is_audited.cs | 0 .../Hosting/When_a_message_is_faulted.cs | 2 - .../Hosting/When_feature_overrides_hostid.cs | 0 .../When_feature_overrides_hostinfo.cs | 0 .../When_overriding_local_addresses.cs | 0 .../When_sending_ensure_proper_headers.cs | 0 .../Licensing/When_a_message_is_audited.cs | 3 +- .../When_message_has_empty_id_header.cs | 0 .../When_message_has_no_id_header.cs | 0 .../Mutators/Issue_1980.cs | 0 ...When_defining_outgoing_message_mutators.cs | 0 ...n_incoming_mutator_changes_message_type.cs | 10 +- .../Mutators/When_mutating.cs | 0 ...When_outgoing_mutator_replaces_instance.cs | 0 .../When_using_outgoing_tm_mutator.cs | 0 .../NServiceBusAcceptanceTest.cs | 0 .../NonTx/When_sending_inside_ambient_tx.cs | 0 .../CriticalTime/When_CriticalTime_enabled.cs | 0 .../CriticalTime/When_deferring_a_message.cs | 0 .../When_slow_with_CriticalTime_enabled.cs | 0 .../SLA/When_sending_slow_with_SLA_enabled.cs | 2 +- .../SLA/When_sending_with_SLA_enabled.cs | 2 +- .../When_TimeToBeReceived_has_expired.cs | 0 ...TimeToBeReceived_has_expired_convention.cs | 0 .../When_TimeToBeReceived_has_not_expired.cs | 0 .../Performance/When_message_is_audited.cs | 0 .../Performance/When_message_is_faulted.cs | 0 .../Pipeline/When_replacing_behavior.cs | 0 ...using_per_uow_component_in_the_pipeline.cs | 119 +++++ .../Retries/When_Subscribing_to_errors.cs | 5 +- ...en_custom_policy_always_moves_to_error.cs} | 17 +- ...gle_delayed_retry_before_move_to_error.cs} | 25 +- .../Retries/When_custom_policy_executed.cs | 76 +++ .../Retries/When_custom_policy_provided.cs | 71 +++ .../When_doing_flr_with_default_settings.cs | 0 .../Retries/When_doing_flr_with_dtc_on.cs | 6 +- ...When_doing_flr_with_native_transactions.cs | 5 +- .../Recoverability/Retries/When_fails_flr.cs | 3 - .../When_fails_with_retries_set_to_0.cs | 2 - .../Retries/When_message_fails_retries.cs | 5 +- ...en_message_is_deferred_by_slr_using_dtc.cs | 2 - .../When_performing_slr_and_counting.cs | 6 +- .../When_performing_slr_with_flr_disabled.cs | 4 +- ...n_performing_slr_with_regular_exception.cs | 2 - ...orming_slr_with_serialization_exception.cs | 2 - ..._policy_moves_to_overridden_error_queue.cs | 87 ++++ .../When_error_is_overridden_in_code.cs | 2 - .../When_message_is_moved_to_error_queue.cs | 120 ++--- ...ssage_is_moved_to_error_queue_using_dtc.cs | 3 - ..._error_queue_with_header_customizations.cs | 99 ++++ ...hen_message_with_TimeToBeReceived_fails.cs | 2 - .../When_a_duplicate_message_arrives.cs | 0 .../Outbox/When_a_message_is_audited.cs | 0 .../When_blowing_up_just_after_dispatch.cs | 0 .../Outbox/When_clearing_saga_timeouts.cs | 6 +- .../When_dispatching_forwarded_messages.cs | 0 .../Outbox/When_receiving_a_message.cs | 0 .../When_sending_from_a_non_dtc_endpoint.cs | 0 .../When_starting_an_endpoint_with_a_saga.cs | 6 + ...oint_with_a_saga_autosubscribe_disabled.cs | 6 + ...starting_an_endpoint_with_autoSubscribe.cs | 0 .../Routing/SubscriptionBehavior.cs | 2 +- .../Routing/SubscriptionBehaviorExtensions.cs | 0 .../Routing/SubscriptionEventArgs.cs | 0 .../When_base_event_from_2_publishers.cs | 0 .../Routing/When_broadcasting_a_command.cs | 22 +- ...ists_but_routing_information_is_missing.cs | 6 +- ...lymorphic_event_on_multicast_transports.cs | 0 ...polymorphic_event_on_unicast_transports.cs | 7 +- .../Routing/When_publishing.cs | 0 ...t_implementing_two_unrelated_interfaces.cs | 0 .../Routing/When_publishing_an_interface.cs | 0 .../Routing/When_publishing_from_sendonly.cs | 3 +- ...out_subscribers_on_multicast_transports.cs | 8 +- ...d_out_subscribers_on_unicast_transports.cs | 12 +- .../When_publishing_using_root_type.cs | 0 ...lishing_with_only_local_messagehandlers.cs | 0 ...ublishing_with_overridden_local_address.cs | 0 .../Routing/When_replying_to_message.cs | 0 ...When_subscribing_to_a_polymorphic_event.cs | 32 +- ...embly_level_message_mapping_for_pub_sub.cs | 0 .../Routing/When_using_instance_ids.cs | 19 +- ...on_combined_with_message_driven_pub_sub.cs | 0 ..._to_a_message_sent_to_specific_instance.cs | 9 +- .../RunDescriptorExtensions.cs | 0 .../When_a_base_class_message_hits_a_saga.cs | 0 .../When_a_existing_saga_instance_exists.cs | 0 .../Sagas/When_a_finder_exists.cs | 3 +- ...er_exists_and_context_information_added.cs | 3 +- .../When_a_finder_exists_and_found_saga.cs | 26 +- ...hen_a_saga_message_goes_through_the_slr.cs | 1 - .../When_an_endpoint_replies_to_a_saga.cs | 0 ...hen_auto_correlated_property_is_changed.cs | 0 ...en_doing_request_response_between_sagas.cs | 0 ..._between_sagas_first_handler_responding.cs | 0 ...tween_sagas_response_from_noninitiating.cs | 0 ...est_response_between_sagas_with_timeout.cs | 0 .../When_forgetting_to_set_a_corr_property.cs | 0 .../Sagas/When_message_has_a_saga_id.cs | 0 .../When_receiving_that_completes_the_saga.cs | 0 ...When_receiving_that_should_start_a_saga.cs | 0 ...t_should_start_a_saga_with_interception.cs | 0 ...hould_start_a_saga_without_interception.cs | 0 ..._replies_to_message_published_by_a_saga.cs | 0 .../When_saga_handles_unmapped_message.cs | 123 +++++ .../When_saga_has_a_non_empty_constructor.cs | 0 .../Sagas/When_saga_id_changed.cs | 2 +- ...en_saga_is_mapped_to_complex_expression.cs | 0 .../Sagas/When_sagas_cant_be_found.cs | 0 .../Sagas/When_sending_from_a_saga_handle.cs | 0 .../Sagas/When_sending_from_a_saga_timeout.cs | 0 ...n_started_by_base_event_from_other_saga.cs | 2 +- ...When_started_by_event_from_another_saga.cs | 0 .../Sagas/When_timeout_hit_not_found_saga.cs | 0 ...n_two_sagas_subscribe_to_the_same_event.cs | 0 ..._updating_existing_correlation_property.cs | 0 .../Sagas/When_using_ReplyToOriginator.cs | 0 ...en_using_a_received_message_for_timeout.cs | 0 .../Sagas/When_using_contain_saga_data.cs | 0 .../Sagas/when_receiving_multiple_timeouts.cs | 2 +- .../when_reply_from_saga_not_found_handler.cs | 0 .../Satellites/When_a_message_is_available.cs | 67 +++ .../AllOutboxCapableStorages.cs | 0 .../ScenarioDescriptors/AllTransports.cs | 0 .../ScenarioDescriptors/Builders.cs | 0 .../ScenarioDescriptors/EnvironmentHelper.cs | 0 .../ScenarioDescriptors/Persistence.cs | 0 .../ScenarioDescriptors/Serializers.cs | 0 .../ScenarioDescriptors/Transports.cs | 2 +- .../When_scheduling_a_recurring_task.cs | 0 .../When_running_saga_tests.cs | 0 .../When_configuring_custom_xml_namespace.cs | 83 ++++ ...en_registering_additional_deserializers.cs | 46 +- .../When_registering_custom_serializer.cs | 4 +- .../When_sanitizing_xml_messages.cs | 88 ++++ .../Serialization/When_skip_wrapping_xml.cs | 92 ++++ .../When_wrapping_is_not_skipped.cs | 94 ++++ .../Timeout/CyclingOutageTimeoutPersister.cs | 2 +- ...eout_storage_is_unavailable_temporarily.cs | 0 .../Tx/FakePromotableResourceManager.cs | 0 ...immediate_dispatch_using_scope_suppress.cs | 3 +- ...g_immediate_dispatch_with_at_least_once.cs | 0 ...ng_immediate_dispatch_with_at_most_once.cs | 0 ...ng_immediate_dispatch_with_exactly_once.cs | 0 .../Tx/Issue_2481.cs | 0 .../Tx/When_receiving_with_dtc_enabled.cs | 0 ...ing_with_native_multi_queue_transaction.cs | 3 +- ...hen_receiving_with_the_default_settings.cs | 0 ...n_sending_within_an_ambient_transaction.cs | 0 .../UnicastPubSubExtensions.cs | 14 + ...iple_versions_of_a_message_is_published.cs | 0 .../ConfigureEndpointSqlServerTransport.cs | 4 +- ..._with_bracketed_transport_discriminator.cs | 7 +- ...schema_configured_with_message_mappings.cs | 8 +- ...configured_with_transport_discriminator.cs | 7 +- ...erviceBus.SqlServer.AcceptanceTests.csproj | 432 +++++++++--------- .../When_queue_contains_expired_messages.cs | 10 +- .../When_a_corrupted_message_is_received.cs | 5 +- .../packages.config | 8 +- ...rviceBus.SqlServer.IntegrationTests.csproj | 8 +- .../When_dispatching_messages.cs | 47 +- .../When_message_receive_takes_long.cs | 2 +- .../When_receiving_messages.cs | 3 +- .../When_using_transaction_scope.cs | 3 +- .../packages.config | 6 +- .../IConfigureTransportInfrastructure.cs | 27 ++ .../NServiceBusTransportTest.cs | 241 ++++++++++ .../TransportConfigurationResult.cs | 30 ++ .../When_failure_happens_after_send.cs | 52 +++ .../When_message_is_available.cs | 43 ++ .../When_on_error_throws.cs | 48 ++ .../When_on_message_throws.cs | 41 ++ ...n_on_message_throws_after_delayed_retry.cs | 51 +++ ...on_message_throws_after_immediate_retry.cs | 49 ++ .../When_requesting_immediate_retry.cs | 40 ++ .../When_scope_dispose_throws.cs | 69 +++ .../When_sending_from_on_error.cs | 44 ++ .../When_user_aborts_processing.cs | 47 ++ ...nfigureSqlServerTransportInfrastructure.cs | 69 +++ ...ServiceBus.SqlServer.TransportTests.csproj | 87 ++++ .../packages.config | 6 + .../APIApprovals.Approve.approved.txt | 4 +- .../NServiceBus.SqlServer.UnitTests.csproj | 11 +- .../Receiving/FailureInfoStorageTests.cs | 127 +++++ .../Sending/MessageDispatcherTests.cs | 6 +- .../packages.config | 5 +- src/NServiceBus.SqlServer.sln | 8 +- .../MultiInstance/LegacyQueueCreator.cs | 2 +- .../LegacyReceiveWithTransactionScope.cs | 107 +++-- .../LegacySqlServerTransportInfrastructure.cs | 4 +- .../LegacyTableBasedQueueDispatcher.cs | 3 +- .../NServiceBus.SqlServer.csproj | 6 +- .../Queuing/TableBasedQueue.cs | 2 +- .../Receiving/FailureInfoStorage.cs | 108 +++++ .../Receiving/MessagePump.cs | 11 +- .../Receiving/QueueCreator.cs | 2 +- .../Receiving/ReceiveStrategy.cs | 68 ++- .../Receiving/ReceiveWithNativeTransaction.cs | 127 +++++ .../Receiving/ReceiveWithNoTransaction.cs | 40 +- .../ReceiveWithReceiveOnlyTransaction.cs | 81 ---- ...veWithSendsAtomicWithReceiveTransaction.cs | 77 ---- .../Receiving/ReceiveWithTransactionScope.cs | 108 +++-- .../Sending/IQueueDispatcher.cs | 3 +- .../Sending/MessageDispatcher.cs | 6 +- .../Sending/MessageWithAddress.cs | 2 +- .../Sending/TableBasedQueueDispatcher.cs | 22 +- .../Sending/UsingV2ConfigurationChecker.cs | 2 +- .../SqlServerTransport.cs | 4 +- .../SqlServerTransportInfrastructure.cs | 10 +- src/NServiceBus.SqlServer/packages.config | 2 +- 281 files changed, 3440 insertions(+), 1402 deletions(-) delete mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/MessageDurability/When_sending_a_non_durable_message.cs delete mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PipelineExt/FilteringWhatGetsAudited.cs delete mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PipelineExt/MutingHandlerExceptions.cs delete mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_custom_policy.cs delete mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_dispatching_transport_operations.cs delete mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Volatile/When_sending_to_non_durable_endpoint.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ApiExtension/When_extending_sendoptions.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ApiExtension/When_extending_the_publish_api.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Audit/When_a_message_is_audited.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Audit/When_a_replymessage_is_audited.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Audit/When_audit_is_overridden_in_code.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Audit/When_auditing.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Audit/When_auditing_message_with_TimeToBeReceived.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_aborting_the_behavior_chain.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_deferring_to_non_local.cs (100%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_depending_on_typed_feature.cs create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_depending_on_untyped_feature.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_extending_behavior_context.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_handling_current_message_later.cs (97%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_handling_message_with_several_messagehandlers.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_multiple_mappings_exists.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_no_content_type.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_receiving_with_catch_all_handlers_registered.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_registering_handlers_explicitly.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_sending_from_a_send_only.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_sending_to_another_endpoint.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_sending_with_conventions.cs (50%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Basic/When_using_a_greedy_convention.cs (83%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_publishing_command.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_publishing_command_bestpractices_disabled.cs (93%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs (91%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_sending_event.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_sending_events_bestpractices_disabled.cs (92%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_sending_events_bestpractices_disabled_on_endpoint.cs (91%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_subscribing_to_command.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_subscribing_to_command_bestpractices_disabled_on_endpoint.cs (90%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_unsubscribing_to_command.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/BestPractices/When_unsubscribing_to_command_bestpractices_disabled_on_endpoint.cs (92%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Causation/When_a_message_is_audited.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Causation/When_a_message_is_faulted.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Causation/When_a_message_is_sent.cs (100%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Config/When_injecting_message_session_into_handlers.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Config/When_only_abstract_config_override_is_found.cs (90%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Config/When_startup_is_complete.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ConfigureEndpointInMemoryPersistence.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ConfigureEndpointMsmqTransport.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ConventionEnforcementTests.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Correlation/When_replying_to_received_message_without_correlationid.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Correlation/When_sending_with_no_correlation_id.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Correlation/When_using_a_custom_correlation_id.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/CriticalError/When_raising_critical_error.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/DataBus/When_sending_databus_properties.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/DataBus/When_using_custom_IDataBus.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/DelayedDelivery/TimeoutManager/When_TimeoutManager_is_disabled.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails.cs (97%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails_on_timeout_data_removal.cs (96%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/DelayedDelivery/TimeoutManager/When_timeout_storage_fails.cs (96%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/DelayedDelivery/When_Deferring_a_message.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/DelayedDelivery/When_deferring_a_message_to_the_past.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/DeterministicGuid.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Encryption/When_using_Rijndael_with_config.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Encryption/When_using_Rijndael_with_custom.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Encryption/When_using_Rijndael_with_multikey.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Encryption/When_using_Rijndael_without_incoming_key_identifier.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Encryption/When_using_encryption_with_custom_service.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/EndpointTemplates/ConfigureExtensions.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/EndpointTemplates/DefaultPublisher.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/EndpointTemplates/DefaultServer.cs (89%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/EndpointTemplates/EndpointCustomizationConfigurationExtensions.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/EndpointTemplates/ServerWithNoDefaultPersistenceDefinitions.cs (91%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Forwarding/When_ForwardReceivedMessagesTo_is_set.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Hosting/When_a_message_is_audited.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Hosting/When_a_message_is_faulted.cs (97%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Hosting/When_feature_overrides_hostid.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Hosting/When_feature_overrides_hostinfo.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Hosting/When_overriding_local_addresses.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Hosting/When_sending_ensure_proper_headers.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Licensing/When_a_message_is_audited.cs (95%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/MessageId/When_message_has_empty_id_header.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/MessageId/When_message_has_no_id_header.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Mutators/Issue_1980.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Mutators/When_defining_outgoing_message_mutators.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Mutators/When_incoming_mutator_changes_message_type.cs (86%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Mutators/When_mutating.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Mutators/When_outgoing_mutator_replaces_instance.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Mutators/When_using_outgoing_tm_mutator.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/NServiceBusAcceptanceTest.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/NonTx/When_sending_inside_ambient_tx.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/PerfMon/CriticalTime/When_CriticalTime_enabled.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/PerfMon/CriticalTime/When_deferring_a_message.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/PerfMon/CriticalTime/When_slow_with_CriticalTime_enabled.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/PerfMon/SLA/When_sending_slow_with_SLA_enabled.cs (94%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/PerfMon/SLA/When_sending_with_SLA_enabled.cs (94%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired_convention.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Performance/TimeToBeReceived/When_TimeToBeReceived_has_not_expired.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Performance/When_message_is_audited.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Performance/When_message_is_faulted.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Pipeline/When_replacing_behavior.cs (100%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Pipeline/When_using_per_uow_component_in_the_pipeline.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_Subscribing_to_errors.cs (92%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_min_policy.cs => NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_always_moves_to_error.cs} (76%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_non_min_policy.cs => NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_does_single_delayed_retry_before_move_to_error.cs} (73%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_executed.cs create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_provided.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_doing_flr_with_default_settings.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_doing_flr_with_dtc_on.cs (89%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_doing_flr_with_native_transactions.cs (92%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_fails_flr.cs (95%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_fails_with_retries_set_to_0.cs (96%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_message_fails_retries.cs (92%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_message_is_deferred_by_slr_using_dtc.cs (96%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_performing_slr_and_counting.cs (85%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_performing_slr_with_flr_disabled.cs (90%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_performing_slr_with_regular_exception.cs (96%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/Retries/When_performing_slr_with_serialization_exception.cs (96%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_custom_policy_moves_to_overridden_error_queue.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/When_error_is_overridden_in_code.cs (96%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/When_message_is_moved_to_error_queue.cs (52%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/When_message_is_moved_to_error_queue_using_dtc.cs (95%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue_with_header_customizations.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Recoverability/When_message_with_TimeToBeReceived_fails.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Reliability/Outbox/When_a_duplicate_message_arrives.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Reliability/Outbox/When_a_message_is_audited.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Reliability/Outbox/When_blowing_up_just_after_dispatch.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Reliability/Outbox/When_clearing_saga_timeouts.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Reliability/Outbox/When_dispatching_forwarded_messages.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Reliability/Outbox/When_receiving_a_message.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Reliability/Outbox/When_sending_from_a_non_dtc_endpoint.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs (89%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs (89%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_autoSubscribe.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/SubscriptionBehavior.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/SubscriptionBehaviorExtensions.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/SubscriptionEventArgs.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_base_event_from_2_publishers.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_broadcasting_a_command.cs (80%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_handler_exists_but_routing_information_is_missing.cs (91%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_multi_subscribing_to_a_polymorphic_event_on_multicast_transports.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_multi_subscribing_to_a_polymorphic_event_on_unicast_transports.cs (91%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_publishing.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_publishing_an_event_implementing_two_unrelated_interfaces.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_publishing_an_interface.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_publishing_from_sendonly.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_publishing_to_scaled_out_subscribers_on_multicast_transports.cs (94%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_publishing_to_scaled_out_subscribers_on_unicast_transports.cs (89%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_publishing_using_root_type.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_publishing_with_only_local_messagehandlers.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_publishing_with_overridden_local_address.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_replying_to_message.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_subscribing_to_a_polymorphic_event.cs (75%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_using_assembly_level_message_mapping_for_pub_sub.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_using_instance_ids.cs (71%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/When_using_legacy_routing_configuration_combined_with_message_driven_pub_sub.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Routing/when_replying_to_a_message_sent_to_specific_instance.cs (83%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/RunDescriptorExtensions.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_a_base_class_message_hits_a_saga.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_a_existing_saga_instance_exists.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_a_finder_exists.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_a_finder_exists_and_context_information_added.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_a_finder_exists_and_found_saga.cs (69%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_a_saga_message_goes_through_the_slr.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_an_endpoint_replies_to_a_saga.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_auto_correlated_property_is_changed.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_doing_request_response_between_sagas.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_doing_request_response_between_sagas_first_handler_responding.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_doing_request_response_between_sagas_response_from_noninitiating.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_doing_request_response_between_sagas_with_timeout.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_forgetting_to_set_a_corr_property.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_message_has_a_saga_id.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_receiving_that_completes_the_saga.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_receiving_that_should_start_a_saga.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_receiving_that_should_start_a_saga_with_interception.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_receiving_that_should_start_a_saga_without_interception.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_replies_to_message_published_by_a_saga.cs (100%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_handles_unmapped_message.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_saga_has_a_non_empty_constructor.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_saga_id_changed.cs (94%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_saga_is_mapped_to_complex_expression.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_sagas_cant_be_found.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_sending_from_a_saga_handle.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_sending_from_a_saga_timeout.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_started_by_base_event_from_other_saga.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_started_by_event_from_another_saga.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_timeout_hit_not_found_saga.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_two_sagas_subscribe_to_the_same_event.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_updating_existing_correlation_property.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_using_ReplyToOriginator.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_using_a_received_message_for_timeout.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/When_using_contain_saga_data.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/when_receiving_multiple_timeouts.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Sagas/when_reply_from_saga_not_found_handler.cs (100%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Satellites/When_a_message_is_available.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ScenarioDescriptors/AllOutboxCapableStorages.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ScenarioDescriptors/AllTransports.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ScenarioDescriptors/Builders.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ScenarioDescriptors/EnvironmentHelper.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ScenarioDescriptors/Persistence.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ScenarioDescriptors/Serializers.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/ScenarioDescriptors/Transports.cs (98%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Scheduling/When_scheduling_a_recurring_task.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/SelfVerification/When_running_saga_tests.cs (100%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_configuring_custom_xml_namespace.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003/Basic => NSB.AcceptanceTests.6.0.0-beta0006/Serialization}/When_registering_additional_deserializers.cs (64%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003/Basic => NSB.AcceptanceTests.6.0.0-beta0006/Serialization}/When_registering_custom_serializer.cs (97%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_sanitizing_xml_messages.cs create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_skip_wrapping_xml.cs create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_wrapping_is_not_skipped.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Timeout/CyclingOutageTimeoutPersister.cs (97%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Timeout/When_timeout_storage_is_unavailable_temporarily.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/FakePromotableResourceManager.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_using_scope_suppress.cs (93%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_least_once.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_most_once.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_exactly_once.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/Issue_2481.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/When_receiving_with_dtc_enabled.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/When_receiving_with_native_multi_queue_transaction.cs (96%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/When_receiving_with_the_default_settings.cs (100%) rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Tx/When_sending_within_an_ambient_transaction.cs (100%) create mode 100644 src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/UnicastPubSubExtensions.cs rename src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/{NSB.AcceptanceTests.6.0.0-beta0003 => NSB.AcceptanceTests.6.0.0-beta0006}/Versioning/When_multiple_versions_of_a_message_is_published.cs (100%) create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/IConfigureTransportInfrastructure.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/NServiceBusTransportTest.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/TransportConfigurationResult.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_failure_happens_after_send.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_message_is_available.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_error_throws.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws_after_delayed_retry.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws_after_immediate_retry.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_requesting_immediate_retry.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_scope_dispose_throws.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_sending_from_on_error.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_user_aborts_processing.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/ConfigureSqlServerTransportInfrastructure.cs create mode 100644 src/NServiceBus.SqlServer.TransportTests/NServiceBus.SqlServer.TransportTests.csproj create mode 100644 src/NServiceBus.SqlServer.TransportTests/packages.config create mode 100644 src/NServiceBus.SqlServer.UnitTests/Receiving/FailureInfoStorageTests.cs create mode 100644 src/NServiceBus.SqlServer/Receiving/FailureInfoStorage.cs create mode 100644 src/NServiceBus.SqlServer/Receiving/ReceiveWithNativeTransaction.cs delete mode 100644 src/NServiceBus.SqlServer/Receiving/ReceiveWithReceiveOnlyTransaction.cs delete mode 100644 src/NServiceBus.SqlServer/Receiving/ReceiveWithSendsAtomicWithReceiveTransaction.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/MessageDurability/When_sending_a_non_durable_message.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/MessageDurability/When_sending_a_non_durable_message.cs deleted file mode 100644 index 1f9e1a52f..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/MessageDurability/When_sending_a_non_durable_message.cs +++ /dev/null @@ -1,53 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Performance.MessageDurability -{ - using System; - using System.Threading.Tasks; - using AcceptanceTesting; - using EndpointTemplates; - using NUnit.Framework; - - public class When_sending_a_non_durable_message : NServiceBusAcceptanceTest - { - [Test] - public async Task Should_be_available_as_a_header_on_receiver() - { - var context = await Scenario.Define() - .WithEndpoint(b => b.When((session, c) => session.SendLocal(new MyMessage()))) - .Done(c => c.WasCalled) - .Run(TimeSpan.FromSeconds(10)); - - Assert.IsTrue(context.NonDurabilityHeader, "Message should be flagged as non durable"); - } - - public class Context : ScenarioContext - { - public bool WasCalled { get; set; } - public bool NonDurabilityHeader { get; set; } - } - - public class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup(); - } - - public class MyMessageHandler : IHandleMessages - { - public Context TestContext { get; set; } - - public Task Handle(MyMessage message, IMessageHandlerContext context) - { - TestContext.NonDurabilityHeader = bool.Parse(context.MessageHeaders[Headers.NonDurableMessage]); - TestContext.WasCalled = true; - return Task.FromResult(0); - } - } - } - - [Express] - public class MyMessage : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PipelineExt/FilteringWhatGetsAudited.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PipelineExt/FilteringWhatGetsAudited.cs deleted file mode 100644 index c3bfab8c9..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PipelineExt/FilteringWhatGetsAudited.cs +++ /dev/null @@ -1,167 +0,0 @@ -namespace NServiceBus.AcceptanceTests.PipelineExt -{ - using System; - using System.Threading.Tasks; - using AcceptanceTesting; - using EndpointTemplates; - using NServiceBus.Pipeline; - using NUnit.Framework; - - /// - /// This is a demo on how pipeline overrides can be used to control which messages that gets audited by NServiceBus - /// - public class FilteringWhatGetsAudited : NServiceBusAcceptanceTest - { - [Test] - public async Task RunDemo() - { - var context = await Scenario.Define() - .WithEndpoint(b => b.When(session => session.SendLocal(new MessageToBeAudited()))) - .WithEndpoint() - .Done(c => c.Done) - .Run(); - - Assert.IsFalse(context.WrongMessageAudited); - } - - public class UserEndpoint : EndpointConfigurationBuilder - { - public UserEndpoint() - { - EndpointSetup() - .AuditTo(); - } - - class MessageToBeAuditedHandler : IHandleMessages - { - public Task Handle(MessageToBeAudited message, IMessageHandlerContext context) - { - return context.SendLocal(new Message3()); - } - } - - class Message3Handler : IHandleMessages - { - public Task Handle(Message3 message, IMessageHandlerContext context) - { - return Task.FromResult(0); - } - } - - class AddContextStorage : Behavior - { - public override Task Invoke(IIncomingPhysicalMessageContext context, Func next) - { - context.Extensions.Set(new AuditFilterResult()); - - return next(); - } - - public class Registration : RegisterStep - { - public Registration() - : base("AddContextStorage", typeof(AddContextStorage), "Adds state to the context so that downstream behaviors can turn audit offf") - { - InsertBefore(WellKnownStep.AuditProcessedMessage); - } - } - } - - class SetFiltering : Behavior - { - public override Task Invoke(IIncomingLogicalMessageContext context, Func next) - { - if (context.Message.MessageType == typeof(MessageToBeAudited)) - { - context.Extensions.Get().DoNotAuditMessage = true; - } - - return next(); - } - } - - class AuditFilterResult - { - public bool DoNotAuditMessage { get; set; } - } - - class FilteringAuditBehavior : Behavior - { - public override Task Invoke(IAuditContext context, Func next) - { - AuditFilterResult result; - - if (context.Extensions.TryGet(out result) && result.DoNotAuditMessage) - { - return Task.FromResult(0); - } - return next(); - } - - public class Registration : RegisterStep - { - public Registration() - : base("FilteringAudit", typeof(FilteringAuditBehavior), "Prevents audits if needed") - { - } - } - } - - class AuditFilteringOverride : INeedInitialization - { - public void Customize(EndpointConfiguration configuration) - { - configuration.Pipeline.Register(); - configuration.Pipeline.Register("SetFiltering", typeof(SetFiltering), "Filters audit entries"); - configuration.Pipeline.Register(); - } - } - } - - public class AuditSpy : EndpointConfigurationBuilder - { - public AuditSpy() - { - EndpointSetup(); - } - - class AuditMessageHandler : IHandleMessages - { - public Context MyContext { get; set; } - - public Task Handle(MessageToBeAudited message, IMessageHandlerContext context) - { - MyContext.WrongMessageAudited = true; - return Task.FromResult(0); - } - } - - class Message3Handler : IHandleMessages - { - public Context MyContext { get; set; } - - public Task Handle(Message3 message, IMessageHandlerContext context) - { - MyContext.Done = true; - return Task.FromResult(0); - } - } - } - - public class Context : ScenarioContext - { - public bool Done { get; set; } - public bool WrongMessageAudited { get; set; } - } - - [Serializable] - public class MessageToBeAudited : IMessage - { - } - - [Serializable] - public class Message3 : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PipelineExt/MutingHandlerExceptions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PipelineExt/MutingHandlerExceptions.cs deleted file mode 100644 index b3ff91726..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PipelineExt/MutingHandlerExceptions.cs +++ /dev/null @@ -1,115 +0,0 @@ -namespace NServiceBus.AcceptanceTests.PipelineExt -{ - using System; - using System.Threading.Tasks; - using AcceptanceTesting; - using EndpointTemplates; - using NServiceBus.Pipeline; - using NUnit.Framework; - - /// - /// This is a demo on how pipeline overrides can be used to control which messages that gets audited by NServiceBus - /// - public class MutingHandlerExceptions : NServiceBusAcceptanceTest - { - [Test] - public async Task RunDemo() - { - var context = await Scenario.Define() - .WithEndpoint(b => b.When(session => session.SendLocal(new MessageThatWillBlowUpButExWillBeMuted()))) - .WithEndpoint() - .Done(c => c.MessageAudited) - .Run(); - - Assert.IsTrue(context.MessageAudited); - } - - public class EndpointWithCustomExceptionMuting : EndpointConfigurationBuilder - { - public EndpointWithCustomExceptionMuting() - { - EndpointSetup() - .AuditTo(); - } - - class Handler : IHandleMessages - { - public Context MyContext { get; set; } - - public Task Handle(MessageThatWillBlowUpButExWillBeMuted message, IMessageHandlerContext context) - { - throw new Exception("Lets filter on this text"); - } - } - - class MyExceptionFilteringBehavior : Behavior - { - public override async Task Invoke(IIncomingPhysicalMessageContext context, Func next) - { - try - { - //invoke the handler/rest of the pipeline - await next().ConfigureAwait(false); - } - //catch specifix exceptions or - catch (Exception ex) - { - //modify this if necessary - if (ex.Message == "Lets filter on this text") - { - return; - } - - throw; - } - } - - //here we inject our behavior - class MyExceptionFilteringOverride : INeedInitialization - { - public void Customize(EndpointConfiguration configuration) - { - configuration.Pipeline.Register(); - } - } - - class MyExceptionFilteringRegistration : RegisterStep - { - public MyExceptionFilteringRegistration() : base("ExceptionFiltering", typeof(MyExceptionFilteringBehavior), "Custom exception filtering") - { - InsertAfter(WellKnownStep.AuditProcessedMessage); - } - } - } - } - - public class AuditSpy : EndpointConfigurationBuilder - { - public AuditSpy() - { - EndpointSetup(); - } - - class AuditMessageHandler : IHandleMessages - { - public Context MyContext { get; set; } - - public Task Handle(MessageThatWillBlowUpButExWillBeMuted message, IMessageHandlerContext context) - { - MyContext.MessageAudited = true; - return Task.FromResult(0); - } - } - } - - public class Context : ScenarioContext - { - public bool MessageAudited { get; set; } - } - - [Serializable] - public class MessageThatWillBlowUpButExWillBeMuted : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_custom_policy.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_custom_policy.cs deleted file mode 100644 index f71f7ea93..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_custom_policy.cs +++ /dev/null @@ -1,86 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Recoverability.Retries -{ - using System; - using System.Threading.Tasks; - using AcceptanceTesting; - using EndpointTemplates; - using Features; - using NUnit.Framework; - using Transports; - - public class When_performing_slr_with_custom_policy : NServiceBusAcceptanceTest - { - [Test] - public async Task Should_expose_headers_to_policy() - { - var context = await Scenario.Define() - .WithEndpoint(b => - b.When(bus => bus.SendLocal(new MessageToBeRetried())) - .DoNotFailOnErrorMessages()) - .Done(c => c.MessageMovedToErrorQueue) - .Run(); - - Assert.That(context.FLRetriesHeaderAvailable, Is.True, "Could not find FLRetries header"); - Assert.That(context.RetriesHeaderAvailable, Is.True, "Could not find Retries header"); - } - - class Context : ScenarioContext - { - public bool FLRetriesHeaderAvailable { get; set; } - public bool MessageMovedToErrorQueue { get; set; } - public bool RetriesHeaderAvailable { get; set; } - } - - class Endpoint : EndpointConfigurationBuilder - { - public Endpoint() - { - EndpointSetup((config, context) => - { - var testContext = context.ScenarioContext as Context; - - config.EnableFeature(); - config.EnableFeature(); - config.EnableFeature(); - config.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => { testContext.MessageMovedToErrorQueue = true; }; - config.SecondLevelRetries().CustomRetryPolicy(new CustomPolicy(testContext).GetDelay); - }); - } - - class CustomPolicy - { - public CustomPolicy(Context context) - { - this.context = context; - } - - public TimeSpan GetDelay(IncomingMessage msg) - { - context.FLRetriesHeaderAvailable |= msg.Headers.ContainsKey(Headers.FLRetries); - context.RetriesHeaderAvailable |= msg.Headers.ContainsKey(Headers.Retries); - - if (slrRetries++ == 1) - { - return TimeSpan.MinValue; - } - return TimeSpan.FromMilliseconds(1); - } - - Context context; - int slrRetries; - } - - class Handler : IHandleMessages - { - public Task Handle(MessageToBeRetried message, IMessageHandlerContext context) - { - throw new SimulatedException(); - } - } - } - - class MessageToBeRetried : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_dispatching_transport_operations.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_dispatching_transport_operations.cs deleted file mode 100644 index fe93206f3..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_dispatching_transport_operations.cs +++ /dev/null @@ -1,78 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Reliability.Outbox -{ - using System; - using System.Collections.Generic; - using System.Threading.Tasks; - using AcceptanceTesting; - using Configuration.AdvanceExtensibility; - using EndpointTemplates; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_dispatching_transport_operations : NServiceBusAcceptanceTest - { - [Test] - public Task Should_honor_all_delivery_options() - { - return Scenario.Define() - .WithEndpoint(b => b.When(session => session.SendLocal(new PlaceOrder()))) - .Done(c => c.DispatchedMessageReceived) - .Repeat(r => r.For()) - .Should(context => - { - Assert.AreEqual(TimeSpan.FromMinutes(1), TimeSpan.Parse(context.HeadersOnDispatchedMessage[Headers.TimeToBeReceived]), "Should honor the TTBR"); - Assert.True(bool.Parse(context.HeadersOnDispatchedMessage[Headers.NonDurableMessage]), "Should honor the durability"); - }) - .Run(TimeSpan.FromSeconds(20)); - } - - public class Context : ScenarioContext - { - public bool DispatchedMessageReceived { get; set; } - public IReadOnlyDictionary HeadersOnDispatchedMessage { get; set; } - } - - public class NonDtcReceivingEndpoint : EndpointConfigurationBuilder - { - public NonDtcReceivingEndpoint() - { - EndpointSetup( - b => - { - b.GetSettings().Set("DisableOutboxTransportCheck", true); - b.EnableOutbox(); - }); - } - - class PlaceOrderHandler : IHandleMessages - { - public Task Handle(PlaceOrder message, IMessageHandlerContext context) - { - return context.SendLocal(new MessageToDispatch()); - } - } - - class MessageToDispatchHandler : IHandleMessages - { - public Context TestContext { get; set; } - - public Task Handle(MessageToDispatch message, IMessageHandlerContext context) - { - TestContext.HeadersOnDispatchedMessage = context.MessageHeaders; - TestContext.DispatchedMessageReceived = true; - return Task.FromResult(0); - } - } - } - - public class PlaceOrder : ICommand - { - } - - [TimeToBeReceived("00:01:00")] - [Express] - class MessageToDispatch : IMessage - { - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Volatile/When_sending_to_non_durable_endpoint.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Volatile/When_sending_to_non_durable_endpoint.cs deleted file mode 100644 index 2aa72e054..000000000 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Volatile/When_sending_to_non_durable_endpoint.cs +++ /dev/null @@ -1,63 +0,0 @@ -namespace NServiceBus.AcceptanceTests.Volatile -{ - using System.Threading.Tasks; - using AcceptanceTesting; - using EndpointTemplates; - using NServiceBus.Config; - using NUnit.Framework; - using ScenarioDescriptors; - - public class When_sending_to_non_durable_endpoint : NServiceBusAcceptanceTest - { - [Test] - public Task Should_receive_the_message() - { - return Scenario.Define() - .WithEndpoint(b => b.When((session, c) => session.Send(new MyMessage()))) - .WithEndpoint() - .Done(c => c.WasCalled) - .Repeat(r => r.For(Transports.Default)) - .Should(c => Assert.True(c.WasCalled, "The message handler should be called")) - .Run(); - } - - public class Context : ScenarioContext - { - public bool WasCalled { get; set; } - } - - public class Sender : EndpointConfigurationBuilder - { - public Sender() - { - EndpointSetup(builder => builder.DisableDurableMessages()) - .AddMapping(typeof(Receiver)) - .WithConfig(c => { c.ErrorQueue = "NonDurableError"; }); - } - } - - public class Receiver : EndpointConfigurationBuilder - { - public Receiver() - { - EndpointSetup(builder => builder.DisableDurableMessages()) - .WithConfig(c => { c.ErrorQueue = "NonDurableError"; }); - } - } - - public class MyMessage : IMessage - { - } - - public class MyMessageHandler : IHandleMessages - { - public Context Context { get; set; } - - public Task Handle(MyMessage message, IMessageHandlerContext context) - { - Context.WasCalled = true; - return Task.FromResult(0); - } - } - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ApiExtension/When_extending_sendoptions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ApiExtension/When_extending_sendoptions.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ApiExtension/When_extending_sendoptions.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ApiExtension/When_extending_sendoptions.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ApiExtension/When_extending_the_publish_api.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ApiExtension/When_extending_the_publish_api.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ApiExtension/When_extending_the_publish_api.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ApiExtension/When_extending_the_publish_api.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_a_message_is_audited.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_a_message_is_audited.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_a_message_is_audited.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_a_message_is_audited.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_a_replymessage_is_audited.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_a_replymessage_is_audited.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_a_replymessage_is_audited.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_a_replymessage_is_audited.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_audit_is_overridden_in_code.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_audit_is_overridden_in_code.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_audit_is_overridden_in_code.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_audit_is_overridden_in_code.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_auditing.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_auditing.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_auditing.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_auditing.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_auditing_message_with_TimeToBeReceived.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_auditing_message_with_TimeToBeReceived.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Audit/When_auditing_message_with_TimeToBeReceived.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Audit/When_auditing_message_with_TimeToBeReceived.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_aborting_the_behavior_chain.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_aborting_the_behavior_chain.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_aborting_the_behavior_chain.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_aborting_the_behavior_chain.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_deferring_to_non_local.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_deferring_to_non_local.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_deferring_to_non_local.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_deferring_to_non_local.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_depending_on_typed_feature.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_depending_on_typed_feature.cs new file mode 100644 index 000000000..ec0d79f3b --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_depending_on_typed_feature.cs @@ -0,0 +1,76 @@ +namespace NServiceBus.AcceptanceTests.Basic +{ + using System.Threading.Tasks; + using AcceptanceTesting; + using EndpointTemplates; + using Features; + using NUnit.Framework; + + public class When_depending_on_typed_feature : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_enable_when_typed_dependency_enabled() + { + var context = await Scenario.Define() + .WithEndpoint(b => b.CustomConfig(c => + { + c.EnableFeature(); + c.EnableFeature(); + })) + .Done(c => c.EndpointsStarted) + .Run(); + + Assert.That(context.TypedDependencyFeatureSetUp, Is.True); + } + + [Test] + public async Task Should_disable_when_typed_dependency_disabled() + { + var context = await Scenario.Define() + .WithEndpoint(b => b.CustomConfig(c => + { + c.DisableFeature(); + c.EnableFeature(); + })) + .Done(c => c.EndpointsStarted) + .Run(); + + Assert.That(context.TypedDependencyFeatureSetUp, Is.False); + } + + class Context : ScenarioContext + { + public bool TypedDependencyFeatureSetUp { get; set; } + public bool UntypedDependencyFeatureSetUp { get; set; } + } + + public class EndpointWithFeatures : EndpointConfigurationBuilder + { + public EndpointWithFeatures() + { + EndpointSetup(); + } + } + + public class TypedDependentFeature : Feature + { + public TypedDependentFeature() + { + DependsOn(); + } + + protected override void Setup(FeatureConfigurationContext context) + { + var testContext = (Context) context.Settings.Get(); + testContext.TypedDependencyFeatureSetUp = true; + } + } + + public class DependencyFeature : Feature + { + protected override void Setup(FeatureConfigurationContext context) + { + } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_depending_on_untyped_feature.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_depending_on_untyped_feature.cs new file mode 100644 index 000000000..f40e8b141 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_depending_on_untyped_feature.cs @@ -0,0 +1,76 @@ +namespace NServiceBus.AcceptanceTests.Basic +{ + using System.Threading.Tasks; + using AcceptanceTesting; + using EndpointTemplates; + using Features; + using NUnit.Framework; + + public class When_depending_on_untyped_feature : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_enable_when_untyped_dependency_enabled() + { + var context = await Scenario.Define() + .WithEndpoint(b => b.CustomConfig(c => + { + c.EnableFeature(); + c.EnableFeature(); + })) + .Done(c => c.EndpointsStarted) + .Run(); + + Assert.That(context.UntypedDependencyFeatureSetUp, Is.True); + } + + [Test] + public async Task Should_disable_when_untyped_dependency_disabled() + { + var context = await Scenario.Define() + .WithEndpoint(b => b.CustomConfig(c => + { + c.DisableFeature(); + c.EnableFeature(); + })) + .Done(c => c.EndpointsStarted) + .Run(); + + Assert.That(context.UntypedDependencyFeatureSetUp, Is.False); + } + + class Context : ScenarioContext + { + public bool UntypedDependencyFeatureSetUp { get; set; } + } + + public class EndpointWithFeatures : EndpointConfigurationBuilder + { + public EndpointWithFeatures() + { + EndpointSetup(); + } + } + + public class UntypedDependentFeature : Feature + { + public UntypedDependentFeature() + { + var featureTypeFullName = typeof(DependencyFeature).FullName; + DependsOn(featureTypeFullName); + } + + protected override void Setup(FeatureConfigurationContext context) + { + var testContext = (Context) context.Settings.Get(); + testContext.UntypedDependencyFeatureSetUp = true; + } + } + + public class DependencyFeature : Feature + { + protected override void Setup(FeatureConfigurationContext context) + { + } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_extending_behavior_context.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_extending_behavior_context.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_extending_behavior_context.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_extending_behavior_context.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_handling_current_message_later.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_handling_current_message_later.cs similarity index 97% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_handling_current_message_later.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_handling_current_message_later.cs index 19b51a495..3cd4eff55 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_handling_current_message_later.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_handling_current_message_later.cs @@ -6,8 +6,9 @@ using EndpointTemplates; using Features; using NServiceBus.Config; - using NServiceBus.UnitOfWork; + using NServiceBus; using NUnit.Framework; + using UnitOfWork; public class When_handling_current_message_later : NServiceBusAcceptanceTest { @@ -44,7 +45,6 @@ public MyEndpoint() { b.RegisterComponents(r => r.ConfigureComponent(DependencyLifecycle.InstancePerCall)); b.DisableFeature(); - b.DisableFeature(); b.ExecuteTheseHandlersFirst(typeof(FirstHandler), typeof(SecondHandler)); }) .WithConfig(c => { c.MaxRetries = 0; }); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_handling_message_with_several_messagehandlers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_handling_message_with_several_messagehandlers.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_handling_message_with_several_messagehandlers.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_handling_message_with_several_messagehandlers.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_multiple_mappings_exists.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_multiple_mappings_exists.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_multiple_mappings_exists.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_multiple_mappings_exists.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_no_content_type.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_no_content_type.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_no_content_type.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_no_content_type.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_receiving_with_catch_all_handlers_registered.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_receiving_with_catch_all_handlers_registered.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_receiving_with_catch_all_handlers_registered.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_receiving_with_catch_all_handlers_registered.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_registering_handlers_explicitly.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_registering_handlers_explicitly.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_registering_handlers_explicitly.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_registering_handlers_explicitly.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_sending_from_a_send_only.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_sending_from_a_send_only.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_sending_from_a_send_only.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_sending_from_a_send_only.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_sending_to_another_endpoint.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_sending_to_another_endpoint.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_sending_to_another_endpoint.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_sending_to_another_endpoint.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_sending_with_conventions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_sending_with_conventions.cs similarity index 50% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_sending_with_conventions.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_sending_with_conventions.cs index a42e2e453..142e17244 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_sending_with_conventions.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_sending_with_conventions.cs @@ -12,19 +12,22 @@ public class When_sending_with_conventions : NServiceBusAcceptanceTest public async Task Should_receive_the_message() { var context = await Scenario.Define(c => { c.Id = Guid.NewGuid(); }) - .WithEndpoint(b => b.When((session, c) => session.SendLocal(new MyMessage + .WithEndpoint(b => b.When(async(session, c) => { - Id = c.Id - }))) - .Done(c => c.WasCalled) + await session.SendLocal(m => m.Id = c.Id); + await session.SendLocal(m => m.Id = c.Id); + })) + .Done(c => c.MessageClassReceived && c.MessageInterfaceReceived) .Run(); - Assert.True(context.WasCalled); + Assert.True(context.MessageClassReceived); + Assert.True(context.MessageInterfaceReceived); } public class Context : ScenarioContext { - public bool WasCalled { get; set; } + public bool MessageClassReceived { get; set; } + public bool MessageInterfaceReceived { get; set; } public Guid Id { get; set; } } @@ -32,16 +35,20 @@ public class Endpoint : EndpointConfigurationBuilder { public Endpoint() { - EndpointSetup(b => b.Conventions().DefiningMessagesAs(type => type == typeof(MyMessage))); + EndpointSetup(b => b.Conventions().DefiningMessagesAs(type => type.Name.EndsWith("Message"))); } } - [Serializable] public class MyMessage { public Guid Id { get; set; } } + public interface IMyInterfaceMessage + { + Guid Id { get; set; } + } + public class MyMessageHandler : IHandleMessages { public Context Context { get; set; } @@ -53,7 +60,24 @@ public Task Handle(MyMessage message, IMessageHandlerContext context) return Task.FromResult(0); } - Context.WasCalled = true; + Context.MessageClassReceived = true; + + return Task.FromResult(0); + } + } + + public class MyMessageInterfaceHandler : IHandleMessages + { + public Context Context { get; set; } + + public Task Handle(IMyInterfaceMessage interfaceMessage, IMessageHandlerContext context) + { + if (Context.Id != interfaceMessage.Id) + { + return Task.FromResult(0); + } + + Context.MessageInterfaceReceived = true; return Task.FromResult(0); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_using_a_greedy_convention.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_using_a_greedy_convention.cs similarity index 83% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_using_a_greedy_convention.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_using_a_greedy_convention.cs index 6abaa0caa..99cf09286 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_using_a_greedy_convention.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Basic/When_using_a_greedy_convention.cs @@ -5,24 +5,21 @@ using AcceptanceTesting; using EndpointTemplates; using NUnit.Framework; - using ScenarioDescriptors; public class When_using_a_greedy_convention : NServiceBusAcceptanceTest { [Test] - public Task Should_receive_the_message() + public async Task Should_receive_the_message() { - return Scenario.Define(c => { c.Id = Guid.NewGuid(); }) + var context = await Scenario.Define(c => { c.Id = Guid.NewGuid(); }) .WithEndpoint(b => b.When((session, c) => session.SendLocal(new MyMessage { Id = c.Id }))) .Done(c => c.WasCalled) - .Repeat(r => r - .For(Transports.Default) - ) - .Should(c => Assert.True(c.WasCalled, "The message handler should be called")) .Run(); + + Assert.True(context.WasCalled, "The message handler should be called"); } public class Context : ScenarioContext diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_publishing_command.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_publishing_command.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_publishing_command.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_publishing_command.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_publishing_command_bestpractices_disabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_publishing_command_bestpractices_disabled.cs similarity index 93% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_publishing_command_bestpractices_disabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_publishing_command_bestpractices_disabled.cs index 0be43fe1d..3a8956efc 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_publishing_command_bestpractices_disabled.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_publishing_command_bestpractices_disabled.cs @@ -10,7 +10,7 @@ public class When_publishing_command_bestpractices_disabled : NServiceBusAccepta [Test] public async Task Should_allow_publishing_commands() { - var context = await Scenario.Define() + var context = await Scenario.Define() .WithEndpoint(b => b.When((session, c) => { var publishOptions = new PublishOptions(); @@ -24,10 +24,6 @@ public async Task Should_allow_publishing_commands() Assert.True(context.EndpointsStarted); } - public class Context : ScenarioContext - { - } - public class Endpoint : EndpointConfigurationBuilder { public Endpoint() diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs similarity index 91% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs index 8bcf713d0..1f8fa3a7b 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_publishing_command_bestpractices_disabled_on_endpoint.cs @@ -11,7 +11,7 @@ public class When_publishing_command_bestpractices_disabled_on_endpoint : NServi [Test] public Task Should_allow_publishing_commands() { - return Scenario.Define() + return Scenario.Define() .WithEndpoint(b => b.When((session, c) => session.Publish(new MyCommand()))) .Done(c => c.EndpointsStarted) .Run(); @@ -20,16 +20,12 @@ public Task Should_allow_publishing_commands() [Test] public Task Should_allow_sending_events() { - return Scenario.Define() + return Scenario.Define() .WithEndpoint(b => b.When((session, c) => session.Send(new MyEvent()))) .Done(c => c.EndpointsStarted) .Run(); } - public class Context : ScenarioContext - { - } - public class Endpoint : EndpointConfigurationBuilder { public Endpoint() diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_sending_event.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_sending_event.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_sending_event.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_sending_event.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_sending_events_bestpractices_disabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_sending_events_bestpractices_disabled.cs similarity index 92% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_sending_events_bestpractices_disabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_sending_events_bestpractices_disabled.cs index 193448d55..3b026d4ae 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_sending_events_bestpractices_disabled.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_sending_events_bestpractices_disabled.cs @@ -10,7 +10,7 @@ public class When_sending_events_bestpractices_disabled : NServiceBusAcceptanceT [Test] public async Task Should_allow_sending_events() { - var context = await Scenario.Define() + var context = await Scenario.Define() .WithEndpoint(b => b.When((session, c) => { var sendOptions = new SendOptions(); @@ -24,9 +24,6 @@ public async Task Should_allow_sending_events() Assert.True(context.EndpointsStarted); } - public class Context : ScenarioContext - { - } public class Endpoint : EndpointConfigurationBuilder { diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_sending_events_bestpractices_disabled_on_endpoint.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_sending_events_bestpractices_disabled_on_endpoint.cs similarity index 91% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_sending_events_bestpractices_disabled_on_endpoint.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_sending_events_bestpractices_disabled_on_endpoint.cs index 6d9151b34..91033796d 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_sending_events_bestpractices_disabled_on_endpoint.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_sending_events_bestpractices_disabled_on_endpoint.cs @@ -11,16 +11,12 @@ public class When_sending_events_bestpractices_disabled_on_endpoint : NServiceBu [Test] public Task Should_allow_sending_events() { - return Scenario.Define() + return Scenario.Define() .WithEndpoint(b => b.When((session, c) => session.Send(new MyEvent()))) .Done(c => c.EndpointsStarted) .Run(); } - public class Context : ScenarioContext - { - } - public class Endpoint : EndpointConfigurationBuilder { public Endpoint() diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_subscribing_to_command.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_subscribing_to_command.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_subscribing_to_command.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_subscribing_to_command.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_subscribing_to_command_bestpractices_disabled_on_endpoint.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_subscribing_to_command_bestpractices_disabled_on_endpoint.cs similarity index 90% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_subscribing_to_command_bestpractices_disabled_on_endpoint.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_subscribing_to_command_bestpractices_disabled_on_endpoint.cs index f08dd6e2f..97473bb84 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_subscribing_to_command_bestpractices_disabled_on_endpoint.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_subscribing_to_command_bestpractices_disabled_on_endpoint.cs @@ -11,7 +11,7 @@ public class When_subscribing_to_command_bestpractices_disabled_on_endpoint : NS [Test] public Task Should_allow_subscribing_to_commands() { - return Scenario.Define() + return Scenario.Define() .WithEndpoint(b => b.When((session, c) => session.Subscribe())) .Done(c => c.EndpointsStarted) .Run(); @@ -20,7 +20,7 @@ public Task Should_allow_subscribing_to_commands() [Test] public Task Should_allow_publishing_commands() { - return Scenario.Define() + return Scenario.Define() .WithEndpoint(b => b.When((session, c) => session.Publish(new MyCommand()))) .Done(c => c.EndpointsStarted) .Run(); @@ -29,16 +29,12 @@ public Task Should_allow_publishing_commands() [Test] public Task Should_allow_sending_events() { - return Scenario.Define() + return Scenario.Define() .WithEndpoint(b => b.When((session, c) => session.Send(new MyEvent()))) .Done(c => c.EndpointsStarted) .Run(); } - public class Context : ScenarioContext - { - } - public class Endpoint : EndpointConfigurationBuilder { public Endpoint() diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_unsubscribing_to_command.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_unsubscribing_to_command.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_unsubscribing_to_command.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_unsubscribing_to_command.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_unsubscribing_to_command_bestpractices_disabled_on_endpoint.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_unsubscribing_to_command_bestpractices_disabled_on_endpoint.cs similarity index 92% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_unsubscribing_to_command_bestpractices_disabled_on_endpoint.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_unsubscribing_to_command_bestpractices_disabled_on_endpoint.cs index 44dfb33e2..a7450897e 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/BestPractices/When_unsubscribing_to_command_bestpractices_disabled_on_endpoint.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/BestPractices/When_unsubscribing_to_command_bestpractices_disabled_on_endpoint.cs @@ -11,16 +11,12 @@ public class When_unsubscribing_to_command_bestpractices_disabled_on_endpoint : [Test] public Task Should_allow_unsubscribing_to_commands() { - return Scenario.Define() + return Scenario.Define() .WithEndpoint(b => b.When((session, c) => session.Unsubscribe())) .Done(c => c.EndpointsStarted) .Run(); } - public class Context : ScenarioContext - { - } - public class Endpoint : EndpointConfigurationBuilder { public Endpoint() diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Causation/When_a_message_is_audited.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Causation/When_a_message_is_audited.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Causation/When_a_message_is_audited.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Causation/When_a_message_is_audited.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Causation/When_a_message_is_faulted.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Causation/When_a_message_is_faulted.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Causation/When_a_message_is_faulted.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Causation/When_a_message_is_faulted.cs index 0dc75bb6d..6b2ace739 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Causation/When_a_message_is_faulted.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Causation/When_a_message_is_faulted.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; - using Features; using NUnit.Framework; public class When_a_message_is_faulted : NServiceBusAcceptanceTest @@ -36,7 +35,6 @@ public CausationEndpoint() { EndpointSetup((c, r) => { - c.DisableFeature(); c.SendFailedMessagesTo("errorQueueForAcceptanceTest"); }); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Causation/When_a_message_is_sent.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Causation/When_a_message_is_sent.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Causation/When_a_message_is_sent.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Causation/When_a_message_is_sent.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Config/When_injecting_message_session_into_handlers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Config/When_injecting_message_session_into_handlers.cs new file mode 100644 index 000000000..8f5ac5212 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Config/When_injecting_message_session_into_handlers.cs @@ -0,0 +1,45 @@ +namespace NServiceBus.AcceptanceTests.Config +{ + using System; + using System.Threading.Tasks; + using AcceptanceTesting; + using EndpointTemplates; + using NUnit.Framework; + + public class When_injecting_message_session_into_handlers : NServiceBusAcceptanceTest + { + [Test] + public void Should_throw_on_startup() + { + var exception = Assert.ThrowsAsync(async () => await Scenario.Define() + .WithEndpoint() + .Done(c => c.EndpointsStarted) + .Run()); + + StringAssert.Contains("IMessageSession", exception.ToString()); + } + + public class StartedEndpoint : EndpointConfigurationBuilder + { + public StartedEndpoint() + { + EndpointSetup(); + } + + class MyHandler : IHandleMessages + { + //not supported + public IMessageSession MessageSession { get; set; } + + public Task Handle(MyMessage message, IMessageHandlerContext context) + { + return MessageSession.Send(new MyMessage()); + } + } + } + + class MyMessage : IMessage + { + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Config/When_only_abstract_config_override_is_found.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Config/When_only_abstract_config_override_is_found.cs similarity index 90% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Config/When_only_abstract_config_override_is_found.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Config/When_only_abstract_config_override_is_found.cs index 88aa3730b..6bd36812e 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Config/When_only_abstract_config_override_is_found.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Config/When_only_abstract_config_override_is_found.cs @@ -13,15 +13,11 @@ public class When_only_abstract_config_override_is_found : NServiceBusAcceptance [Test] public Task Should_not_invoke_it() { - return Scenario.Define() + return Scenario.Define() .WithEndpoint().Done(c => c.EndpointsStarted) .Run(); } - public class Context : ScenarioContext - { - } - public class ConfigOverrideEndpoint : EndpointConfigurationBuilder { public ConfigOverrideEndpoint() diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Config/When_startup_is_complete.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Config/When_startup_is_complete.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Config/When_startup_is_complete.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Config/When_startup_is_complete.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ConfigureEndpointInMemoryPersistence.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ConfigureEndpointInMemoryPersistence.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ConfigureEndpointInMemoryPersistence.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ConfigureEndpointInMemoryPersistence.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ConfigureEndpointMsmqTransport.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ConfigureEndpointMsmqTransport.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ConfigureEndpointMsmqTransport.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ConfigureEndpointMsmqTransport.cs index 0741b6bb9..352f567e5 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ConfigureEndpointMsmqTransport.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ConfigureEndpointMsmqTransport.cs @@ -7,7 +7,7 @@ using NServiceBus.AcceptanceTesting.Support; using NServiceBus.AcceptanceTests.ScenarioDescriptors; using NServiceBus.Configuration.AdvanceExtensibility; -using NServiceBus.Transports; +using NServiceBus.Transport; public class ConfigureScenariosForMsmqTransport : IConfigureSupportedScenariosForTestExecution { diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ConventionEnforcementTests.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ConventionEnforcementTests.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ConventionEnforcementTests.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ConventionEnforcementTests.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Correlation/When_replying_to_received_message_without_correlationid.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Correlation/When_replying_to_received_message_without_correlationid.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Correlation/When_replying_to_received_message_without_correlationid.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Correlation/When_replying_to_received_message_without_correlationid.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Correlation/When_sending_with_no_correlation_id.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Correlation/When_sending_with_no_correlation_id.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Correlation/When_sending_with_no_correlation_id.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Correlation/When_sending_with_no_correlation_id.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Correlation/When_using_a_custom_correlation_id.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Correlation/When_using_a_custom_correlation_id.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Correlation/When_using_a_custom_correlation_id.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Correlation/When_using_a_custom_correlation_id.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/CriticalError/When_raising_critical_error.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/CriticalError/When_raising_critical_error.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/CriticalError/When_raising_critical_error.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/CriticalError/When_raising_critical_error.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DataBus/When_sending_databus_properties.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DataBus/When_sending_databus_properties.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DataBus/When_sending_databus_properties.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DataBus/When_sending_databus_properties.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DataBus/When_using_custom_IDataBus.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DataBus/When_using_custom_IDataBus.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DataBus/When_using_custom_IDataBus.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DataBus/When_using_custom_IDataBus.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_TimeoutManager_is_disabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_TimeoutManager_is_disabled.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_TimeoutManager_is_disabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_TimeoutManager_is_disabled.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails.cs similarity index 97% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails.cs index ffae7f419..9b6810359 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails.cs @@ -3,20 +3,19 @@ using System; using System.Threading.Tasks; using AcceptanceTesting; - using AcceptanceTesting.Customization; using EndpointTemplates; using Extensibility; using Features; - using NServiceBus.Persistence; + using NServiceBus; using NServiceBus.Pipeline; using NUnit.Framework; + using Persistence; using ScenarioDescriptors; using Timeout.Core; + using Conventions = AcceptanceTesting.Customization.Conventions; public class When_timeout_dispatch_fails : NServiceBusAcceptanceTest { - static readonly TimeSpan VeryLongTimeSpan = TimeSpan.FromMinutes(10); - [Test] public Task Should_retry_and_move_to_error() { @@ -42,8 +41,7 @@ public Task Should_retry_and_move_to_error() .Run(); } - const string ErrorQueueForTimeoutErrors = "timeout_dispatch_errors"; - + static readonly TimeSpan VeryLongTimeSpan = TimeSpan.FromMinutes(10); public class Context : ScenarioContext { public bool FailedTimeoutMovedToError { get; set; } @@ -86,7 +84,6 @@ public FakeTimeoutPersistence() class FakeTimeoutStorage : IQueryTimeouts, IPersistTimeouts { public Context TestContext { get; set; } - TimeoutData timeoutData; public Task Add(TimeoutData timeout, ContextBag context) { @@ -132,6 +129,8 @@ public Task GetNextChunk(DateTime startSlice) return Task.FromResult(new TimeoutsChunk(timeouts, DateTime.UtcNow + TimeSpan.FromSeconds(10))); } + + TimeoutData timeoutData; } class BehaviorThatLogsControlMessageDelivery : Behavior diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails_on_timeout_data_removal.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails_on_timeout_data_removal.cs similarity index 96% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails_on_timeout_data_removal.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails_on_timeout_data_removal.cs index 4ffd8995e..c1410b447 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails_on_timeout_data_removal.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_timeout_dispatch_fails_on_timeout_data_removal.cs @@ -1,18 +1,18 @@ namespace NServiceBus.AcceptanceTests.DelayedDelivery { using System; - using System.Collections.Generic; using System.Threading.Tasks; using AcceptanceTesting; - using AcceptanceTesting.Customization; using EndpointTemplates; using Extensibility; using Features; - using NServiceBus.Persistence; + using NServiceBus; using NServiceBus.Pipeline; using NUnit.Framework; + using Persistence; using ScenarioDescriptors; using Timeout.Core; + using Conventions = AcceptanceTesting.Customization.Conventions; public class When_timeout_dispatch_fails_on_timeout_data_removal : NServiceBusAcceptanceTest { @@ -123,11 +123,11 @@ public Task RemoveTimeoutBy(Guid sagaId, ContextBag context) public Task GetNextChunk(DateTime startSlice) { var timeouts = timeoutData != null - ? new List + ? new[] { new TimeoutsChunk.Timeout(timeoutData.Id, timeoutData.Time) } - : new List(); + : new TimeoutsChunk.Timeout[0]; return Task.FromResult(new TimeoutsChunk(timeouts, DateTime.UtcNow + TimeSpan.FromSeconds(10))); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_timeout_storage_fails.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_timeout_storage_fails.cs similarity index 96% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_timeout_storage_fails.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_timeout_storage_fails.cs index ece93cfe9..192b42e38 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/TimeoutManager/When_timeout_storage_fails.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/TimeoutManager/When_timeout_storage_fails.cs @@ -1,14 +1,14 @@ namespace NServiceBus.AcceptanceTests.DelayedDelivery { using System; - using System.Collections.Generic; using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; using Extensibility; using Features; - using NServiceBus.Persistence; + using NServiceBus; using NUnit.Framework; + using Persistence; using ScenarioDescriptors; using Timeout.Core; @@ -96,7 +96,7 @@ public Task RemoveTimeoutBy(Guid sagaId, ContextBag context) public Task GetNextChunk(DateTime startSlice) { - return Task.FromResult(new TimeoutsChunk(new List(), DateTime.UtcNow + TimeSpan.FromSeconds(10))); + return Task.FromResult(new TimeoutsChunk(new TimeoutsChunk.Timeout[0], DateTime.UtcNow + TimeSpan.FromSeconds(10))); } Context testContext; diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/When_Deferring_a_message.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/When_Deferring_a_message.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/When_Deferring_a_message.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/When_Deferring_a_message.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/When_deferring_a_message_to_the_past.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/When_deferring_a_message_to_the_past.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DelayedDelivery/When_deferring_a_message_to_the_past.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DelayedDelivery/When_deferring_a_message_to_the_past.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DeterministicGuid.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DeterministicGuid.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/DeterministicGuid.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/DeterministicGuid.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_Rijndael_with_config.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_Rijndael_with_config.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_Rijndael_with_config.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_Rijndael_with_config.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_Rijndael_with_custom.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_Rijndael_with_custom.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_Rijndael_with_custom.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_Rijndael_with_custom.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_Rijndael_with_multikey.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_Rijndael_with_multikey.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_Rijndael_with_multikey.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_Rijndael_with_multikey.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_Rijndael_without_incoming_key_identifier.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_Rijndael_without_incoming_key_identifier.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_Rijndael_without_incoming_key_identifier.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_Rijndael_without_incoming_key_identifier.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_encryption_with_custom_service.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_encryption_with_custom_service.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Encryption/When_using_encryption_with_custom_service.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Encryption/When_using_encryption_with_custom_service.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/ConfigureExtensions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/ConfigureExtensions.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/ConfigureExtensions.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/ConfigureExtensions.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/DefaultPublisher.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/DefaultPublisher.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/DefaultPublisher.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/DefaultPublisher.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/DefaultServer.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/DefaultServer.cs similarity index 89% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/DefaultServer.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/DefaultServer.cs index a81a89382..098d0bec4 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/DefaultServer.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/DefaultServer.cs @@ -8,7 +8,7 @@ using Configuration.AdvanceExtensibility; using Features; using NServiceBus.Config.ConfigurationSource; - using Serialization; + using NServiceBus.Serialization; public class DefaultServer : IEndpointSetupTemplate { @@ -37,8 +37,9 @@ public async Task GetConfiguration(RunDescriptor runDescr configuration.EnableInstallers(); configuration.DisableFeature(); - configuration.DisableFeature(); - configuration.DisableFeature(); + configuration.Recoverability() + .Delayed(delayed => delayed.NumberOfRetries(0)) + .Immediate(immediate => immediate.NumberOfRetries(0)); await configuration.DefineTransport(settings, endpointConfiguration.EndpointName).ConfigureAwait(false); @@ -48,7 +49,7 @@ public async Task GetConfiguration(RunDescriptor runDescr Type serializerType; if (settings.TryGet("Serializer", out serializerType)) { - configuration.UseSerialization((SerializationDefinition) Activator.CreateInstance(serializerType)); + configuration.UseSerialization((SerializationDefinition)Activator.CreateInstance(serializerType)); } await configuration.DefinePersistence(settings, endpointConfiguration.EndpointName).ConfigureAwait(false); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/EndpointCustomizationConfigurationExtensions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/EndpointCustomizationConfigurationExtensions.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/EndpointCustomizationConfigurationExtensions.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/EndpointCustomizationConfigurationExtensions.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/ServerWithNoDefaultPersistenceDefinitions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/ServerWithNoDefaultPersistenceDefinitions.cs similarity index 91% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/ServerWithNoDefaultPersistenceDefinitions.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/ServerWithNoDefaultPersistenceDefinitions.cs index b48fdd97d..7e35ec415 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/EndpointTemplates/ServerWithNoDefaultPersistenceDefinitions.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/EndpointTemplates/ServerWithNoDefaultPersistenceDefinitions.cs @@ -34,8 +34,9 @@ public async Task GetConfiguration(RunDescriptor runDescr builder.EnableInstallers(); builder.DisableFeature(); - builder.DisableFeature(); - builder.DisableFeature(); + builder.Recoverability() + .Delayed(delayed => delayed.NumberOfRetries(0)) + .Immediate(immediate => immediate.NumberOfRetries(0)); await builder.DefineTransport(settings, endpointConfiguration.EndpointName).ConfigureAwait(false); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Forwarding/When_ForwardReceivedMessagesTo_is_set.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Forwarding/When_ForwardReceivedMessagesTo_is_set.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Forwarding/When_ForwardReceivedMessagesTo_is_set.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Forwarding/When_ForwardReceivedMessagesTo_is_set.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_a_message_is_audited.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_a_message_is_audited.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_a_message_is_audited.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_a_message_is_audited.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_a_message_is_faulted.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_a_message_is_faulted.cs similarity index 97% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_a_message_is_faulted.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_a_message_is_faulted.cs index fe3cd72e3..0b9a181ef 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_a_message_is_faulted.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_a_message_is_faulted.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; - using Features; using NUnit.Framework; public class When_a_message_is_faulted : NServiceBusAcceptanceTest @@ -38,7 +37,6 @@ public EndpointWithAuditOn() { EndpointSetup(c => { - c.DisableFeature(); c.SendFailedMessagesTo("errorQueueForAcceptanceTest"); }); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_feature_overrides_hostid.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_feature_overrides_hostid.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_feature_overrides_hostid.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_feature_overrides_hostid.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_feature_overrides_hostinfo.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_feature_overrides_hostinfo.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_feature_overrides_hostinfo.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_feature_overrides_hostinfo.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_overriding_local_addresses.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_overriding_local_addresses.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_overriding_local_addresses.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_overriding_local_addresses.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_sending_ensure_proper_headers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_sending_ensure_proper_headers.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Hosting/When_sending_ensure_proper_headers.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Hosting/When_sending_ensure_proper_headers.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Licensing/When_a_message_is_audited.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Licensing/When_a_message_is_audited.cs similarity index 95% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Licensing/When_a_message_is_audited.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Licensing/When_a_message_is_audited.cs index b8e563690..d5d1900a0 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Licensing/When_a_message_is_audited.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Licensing/When_a_message_is_audited.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; + using Logging; using NUnit.Framework; public class When_a_message_is_audited : NServiceBusAcceptanceTest @@ -22,7 +23,7 @@ public async Task Should_add_the_license_diagnostic_headers() if (Debugger.IsAttached) { - Assert.True(context.Logs.Any(m => m.Level == "error" && m.Message.StartsWith("Your license has expired")), "Error should be logged"); + Assert.True(context.Logs.Any(m => m.Level == LogLevel.Error && m.Message.StartsWith("Your license has expired")), "Error should be logged"); } } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/MessageId/When_message_has_empty_id_header.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/MessageId/When_message_has_empty_id_header.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/MessageId/When_message_has_empty_id_header.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/MessageId/When_message_has_empty_id_header.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/MessageId/When_message_has_no_id_header.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/MessageId/When_message_has_no_id_header.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/MessageId/When_message_has_no_id_header.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/MessageId/When_message_has_no_id_header.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/Issue_1980.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/Issue_1980.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/Issue_1980.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/Issue_1980.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_defining_outgoing_message_mutators.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_defining_outgoing_message_mutators.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_defining_outgoing_message_mutators.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_defining_outgoing_message_mutators.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_incoming_mutator_changes_message_type.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_incoming_mutator_changes_message_type.cs similarity index 86% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_incoming_mutator_changes_message_type.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_incoming_mutator_changes_message_type.cs index 993a7f1fb..cfab06297 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_incoming_mutator_changes_message_type.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_incoming_mutator_changes_message_type.cs @@ -13,7 +13,7 @@ public async Task Should_invoke_handlers_for_new_message_type() { var context = await Scenario.Define() .WithEndpoint(e => e - .When(s => s.SendLocal(new OriginalMessage()))) + .When(s => s.SendLocal(new OriginalMessage { SomeId = "TestId" }))) .Done(c => c.NewMessageHandlerCalled || c.OriginalMessageHandlerCalled) .Run(); @@ -44,7 +44,8 @@ public class MessageMutator : IMutateIncomingMessages { public Task MutateIncoming(MutateIncomingMessageContext context) { - context.Message = new NewMessage(); + var original = (OriginalMessage)context.Message; + context.Message = new NewMessage { SomeId = original.SomeId }; return Task.FromResult(0); } } @@ -102,6 +103,8 @@ public Task Handle(OriginalMessage message, IMessageHandlerContext context) protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) { + mapper.ConfigureMapping(msg => msg.SomeId).ToSaga(saga => saga.SomeId); + mapper.ConfigureMapping(msg => msg.SomeId).ToSaga(saga => saga.SomeId); } Context TestContext; @@ -109,15 +112,18 @@ protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapp public class SagaData : ContainSagaData { + public virtual string SomeId { get; set; } } } public class OriginalMessage : ICommand { + public string SomeId { get; set; } } public class NewMessage : ICommand { + public string SomeId { get; set; } } } } \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_mutating.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_mutating.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_mutating.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_mutating.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_outgoing_mutator_replaces_instance.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_outgoing_mutator_replaces_instance.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_outgoing_mutator_replaces_instance.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_outgoing_mutator_replaces_instance.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_using_outgoing_tm_mutator.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_using_outgoing_tm_mutator.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Mutators/When_using_outgoing_tm_mutator.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Mutators/When_using_outgoing_tm_mutator.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/NServiceBusAcceptanceTest.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/NServiceBusAcceptanceTest.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/NServiceBusAcceptanceTest.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/NServiceBusAcceptanceTest.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/NonTx/When_sending_inside_ambient_tx.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/NonTx/When_sending_inside_ambient_tx.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/NonTx/When_sending_inside_ambient_tx.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/NonTx/When_sending_inside_ambient_tx.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/CriticalTime/When_CriticalTime_enabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/CriticalTime/When_CriticalTime_enabled.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/CriticalTime/When_CriticalTime_enabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/CriticalTime/When_CriticalTime_enabled.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/CriticalTime/When_deferring_a_message.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/CriticalTime/When_deferring_a_message.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/CriticalTime/When_deferring_a_message.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/CriticalTime/When_deferring_a_message.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/CriticalTime/When_slow_with_CriticalTime_enabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/CriticalTime/When_slow_with_CriticalTime_enabled.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/CriticalTime/When_slow_with_CriticalTime_enabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/CriticalTime/When_slow_with_CriticalTime_enabled.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/SLA/When_sending_slow_with_SLA_enabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/SLA/When_sending_slow_with_SLA_enabled.cs similarity index 94% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/SLA/When_sending_slow_with_SLA_enabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/SLA/When_sending_slow_with_SLA_enabled.cs index 9b6e1b4fe..131e4eef0 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/SLA/When_sending_slow_with_SLA_enabled.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/SLA/When_sending_slow_with_SLA_enabled.cs @@ -15,7 +15,7 @@ public class When_sending_slow_with_SLA_enabled : NServiceBusAcceptanceTest [Explicit("Since perf counters need to be enabled with powershell")] public async Task Should_have_perf_counter_set() { - using (var counter = new PerformanceCounter("NServiceBus", "SLA violation countdown", "PerformanceMonitoring.Endpoint.WhenSendingSlowWithSLAEnabled." + Transports.Default.Key, true)) + using (var counter = new PerformanceCounter("NServiceBus", "SLA violation countdown", "SendingWithSLAEnabled.Endpoint", false)) { using (new Timer(state => CheckPerfCounter(counter), null, 0, 100)) { diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/SLA/When_sending_with_SLA_enabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/SLA/When_sending_with_SLA_enabled.cs similarity index 94% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/SLA/When_sending_with_SLA_enabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/SLA/When_sending_with_SLA_enabled.cs index 5e9b6d161..cd760565d 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/PerfMon/SLA/When_sending_with_SLA_enabled.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/PerfMon/SLA/When_sending_with_SLA_enabled.cs @@ -15,7 +15,7 @@ public class When_sending_with_SLA_enabled : NServiceBusAcceptanceTest [Explicit("Since perf counters need to be enabled with powershell")] public async Task Should_have_perf_counter_set() { - using (var counter = new PerformanceCounter("NServiceBus", "SLA violation countdown", "PerformanceMonitoring.Endpoint.WhenSendingWithSLAEnabled." + Transports.Default.Key, true)) + using (var counter = new PerformanceCounter("NServiceBus", "SLA violation countdown", "SendingWithSLAEnabled.Endpoint", false)) { using (new Timer(state => CheckPerfCounter(counter), null, 0, 100)) { diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired_convention.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired_convention.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired_convention.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/TimeToBeReceived/When_TimeToBeReceived_has_expired_convention.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/TimeToBeReceived/When_TimeToBeReceived_has_not_expired.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/TimeToBeReceived/When_TimeToBeReceived_has_not_expired.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/TimeToBeReceived/When_TimeToBeReceived_has_not_expired.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/TimeToBeReceived/When_TimeToBeReceived_has_not_expired.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/When_message_is_audited.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/When_message_is_audited.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/When_message_is_audited.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/When_message_is_audited.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/When_message_is_faulted.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/When_message_is_faulted.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Performance/When_message_is_faulted.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Performance/When_message_is_faulted.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Pipeline/When_replacing_behavior.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Pipeline/When_replacing_behavior.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Pipeline/When_replacing_behavior.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Pipeline/When_replacing_behavior.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Pipeline/When_using_per_uow_component_in_the_pipeline.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Pipeline/When_using_per_uow_component_in_the_pipeline.cs new file mode 100644 index 000000000..32f28c5c8 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Pipeline/When_using_per_uow_component_in_the_pipeline.cs @@ -0,0 +1,119 @@ +namespace NServiceBus.AcceptanceTests.Pipeline +{ + using System; + using System.Threading; + using System.Threading.Tasks; + using AcceptanceTesting; + using EndpointTemplates; + using NServiceBus.Pipeline; + using NUnit.Framework; + + public class When_using_per_uow_component_in_the_pipeline : NServiceBusAcceptanceTest + { + [Test] + public async Task It_should_be_scoped_to_uow_both_in_behavior_and_in_the_handler() + { + var context = await Scenario.Define() + .WithEndpoint(e => e + .When(async s => + { + await SendMessage(s).ConfigureAwait(false); + await SendMessage(s).ConfigureAwait(false); + })) + .Done(c => c.MessagesProcessed >= 2) + .Run(); + + Assert.IsFalse(context.ValueEmpty, "Empty value in the UoW component meaning the UoW component has been registered as per-call"); + Assert.IsFalse(context.ValueAlreadyInitialized, "Value in the UoW has already been initialized when it was resolved for the first time in a given pipeline meaning the UoW component has been registered as a singleton."); + } + + static Task SendMessage(IMessageSession s) + { + var uniqueValue = Guid.NewGuid().ToString(); + var options = new SendOptions(); + options.RouteToThisEndpoint(); + options.SetHeader("Value", uniqueValue); + var message = new Message + { + Value = uniqueValue + }; + + return s.Send(message, options); + } + + class Context : ScenarioContext + { + int messagesProcessed; + public int MessagesProcessed => messagesProcessed; + + public void OnMessageProcessed() + { + Interlocked.Increment(ref messagesProcessed); + } + + public bool ValueEmpty { get; set; } + public bool ValueAlreadyInitialized { get; set; } + } + + class Endpoint : EndpointConfigurationBuilder + { + public Endpoint() + { + EndpointSetup(c => + { + c.RegisterComponents(r => r.ConfigureComponent(DependencyLifecycle.InstancePerUnitOfWork)); + c.Pipeline.Register(b => new HeaderProcessingBehavior(b.Build()), "Populates UoW component."); + c.LimitMessageProcessingConcurrencyTo(1); + }); + } + + class HeaderProcessingBehavior : Behavior + { + Context testContext; + + public HeaderProcessingBehavior(Context testContext) + { + this.testContext = testContext; + } + + public override Task Invoke(IIncomingLogicalMessageContext context, Func next) + { + var uowScopeComponent = context.Builder.Build(); + testContext.ValueAlreadyInitialized |= uowScopeComponent.ValueFromHeader != null; + uowScopeComponent.ValueFromHeader = context.MessageHeaders["Value"]; + + return next(); + } + } + + class UnitOfWorkComponent + { + public string ValueFromHeader { get; set; } + } + + class Handler : IHandleMessages + { + public Handler(Context testContext, UnitOfWorkComponent component) + { + this.testContext = testContext; + this.component = component; + } + + public Task Handle(Message message, IMessageHandlerContext context) + { + testContext.ValueEmpty |= component.ValueFromHeader == null; + testContext.OnMessageProcessed(); + return Task.FromResult(0); + } + + Context testContext; + UnitOfWorkComponent component; + } + } + + class Message : IMessage + { + public string Value { get; set; } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_Subscribing_to_errors.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_Subscribing_to_errors.cs similarity index 92% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_Subscribing_to_errors.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_Subscribing_to_errors.cs index ef7c1a805..fadbc6c68 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_Subscribing_to_errors.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_Subscribing_to_errors.cs @@ -6,6 +6,7 @@ using AcceptanceTesting; using EndpointTemplates; using Features; + using Logging; using NServiceBus.Config; using NUnit.Framework; @@ -27,7 +28,7 @@ public async Task Should_retain_exception_details_over_FLR_and_SLR() .Run(); Assert.IsInstanceOf(context.MessageSentToErrorException); - Assert.True(context.Logs.Any(l => l.Level == "error" && l.Message.Contains("Simulated exception message")), "The last exception should be logged as `error` before sending it to the error queue"); + Assert.True(context.Logs.Any(l => l.Level == LogLevel.Error && l.Message.Contains("Simulated exception message")), "The last exception should be logged as `error` before sending it to the error queue"); //FLR max retries = 3 means we will be processing 4 times. SLR max retries = 2 means we will do 3*FLR Assert.AreEqual(4*3, context.TotalNumberOfFLRTimesInvokedInHandler); @@ -53,9 +54,7 @@ public SLREndpoint() { var testContext = (Context) context.ScenarioContext; var notifications = config.Notifications; - config.EnableFeature(); config.EnableFeature(); - config.EnableFeature(); notifications.Errors.MessageSentToErrorQueue += (sender, message) => { testContext.MessageSentToErrorException = message.Exception; diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_min_policy.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_always_moves_to_error.cs similarity index 76% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_min_policy.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_always_moves_to_error.cs index 62e8fa24f..b9d553e66 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_min_policy.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_always_moves_to_error.cs @@ -5,11 +5,9 @@ namespace NServiceBus.AcceptanceTests.Recoverability.Retries using AcceptanceTesting; using EndpointTemplates; using Features; - using NServiceBus.Config; using NUnit.Framework; - using Transports; - public class When_performing_slr_with_min_policy : NServiceBusAcceptanceTest + public class When_custom_policy_always_moves_to_error : NServiceBusAcceptanceTest { [Test] public async Task Should_execute_once() @@ -37,18 +35,11 @@ public RetryEndpoint() EndpointSetup((configure, context) => { var scenarioContext = (Context) context.ScenarioContext; - configure.DisableFeature(); - configure.EnableFeature(); configure.EnableFeature(); - configure.SecondLevelRetries().CustomRetryPolicy(RetryPolicy); + configure.Recoverability() + .CustomPolicy((cfg, errorContext) => RecoverabilityAction.MoveToError(cfg.Failed.ErrorQueue)); configure.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => { scenarioContext.MessageSentToErrorQueue = true; }; - }) - .WithConfig(c => c.TimeIncrease = TimeSpan.FromMilliseconds(1)); - } - - static TimeSpan RetryPolicy(IncomingMessage transportMessage) - { - return TimeSpan.MinValue; + }); } class MessageToBeRetriedHandler : IHandleMessages diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_non_min_policy.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_does_single_delayed_retry_before_move_to_error.cs similarity index 73% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_non_min_policy.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_does_single_delayed_retry_before_move_to_error.cs index f95241987..dcd2dffc9 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_non_min_policy.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_does_single_delayed_retry_before_move_to_error.cs @@ -5,11 +5,10 @@ namespace NServiceBus.AcceptanceTests.Recoverability.Retries using AcceptanceTesting; using EndpointTemplates; using Features; - using NServiceBus.Config; using NUnit.Framework; - using Transports; + using Transport; - public class When_performing_slr_with_non_min_policy : NServiceBusAcceptanceTest + public class When_custom_policy_does_single_delayed_retry_before_move_to_error : NServiceBusAcceptanceTest { [Test] public async Task Should_execute_twice() @@ -37,26 +36,22 @@ public RetryEndpoint() EndpointSetup((configure, context) => { var scenarioContext = (Context) context.ScenarioContext; - configure.DisableFeature(); - configure.EnableFeature(); configure.EnableFeature(); - configure.SecondLevelRetries().CustomRetryPolicy(RetryPolicy); + configure.Recoverability() + .CustomPolicy(RetryPolicy); configure.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => { scenarioContext.MessageSentToErrorQueue = true; }; - }) - .WithConfig(c => c.TimeIncrease = TimeSpan.FromMilliseconds(1)); + }); } - TimeSpan RetryPolicy(IncomingMessage transportMessage) + RecoverabilityAction RetryPolicy(RecoverabilityConfig config, ErrorContext context) { - if (count == 0) + if (context.DelayedDeliveriesPerformed == 0) { - count++; - return TimeSpan.FromMilliseconds(10); + return RecoverabilityAction.DelayedRetry(TimeSpan.FromMilliseconds(10)); } - return TimeSpan.MinValue; - } - int count; + return RecoverabilityAction.MoveToError(config.Failed.ErrorQueue); + } class MessageToBeRetriedHandler : IHandleMessages { diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_executed.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_executed.cs new file mode 100644 index 000000000..6d7c3f458 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_executed.cs @@ -0,0 +1,76 @@ +namespace NServiceBus.AcceptanceTests.Recoverability.Retries +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Threading.Tasks; + using AcceptanceTesting; + using EndpointTemplates; + using Features; + using NUnit.Framework; + using Transport; + + public class When_custom_policy_executed : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_provide_error_context_to_policy() + { + var context = await Scenario.Define() + .WithEndpoint(b => + b.When(bus => bus.SendLocal(new MessageToBeRetried())) + .DoNotFailOnErrorMessages()) + .Done(c => c.FailedMessages.Any()) + .Run(); + + Assert.That(context.ErrorContexts.Count, Is.EqualTo(2), "because the custom policy should have been invoked twice"); + Assert.That(context.ErrorContexts[0].Message, Is.Not.Null); + Assert.That(context.ErrorContexts[0].Exception, Is.TypeOf()); + Assert.That(context.ErrorContexts[0].DelayedDeliveriesPerformed, Is.EqualTo(0)); + Assert.That(context.ErrorContexts[1].Message, Is.Not.Null); + Assert.That(context.ErrorContexts[1].Exception, Is.TypeOf()); + Assert.That(context.ErrorContexts[1].DelayedDeliveriesPerformed, Is.EqualTo(1)); + } + + class Context : ScenarioContext + { + public List ErrorContexts { get; } = new List(); + } + + class Endpoint : EndpointConfigurationBuilder + { + public Endpoint() + { + EndpointSetup((config, context) => + { + var testContext = (Context) context.ScenarioContext; + + config.EnableFeature(); + config.Recoverability() + .CustomPolicy((cfg, errorContext) => + { + testContext.ErrorContexts.Add(errorContext); + + if (errorContext.DelayedDeliveriesPerformed >= 1) + { + return RecoverabilityAction.MoveToError(cfg.Failed.ErrorQueue); + } + + return RecoverabilityAction.DelayedRetry(TimeSpan.FromMilliseconds(1)); + }); + }); + } + + class Handler : IHandleMessages + { + public Task Handle(MessageToBeRetried message, IMessageHandlerContext context) + { + throw new SimulatedException(); + } + } + } + + class MessageToBeRetried : IMessage + { + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_provided.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_provided.cs new file mode 100644 index 000000000..84220a0b3 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_custom_policy_provided.cs @@ -0,0 +1,71 @@ +namespace NServiceBus.AcceptanceTests.Recoverability.Retries +{ + using System; + using System.Linq; + using System.Threading.Tasks; + using AcceptanceTesting; + using EndpointTemplates; + using Features; + using NUnit.Framework; + + public class When_custom_policy_provided : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_pass_recoverability_configuration() + { + var context = await Scenario.Define() + .WithEndpoint(b => + b.When(bus => bus.SendLocal(new MessageToBeRetried())) + .DoNotFailOnErrorMessages()) + .Done(c => c.FailedMessages.Any()) + .Run(); + + Assert.That(context.Configuration.Immediate.MaxNumberOfRetries, Is.EqualTo(MaxImmediateRetries)); + Assert.That(context.Configuration.Delayed.MaxNumberOfRetries, Is.EqualTo(MaxDelayedRetries)); + Assert.That(context.Configuration.Delayed.TimeIncrease, Is.EqualTo(DelayedRetryDelayIncrease)); + } + + static TimeSpan DelayedRetryDelayIncrease = TimeSpan.FromMinutes(1); + const int MaxImmediateRetries = 2; + const int MaxDelayedRetries = 2; + + class Context : ScenarioContext + { + public RecoverabilityConfig Configuration { get; set; } + } + + class Endpoint : EndpointConfigurationBuilder + { + public Endpoint() + { + EndpointSetup((config, context) => + { + var testContext = (Context) context.ScenarioContext; + + config.EnableFeature(); + config.Recoverability() + .Immediate(immediate => immediate.NumberOfRetries(MaxImmediateRetries)) + .Delayed(delayed => delayed.NumberOfRetries(MaxDelayedRetries).TimeIncrease(DelayedRetryDelayIncrease)) + .CustomPolicy((cfg, errorContext) => + { + testContext.Configuration = cfg; + + return RecoverabilityAction.MoveToError(cfg.Failed.ErrorQueue); + }); + }); + } + + class Handler : IHandleMessages + { + public Task Handle(MessageToBeRetried message, IMessageHandlerContext context) + { + throw new SimulatedException(); + } + } + } + + class MessageToBeRetried : IMessage + { + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_doing_flr_with_default_settings.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_doing_flr_with_default_settings.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_doing_flr_with_default_settings.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_doing_flr_with_default_settings.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_doing_flr_with_dtc_on.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_doing_flr_with_dtc_on.cs similarity index 89% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_doing_flr_with_dtc_on.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_doing_flr_with_dtc_on.cs index 67fa4f9b3..c37513912 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_doing_flr_with_dtc_on.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_doing_flr_with_dtc_on.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; - using Features; using NServiceBus.Config; using NUnit.Framework; using ScenarioDescriptors; @@ -30,8 +29,6 @@ public Task Should_do_X_retries_by_default_with_dtc_on() Assert.AreEqual(maxretries + 1, c.NumberOfTimesInvoked, $"The FLR should by default retry {maxretries} times"); Assert.AreEqual(maxretries, c.Logs.Count(l => l.Message .StartsWith($"First Level Retry is going to retry message '{c.PhysicalMessageId}' because of an exception:"))); - Assert.AreEqual(1, c.Logs.Count(l => l.Message - .StartsWith($"Giving up First Level Retries for message '{c.PhysicalMessageId}'."))); }) .Run(); } @@ -56,10 +53,9 @@ public RetryEndpoint() EndpointSetup((b, context) => { var scenarioContext = (Context) context.ScenarioContext; - b.EnableFeature(); b.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => scenarioContext.GaveUpOnRetries = true; }) - .WithConfig(c => c.MaxRetries = maxretries); + .WithConfig(c => c.MaxRetries = maxretries); } class MessageToBeRetriedHandler : IHandleMessages diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_doing_flr_with_native_transactions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_doing_flr_with_native_transactions.cs similarity index 92% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_doing_flr_with_native_transactions.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_doing_flr_with_native_transactions.cs index 19156684f..c57e1ad95 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_doing_flr_with_native_transactions.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_doing_flr_with_native_transactions.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; - using Features; using NUnit.Framework; using ScenarioDescriptors; @@ -28,8 +27,6 @@ public Task Should_do_5_retries_by_default_with_native_transactions() Assert.AreEqual(5 + 1, c.NumberOfTimesInvoked, "The FLR should by default retry 5 times"); Assert.AreEqual(5, c.Logs.Count(l => l.Message .StartsWith($"First Level Retry is going to retry message '{c.PhysicalMessageId}' because of an exception:"))); - Assert.AreEqual(1, c.Logs.Count(l => l.Message - .StartsWith($"Giving up First Level Retries for message '{c.PhysicalMessageId}'."))); }) .Run(); } @@ -52,7 +49,7 @@ public RetryEndpoint() EndpointSetup((config, context) => { var scenarioContext = (Context) context.ScenarioContext; - config.EnableFeature(); + config.Recoverability().Immediate(immediate => immediate.NumberOfRetries(5)); config.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => scenarioContext.ForwardedToErrorQueue = true; config.UseTransport(context.GetTransportType()) .Transactions(TransportTransactionMode.ReceiveOnly); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_fails_flr.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_fails_flr.cs similarity index 95% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_fails_flr.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_fails_flr.cs index 56a4cc831..ca250d4bd 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_fails_flr.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_fails_flr.cs @@ -52,10 +52,7 @@ public SLREndpoint() EndpointSetup(config => { config.EnableFeature(); - config.EnableFeature(); }) - .WithConfig(c => { c.MaxRetries = 0; //to skip the FLR - }) .WithConfig(c => { c.NumberOfRetries = 1; diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_fails_with_retries_set_to_0.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_fails_with_retries_set_to_0.cs similarity index 96% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_fails_with_retries_set_to_0.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_fails_with_retries_set_to_0.cs index 4179cb5e0..b4d07e8cd 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_fails_with_retries_set_to_0.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_fails_with_retries_set_to_0.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; - using Features; using NServiceBus.Config; using NUnit.Framework; @@ -43,7 +42,6 @@ public RetryEndpoint() EndpointSetup((configure, context) => { var scenarioContext = (Context) context.ScenarioContext; - configure.EnableFeature(); configure.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => scenarioContext.GaveUp = true; }) .WithConfig(c => { c.MaxRetries = 0; }); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_message_fails_retries.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_message_fails_retries.cs similarity index 92% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_message_fails_retries.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_message_fails_retries.cs index e36f13bd6..85982a9ad 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_message_fails_retries.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_message_fails_retries.cs @@ -6,7 +6,6 @@ using AcceptanceTesting; using AcceptanceTesting.Support; using EndpointTemplates; - using Features; using NUnit.Framework; public class When_message_fails_retries : NServiceBusAcceptanceTest @@ -37,7 +36,7 @@ await Scenario.Define() Assert.IsAssignableFrom(typeof(SimulatedException), failedMessage.Exception); Assert.AreEqual(1, testContext.Logs.Count(l => l.Message - .StartsWith($"Moving message '{testContext.PhysicalMessageId}' to the error queue because processing failed due to an exception:"))); + .StartsWith($"Moving message '{testContext.PhysicalMessageId}' to the error queue 'error' because processing failed due to an exception:"))); } public class RetryEndpoint : EndpointConfigurationBuilder @@ -47,8 +46,6 @@ public RetryEndpoint() EndpointSetup((configure, context) => { var scenarioContext = (Context) context.ScenarioContext; - configure.DisableFeature(); - configure.DisableFeature(); configure.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => scenarioContext.ForwardedToErrorQueue = true; }); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_message_is_deferred_by_slr_using_dtc.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_message_is_deferred_by_slr_using_dtc.cs similarity index 96% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_message_is_deferred_by_slr_using_dtc.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_message_is_deferred_by_slr_using_dtc.cs index ec0b5a908..fde0304d5 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_message_is_deferred_by_slr_using_dtc.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_message_is_deferred_by_slr_using_dtc.cs @@ -47,8 +47,6 @@ public Endpoint() { EndpointSetup(config => { - config.DisableFeature(); - config.EnableFeature(); config.EnableFeature(); config.SendFailedMessagesTo(ErrorQueueName); }) diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_and_counting.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_and_counting.cs similarity index 85% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_and_counting.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_and_counting.cs index 47e30a7e7..fe0979c54 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_and_counting.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_and_counting.cs @@ -24,8 +24,6 @@ public async Task Should_reschedule_message_three_times_by_default() Assert.IsTrue(context.ForwardedToErrorQueue); Assert.AreEqual(3, context.Logs.Count(l => l.Message .StartsWith($"Second Level Retry will reschedule message '{context.PhysicalMessageId}'"))); - Assert.AreEqual(1, context.Logs.Count(l => l.Message - .StartsWith($"Giving up Second Level Retries for message '{context.PhysicalMessageId}'."))); } class Context : ScenarioContext @@ -41,12 +39,10 @@ public RetryEndpoint() EndpointSetup((configure, context) => { var scenarioContext = (Context) context.ScenarioContext; - configure.DisableFeature(); - configure.EnableFeature(); configure.EnableFeature(); configure.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => { scenarioContext.ForwardedToErrorQueue = true; }; }) - .WithConfig(c => c.TimeIncrease = TimeSpan.FromMilliseconds(1)); + .WithConfig(c => c.TimeIncrease = TimeSpan.FromMilliseconds(1)); } class MessageToBeRetriedHandler : IHandleMessages diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_flr_disabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_with_flr_disabled.cs similarity index 90% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_flr_disabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_with_flr_disabled.cs index 7684f634f..63122eeeb 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_flr_disabled.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_with_flr_disabled.cs @@ -13,7 +13,7 @@ public class When_performing_slr_with_flr_disabled : NServiceBusAcceptanceTest [Test] public async Task Should_reschedule_message_three_times_by_default() { - var context = await Scenario.Define((c => { c.Id = Guid.NewGuid(); })) + var context = await Scenario.Define(c => { c.Id = Guid.NewGuid(); }) .WithEndpoint(b => b .When((session, ctx) => session.SendLocal(new MessageToBeRetried {Id = ctx.Id})) .DoNotFailOnErrorMessages()) @@ -35,8 +35,6 @@ public RetryEndpoint() { EndpointSetup((configure, context) => { - configure.DisableFeature(); - configure.EnableFeature(); configure.EnableFeature(); }).WithConfig(c => c.TimeIncrease = TimeSpan.FromMilliseconds(1)); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_regular_exception.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_with_regular_exception.cs similarity index 96% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_regular_exception.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_with_regular_exception.cs index 3846591ad..edede3bb9 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_regular_exception.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_with_regular_exception.cs @@ -38,8 +38,6 @@ public RetryEndpoint() EndpointSetup((configure, context) => { var scenarioContext = (Context) context.ScenarioContext; - configure.DisableFeature(); - configure.EnableFeature(); configure.EnableFeature(); configure.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => { scenarioContext.SlrChecksum = Checksum(message.Body); }; configure.RegisterComponents(c => c.ConfigureComponent(DependencyLifecycle.InstancePerCall)); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_serialization_exception.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_with_serialization_exception.cs similarity index 96% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_serialization_exception.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_with_serialization_exception.cs index 52a9ab544..84cbf5169 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/Retries/When_performing_slr_with_serialization_exception.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/Retries/When_performing_slr_with_serialization_exception.cs @@ -39,8 +39,6 @@ public RetryEndpoint() EndpointSetup((configure, context) => { var testContext = (Context) context.ScenarioContext; - configure.DisableFeature(); - configure.EnableFeature(); configure.EnableFeature(); configure.RegisterComponents(c => c.ConfigureComponent(DependencyLifecycle.InstancePerCall)); configure.Notifications.Errors.MessageSentToErrorQueue += (sender, message) => diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_custom_policy_moves_to_overridden_error_queue.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_custom_policy_moves_to_overridden_error_queue.cs new file mode 100644 index 000000000..10bf26de8 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_custom_policy_moves_to_overridden_error_queue.cs @@ -0,0 +1,87 @@ +namespace NServiceBus.AcceptanceTests.Recoverability +{ + using System; + using System.Threading.Tasks; + using AcceptanceTesting; + using AcceptanceTesting.Customization; + using EndpointTemplates; + using NUnit.Framework; + + public class When_custom_policy_moves_to_overridden_error_queue : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_move_to_defined_error_queue() + { + var context = await Scenario.Define() + .WithEndpoint(b => b + .DoNotFailOnErrorMessages() + .When((session, ctx) => session.SendLocal(new InitiatingMessage + { + Id = ctx.TestRunId + })) + ) + .WithEndpoint() + .Done(c => c.MessageMovedToErrorQueue) + .Run(); + + Assert.IsTrue(context.MessageMovedToErrorQueue); + } + + class Context : ScenarioContext + { + public bool MessageMovedToErrorQueue { get; set; } + } + + class EndpointWithFailingHandler : EndpointConfigurationBuilder + { + public EndpointWithFailingHandler() + { + EndpointSetup((config, context) => + { + config.Recoverability().CustomPolicy((c, ec) => + RecoverabilityAction.MoveToError(Conventions.EndpointNamingConvention(typeof(ErrorSpy)))); + + config.SendFailedMessagesTo("error"); + }); + } + + class InitiatingHandler : IHandleMessages + { + public Context TestContext { get; set; } + + public Task Handle(InitiatingMessage initiatingMessage, IMessageHandlerContext context) + { + throw new SimulatedException(); + } + } + } + + class ErrorSpy : EndpointConfigurationBuilder + { + public ErrorSpy() + { + EndpointSetup(); + } + + class InitiatingMessageHandler : IHandleMessages + { + public Context TestContext { get; set; } + + public Task Handle(InitiatingMessage initiatingMessage, IMessageHandlerContext context) + { + if (initiatingMessage.Id == TestContext.TestRunId) + { + TestContext.MessageMovedToErrorQueue = true; + } + + return Task.FromResult(0); + } + } + } + + class InitiatingMessage : IMessage + { + public Guid Id { get; set; } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_error_is_overridden_in_code.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_error_is_overridden_in_code.cs similarity index 96% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_error_is_overridden_in_code.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_error_is_overridden_in_code.cs index ce2999c9f..3b5629af7 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_error_is_overridden_in_code.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_error_is_overridden_in_code.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; - using Features; using NServiceBus.Config; using NUnit.Framework; @@ -30,7 +29,6 @@ public UserEndpoint() { EndpointSetup(b => { - b.DisableFeature(); b.SendFailedMessagesTo("error_with_code_source"); }) .WithConfig(c => { c.MaxRetries = 0; }); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_message_is_moved_to_error_queue.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue.cs similarity index 52% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_message_is_moved_to_error_queue.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue.cs index edc6bccf9..e3fe7b2e9 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_message_is_moved_to_error_queue.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue.cs @@ -3,8 +3,8 @@ using System; using System.Threading.Tasks; using AcceptanceTesting; + using AcceptanceTesting.Customization; using EndpointTemplates; - using Features; using NServiceBus.Pipeline; using NUnit.Framework; using ScenarioDescriptors; @@ -15,58 +15,65 @@ public class When_message_is_moved_to_error_queue : NServiceBusAcceptanceTest [TestCase(TransportTransactionMode.TransactionScope)] public Task Should_not_send_outgoing_messages(TransportTransactionMode transactionMode) { - return Scenario.Define(c => - { - c.Id = Guid.NewGuid(); - c.TransactionMode = transactionMode; - }) - .WithEndpoint(b => b.DoNotFailOnErrorMessages() - .When((session, context) => session.SendLocal(new InitiatingMessage - { - Id = context.Id - })) - ) - .WithEndpoint() - .Done(c => c.MessageMovedToErrorQueue) - .Repeat(r => r.For()) - .Should(c => Assert.IsFalse(c.OutgoingMessageSent, "Outgoing messages should not be sent")) - .Run(); + return Scenario.Define(c => { c.TransactionMode = transactionMode; }) + .WithEndpoint(b => b.DoNotFailOnErrorMessages() + .When((session, context) => session.SendLocal(new InitiatingMessage + { + Id = context.TestRunId + })) + ) + .WithEndpoint() + .Done(c => c.MessageMovedToErrorQueue) + .Repeat(r => r.For()) + .Should(c => Assert.IsFalse(c.OutgoingMessageSent, "Outgoing messages should not be sent")) + .Run(); } [TestCase(TransportTransactionMode.ReceiveOnly)] [TestCase(TransportTransactionMode.None)] public Task May_send_outgoing_messages(TransportTransactionMode transactionMode) { - return Scenario.Define(c => - { - c.Id = Guid.NewGuid(); - c.TransactionMode = transactionMode; - }) - .WithEndpoint(b => b.DoNotFailOnErrorMessages() - .When((session, context) => session.SendLocal(new InitiatingMessage - { - Id = context.Id - })) - ) - .WithEndpoint() - .Done(c => c.MessageMovedToErrorQueue) - .Repeat(r => r.For()) - .Run(); + return Scenario.Define(c => { c.TransactionMode = transactionMode; }) + .WithEndpoint(b => b.DoNotFailOnErrorMessages() + .When((session, context) => session.SendLocal(new InitiatingMessage + { + Id = context.TestRunId + })) + ) + .WithEndpoint() + .Done(c => c.MessageMovedToErrorQueue) + .Repeat(r => r.For()) + .Run(); } - const string ErrorSpyQueueName = "error_spy_queue"; + [Test] + public async Task Should_log_exception() + { + var context = await Scenario.Define() + .WithEndpoint(b => b + .DoNotFailOnErrorMessages() + .When((session, ctx) => session.SendLocal(new InitiatingMessage + { + Id = ctx.TestRunId + })) + ) + .WithEndpoint() + .Done(c => c.MessageMovedToErrorQueue) + .Run(); + + Assert.That(context.Logs, Has.Some.Message.Match($"Moving message .+ to the error queue '{ Conventions.EndpointNamingConvention(typeof(ErrorSpy)) }' because processing failed due to an exception: NServiceBus.AcceptanceTesting.SimulatedException:")); + } class Context : ScenarioContext { - public Guid Id { get; set; } public bool MessageMovedToErrorQueue { get; set; } public bool OutgoingMessageSent { get; set; } public TransportTransactionMode TransactionMode { get; set; } } - class Endpoint : EndpointConfigurationBuilder + class EndpointWithOutgoingMessages : EndpointConfigurationBuilder { - public Endpoint() + public EndpointWithOutgoingMessages() { EndpointSetup((config, context) => { @@ -74,10 +81,8 @@ public Endpoint() config.UseTransport(context.GetTransportType()) .Transactions(testContext.TransactionMode); - config.DisableFeature(); - config.DisableFeature(); - config.Pipeline.Register(new RegisterThrowingBehavior()); - config.SendFailedMessagesTo(ErrorSpyQueueName); + config.Pipeline.Register(new ThrowingBehavior(), "Behavior that always throws"); + config.SendFailedMessagesTo(Conventions.EndpointNamingConvention(typeof(ErrorSpy))); }); } @@ -87,9 +92,9 @@ class InitiatingHandler : IHandleMessages public async Task Handle(InitiatingMessage initiatingMessage, IMessageHandlerContext context) { - if (initiatingMessage.Id == TestContext.Id) + if (initiatingMessage.Id == TestContext.TestRunId) { - await context.Send(ErrorSpyQueueName, new SubsequentMessage + await context.Send(Conventions.EndpointNamingConvention(typeof(ErrorSpy)), new SubsequentMessage { Id = initiatingMessage.Id }); @@ -98,12 +103,27 @@ public async Task Handle(InitiatingMessage initiatingMessage, IMessageHandlerCon } } + class EndpointWithFailingHandler : EndpointConfigurationBuilder + { + public EndpointWithFailingHandler() + { + EndpointSetup((config, context) => { config.SendFailedMessagesTo(Conventions.EndpointNamingConvention(typeof(ErrorSpy))); }); + } + + class InitiatingMessageHandler : IHandleMessages + { + public Task Handle(InitiatingMessage message, IMessageHandlerContext context) + { + throw new SimulatedException("message should be moved to the error queue"); + } + } + } + class ErrorSpy : EndpointConfigurationBuilder { public ErrorSpy() { - EndpointSetup(config => config.LimitMessageProcessingConcurrencyTo(1)) - .CustomEndpointName(ErrorSpyQueueName); + EndpointSetup(config => config.LimitMessageProcessingConcurrencyTo(1)); } class InitiatingMessageHandler : IHandleMessages @@ -112,7 +132,7 @@ class InitiatingMessageHandler : IHandleMessages public Task Handle(InitiatingMessage initiatingMessage, IMessageHandlerContext context) { - if (initiatingMessage.Id == TestContext.Id) + if (initiatingMessage.Id == TestContext.TestRunId) { TestContext.MessageMovedToErrorQueue = true; } @@ -127,7 +147,7 @@ class SubsequentMessageHandler : IHandleMessages public Task Handle(SubsequentMessage message, IMessageHandlerContext context) { - if (message.Id == TestContext.Id) + if (message.Id == TestContext.TestRunId) { TestContext.OutgoingMessageSent = true; } @@ -137,14 +157,6 @@ public Task Handle(SubsequentMessage message, IMessageHandlerContext context) } } - class RegisterThrowingBehavior : RegisterStep - { - public RegisterThrowingBehavior() : base("ThrowingBehavior", typeof(ThrowingBehavior), "Behavior that always throws") - { - InsertAfter("MoveFaultsToErrorQueue"); - } - } - class ThrowingBehavior : Behavior { public override async Task Invoke(ITransportReceiveContext context, Func next) diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_message_is_moved_to_error_queue_using_dtc.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue_using_dtc.cs similarity index 95% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_message_is_moved_to_error_queue_using_dtc.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue_using_dtc.cs index d6e5160eb..455fe5904 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_message_is_moved_to_error_queue_using_dtc.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue_using_dtc.cs @@ -6,7 +6,6 @@ using System.Transactions; using AcceptanceTesting; using EndpointTemplates; - using Features; using NUnit.Framework; using ScenarioDescriptors; @@ -44,8 +43,6 @@ public Endpoint() { EndpointSetup(config => { - config.DisableFeature(); - config.DisableFeature(); config.SendFailedMessagesTo(ErrorQueueName); }); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue_with_header_customizations.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue_with_header_customizations.cs new file mode 100644 index 000000000..4fa33a3cd --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_is_moved_to_error_queue_with_header_customizations.cs @@ -0,0 +1,99 @@ +namespace NServiceBus.AcceptanceTests.Recoverability +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using AcceptanceTesting; + using AcceptanceTesting.Customization; + using EndpointTemplates; + using NUnit.Framework; + + public class When_message_is_moved_to_error_queue_with_header_customizations : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_apply_header_customizations() + { + var context = await Scenario.Define() + .WithEndpoint(b => b + .DoNotFailOnErrorMessages() + .When((session, ctx) => session.SendLocal(new InitiatingMessage + { + Id = ctx.TestRunId + })) + ) + .WithEndpoint() + .Done(c => c.MessageMovedToErrorQueue) + .Run(); + + Assert.IsFalse(context.Headers.ContainsKey("NServiceBus.ExceptionInfo.ExceptionType")); + Assert.IsTrue(context.Headers.ContainsKey("NServiceBus.ExceptionInfo.Message")); + Assert.AreEqual("this is a large message", context.Headers["NServiceBus.ExceptionInfo.Message"]); + Assert.IsTrue(context.Headers.ContainsKey("NServiceBus.ExceptionInfo.NotInventedHere")); + Assert.AreEqual("NotInventedHere", context.Headers["NServiceBus.ExceptionInfo.NotInventedHere"]); + } + + class Context : ScenarioContext + { + public bool MessageMovedToErrorQueue { get; set; } + public IReadOnlyDictionary Headers { get; set; } + } + + class EndpointWithFailingHandler : EndpointConfigurationBuilder + { + public EndpointWithFailingHandler() + { + EndpointSetup((config, context) => + { + config.Recoverability() + .Failed(failed => failed.HeaderCustomization(headers => + { + headers.Remove("NServiceBus.ExceptionInfo.ExceptionType"); + headers["NServiceBus.ExceptionInfo.Message"] = headers["NServiceBus.ExceptionInfo.Message"].ToLower(); + headers["NServiceBus.ExceptionInfo.NotInventedHere"] = "NotInventedHere"; + })); + + config.SendFailedMessagesTo(Conventions.EndpointNamingConvention(typeof(ErrorSpy))); + }); + } + + class InitiatingHandler : IHandleMessages + { + public Context TestContext { get; set; } + + public Task Handle(InitiatingMessage initiatingMessage, IMessageHandlerContext context) + { + throw new SimulatedException("THIS IS A LARGE MESSAGE"); + } + } + } + + class ErrorSpy : EndpointConfigurationBuilder + { + public ErrorSpy() + { + EndpointSetup(); + } + + class InitiatingMessageHandler : IHandleMessages + { + public Context TestContext { get; set; } + + public Task Handle(InitiatingMessage initiatingMessage, IMessageHandlerContext context) + { + if (initiatingMessage.Id == TestContext.TestRunId) + { + TestContext.Headers = context.MessageHeaders; + TestContext.MessageMovedToErrorQueue = true; + } + + return Task.FromResult(0); + } + } + } + + class InitiatingMessage : IMessage + { + public Guid Id { get; set; } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_message_with_TimeToBeReceived_fails.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_with_TimeToBeReceived_fails.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_message_with_TimeToBeReceived_fails.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_with_TimeToBeReceived_fails.cs index eafda2be7..30f611025 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Recoverability/When_message_with_TimeToBeReceived_fails.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Recoverability/When_message_with_TimeToBeReceived_fails.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; - using Features; using NServiceBus.Config; using NUnit.Framework; @@ -38,7 +37,6 @@ public EndpointThatThrows() { EndpointSetup(b => { - b.DisableFeature(); b.SendFailedMessagesTo("errorQueueForAcceptanceTest"); }) .WithConfig(c => { c.MaxRetries = 0; }); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_a_duplicate_message_arrives.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_a_duplicate_message_arrives.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_a_duplicate_message_arrives.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_a_duplicate_message_arrives.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_a_message_is_audited.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_a_message_is_audited.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_a_message_is_audited.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_a_message_is_audited.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_blowing_up_just_after_dispatch.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_blowing_up_just_after_dispatch.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_blowing_up_just_after_dispatch.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_blowing_up_just_after_dispatch.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_clearing_saga_timeouts.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_clearing_saga_timeouts.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_clearing_saga_timeouts.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_clearing_saga_timeouts.cs index 22cc98a8e..f894d292a 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_clearing_saga_timeouts.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_clearing_saga_timeouts.cs @@ -1,7 +1,6 @@ namespace NServiceBus.AcceptanceTests.Reliability.Outbox { using System; - using System.Linq; using System.Threading.Tasks; using AcceptanceTesting; using Configuration.AdvanceExtensibility; @@ -9,8 +8,9 @@ using Extensibility; using Features; using NServiceBus.Outbox; - using NServiceBus.Persistence; + using NServiceBus; using NUnit.Framework; + using Persistence; using ScenarioDescriptors; public class When_clearing_saga_timeouts : NServiceBusAcceptanceTest @@ -94,7 +94,7 @@ public Task Get(string messageId, ContextBag context) public Task Store(OutboxMessage message, OutboxTransaction transaction, ContextBag context) { - testContext.NumberOfOps += message.TransportOperations.Count(); + testContext.NumberOfOps += message.TransportOperations.Length; return Task.FromResult(0); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_dispatching_forwarded_messages.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_dispatching_forwarded_messages.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_dispatching_forwarded_messages.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_dispatching_forwarded_messages.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_receiving_a_message.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_receiving_a_message.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_receiving_a_message.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_receiving_a_message.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_sending_from_a_non_dtc_endpoint.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_sending_from_a_non_dtc_endpoint.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Reliability/Outbox/When_sending_from_a_non_dtc_endpoint.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Reliability/Outbox/When_sending_from_a_non_dtc_endpoint.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs similarity index 89% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs index 378e404e6..b719bc527 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga.cs @@ -68,10 +68,12 @@ public Task Handle(MyEvent message, IMessageHandlerContext context) protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) { + mapper.ConfigureMapping(msg => msg.SomeId).ToSaga(saga => saga.SomeId); } public class AutoSubscriptionSagaData : ContainSagaData { + public virtual string SomeId { get; set; } } } @@ -85,16 +87,19 @@ public Task Handle(MyEventBase message, IMessageHandlerContext context) protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) { + mapper.ConfigureMapping(msg => msg.SomeId).ToSaga(saga => saga.SomeId); } public class SuperClassEventSagaData : ContainSagaData { + public virtual string SomeId { get; set; } } } } public class MyEventBase : IEvent { + public string SomeId { get; set; } } public class MyEventWithParent : MyEventBase @@ -107,6 +112,7 @@ public class MyMessage : IMessage public class MyEvent : IEvent { + public string SomeId { get; set; } } } } \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs similarity index 89% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs index 5eebb0c50..782cfb61d 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_a_saga_autosubscribe_disabled.cs @@ -68,10 +68,12 @@ public Task Handle(MyEvent message, IMessageHandlerContext context) protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) { + mapper.ConfigureMapping(msg => msg.SomeId).ToSaga(saga => saga.SomeId); } public class NotAutoSubscribedSagaSagaData : ContainSagaData { + public virtual string SomeId { get; set; } } } @@ -85,16 +87,19 @@ public Task Handle(MyEventBase message, IMessageHandlerContext context) protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) { + mapper.ConfigureMapping(saga => saga.SomeId).ToSaga(saga => saga.SomeId); } public class NotAutosubscribeSuperClassEventSagaData : ContainSagaData { + public virtual string SomeId { get; set; } } } } public class MyEventBase : IEvent { + public string SomeId { get; set; } } public class MyEventWithParent : MyEventBase @@ -107,6 +112,7 @@ public class MyMessage : IMessage public class MyEvent : IEvent { + public string SomeId { get; set; } } } } \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_autoSubscribe.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_autoSubscribe.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_autoSubscribe.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/AutomaticSubscriptions/When_starting_an_endpoint_with_autoSubscribe.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/SubscriptionBehavior.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/SubscriptionBehavior.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/SubscriptionBehavior.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/SubscriptionBehavior.cs index f0688020d..e2949e3fc 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/SubscriptionBehavior.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/SubscriptionBehavior.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using AcceptanceTesting; using NServiceBus.Pipeline; - using Transports; + using Transport; class SubscriptionBehavior : Behavior where TContext : ScenarioContext { diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/SubscriptionBehaviorExtensions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/SubscriptionBehaviorExtensions.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/SubscriptionBehaviorExtensions.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/SubscriptionBehaviorExtensions.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/SubscriptionEventArgs.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/SubscriptionEventArgs.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/SubscriptionEventArgs.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/SubscriptionEventArgs.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_base_event_from_2_publishers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_base_event_from_2_publishers.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_base_event_from_2_publishers.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_base_event_from_2_publishers.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_broadcasting_a_command.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_broadcasting_a_command.cs similarity index 80% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_broadcasting_a_command.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_broadcasting_a_command.cs index 55e0831fa..e1d953542 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_broadcasting_a_command.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_broadcasting_a_command.cs @@ -4,6 +4,7 @@ using AcceptanceTesting; using AcceptanceTesting.Customization; using EndpointTemplates; + using Features; using NServiceBus.Routing; using NUnit.Framework; @@ -16,8 +17,8 @@ public async Task Should_send_it_to_all_instances() { var context = await Scenario.Define() .WithEndpoint(b => b.When(c => c.EndpointsStarted, (session, c) => session.Send(new Request()))) - .WithEndpoint(b => { b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("1")); }) - .WithEndpoint(b => { b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("2")); }) + .WithEndpoint(b => { b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("1")); }) + .WithEndpoint(b => { b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("2")); }) .Done(c => c.Receiver1TimesCalled > 0 && c.Receiver2TimesCalled > 0) .Run(); @@ -35,15 +36,22 @@ public class Sender : EndpointConfigurationBuilder { public Sender() { - EndpointSetup(c => + EndpointSetup((c, r) => { - c.UnicastRouting().RouteToEndpoint(typeof(Request), ReceiverEndpoint); + c.UseTransport(r.GetTransportType()).Routing().RouteToEndpoint(typeof(Request), ReceiverEndpoint); + c.EnableFeature(); + }); + } - c.UnicastRouting().Mapping.SetMessageDistributionStrategy(new AllInstancesDistributionStrategy(), t => t == typeof(Request)); - c.UnicastRouting().Mapping.Physical.Add(new EndpointName(ReceiverEndpoint), + class SpecificRoutingFeature : Feature + { + protected override void Setup(FeatureConfigurationContext context) + { + context.DistributionPolicy().SetDistributionStrategy(ReceiverEndpoint, new AllInstancesDistributionStrategy()); + context.EndpointInstances().Add( new EndpointInstance(ReceiverEndpoint, "1"), new EndpointInstance(ReceiverEndpoint, "2")); - }); + } } public class ResponseHandler : IHandleMessages diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_handler_exists_but_routing_information_is_missing.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_handler_exists_but_routing_information_is_missing.cs similarity index 91% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_handler_exists_but_routing_information_is_missing.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_handler_exists_but_routing_information_is_missing.cs index 6c2313180..069c9c223 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_handler_exists_but_routing_information_is_missing.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_handler_exists_but_routing_information_is_missing.cs @@ -11,7 +11,7 @@ public class when_using_autosubscribe_with_missing_routing_information : NServic [Test] public Task Should_skip_events_with_missing_routes() { - return Scenario.Define() + return Scenario.Define() .WithEndpoint() .Done(c => c.EndpointsStarted) .Repeat(r => r.For()) @@ -19,10 +19,6 @@ public Task Should_skip_events_with_missing_routes() .Run(); } - public class Context : ScenarioContext - { - } - public class Subscriber : EndpointConfigurationBuilder { public Subscriber() diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_multi_subscribing_to_a_polymorphic_event_on_multicast_transports.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_multi_subscribing_to_a_polymorphic_event_on_multicast_transports.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_multi_subscribing_to_a_polymorphic_event_on_multicast_transports.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_multi_subscribing_to_a_polymorphic_event_on_multicast_transports.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_multi_subscribing_to_a_polymorphic_event_on_unicast_transports.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_multi_subscribing_to_a_polymorphic_event_on_unicast_transports.cs similarity index 91% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_multi_subscribing_to_a_polymorphic_event_on_unicast_transports.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_multi_subscribing_to_a_polymorphic_event_on_unicast_transports.cs index 1d9a29545..2649dcf23 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_multi_subscribing_to_a_polymorphic_event_on_unicast_transports.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_multi_subscribing_to_a_polymorphic_event_on_unicast_transports.cs @@ -53,6 +53,8 @@ public Publisher1() { EndpointSetup(b => { + //FLR on since subscription storages can throw on concurrency violation and need to retry + b.Recoverability().Immediate(immediate => immediate.NumberOfRetries(5)); b.OnEndpointSubscribed((args, context) => { context.AddTrace("Publisher1 OnEndpointSubscribed " + args.MessageType); @@ -61,7 +63,6 @@ public Publisher1() context.Publisher1HasASubscriberForIMyEvent = true; } }); - b.EnableFeature(); //Because subscription storages can throw on concurrency violation and need to retry }); } } @@ -72,6 +73,9 @@ public Publisher2() { EndpointSetup(b => { + //FLR on since subscription storages can throw on concurrency violation and need to retry + b.Recoverability().Immediate(immediate => immediate.NumberOfRetries(5)); + b.OnEndpointSubscribed((args, context) => { context.AddTrace("Publisher2 OnEndpointSubscribed " + args.MessageType); @@ -81,7 +85,6 @@ public Publisher2() context.Publisher2HasDetectedASubscriberForEvent2 = true; } }); - b.EnableFeature(); //Because subscription storages can throw on concurrency violation and need to retry }); } } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_an_event_implementing_two_unrelated_interfaces.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_an_event_implementing_two_unrelated_interfaces.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_an_event_implementing_two_unrelated_interfaces.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_an_event_implementing_two_unrelated_interfaces.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_an_interface.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_an_interface.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_an_interface.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_an_interface.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_from_sendonly.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_from_sendonly.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_from_sendonly.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_from_sendonly.cs index 3a0ce63b7..45cd4f1fb 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_from_sendonly.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_from_sendonly.cs @@ -8,8 +8,9 @@ using EndpointTemplates; using Extensibility; using Features; - using NServiceBus.Persistence; + using NServiceBus; using NUnit.Framework; + using Persistence; using ScenarioDescriptors; using Unicast.Subscriptions; using Unicast.Subscriptions.MessageDrivenSubscriptions; diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_to_scaled_out_subscribers_on_multicast_transports.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_to_scaled_out_subscribers_on_multicast_transports.cs similarity index 94% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_to_scaled_out_subscribers_on_multicast_transports.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_to_scaled_out_subscribers_on_multicast_transports.cs index 97fa320ec..e9acf152f 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_to_scaled_out_subscribers_on_multicast_transports.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_to_scaled_out_subscribers_on_multicast_transports.cs @@ -14,10 +14,10 @@ public async Task Each_event_should_be_delivered_to_single_instance_of_each_subs { await Scenario.Define() .WithEndpoint(b => b.When(c => c.EndpointsStarted, async (session, c) => { await session.Publish(new MyEvent()); })) - .WithEndpoint(b => b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("1"))) - .WithEndpoint(b => b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("2"))) - .WithEndpoint(b => b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("1"))) - .WithEndpoint(b => b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("2"))) + .WithEndpoint(b => b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("1"))) + .WithEndpoint(b => b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("2"))) + .WithEndpoint(b => b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("1"))) + .WithEndpoint(b => b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("2"))) .Done(c => c.SubscriberACounter > 0 && c.SubscriberBCounter > 0) .Repeat(r => r.For()) .Should(c => diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_to_scaled_out_subscribers_on_unicast_transports.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_to_scaled_out_subscribers_on_unicast_transports.cs similarity index 89% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_to_scaled_out_subscribers_on_unicast_transports.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_to_scaled_out_subscribers_on_unicast_transports.cs index 84c6fb2d0..490d7af41 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_to_scaled_out_subscribers_on_unicast_transports.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_to_scaled_out_subscribers_on_unicast_transports.cs @@ -17,10 +17,10 @@ public async Task Each_event_should_be_delivered_to_single_instance_of_each_subs { await Scenario.Define() .WithEndpoint(b => b.When(c => c.SubscribersCounter == 4, async (session, c) => { await session.Publish(new MyEvent()); })) - .WithEndpoint(b => b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("1"))) - .WithEndpoint(b => b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("2"))) - .WithEndpoint(b => b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("1"))) - .WithEndpoint(b => b.CustomConfig(c => c.ScaleOut().InstanceDiscriminator("2"))) + .WithEndpoint(b => b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("1"))) + .WithEndpoint(b => b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("2"))) + .WithEndpoint(b => b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("1"))) + .WithEndpoint(b => b.CustomConfig(c => c.MakeInstanceUniquelyAddressable("2"))) .Done(c => c.ProcessedByA > 0 && c.ProcessedByB > 0) .Repeat(r => r.For()) .Should(c => @@ -71,7 +71,7 @@ public class SubscriberA : EndpointConfigurationBuilder { public SubscriberA() { - EndpointSetup(c => { c.UnicastRouting().AddPublisher(PublisherEndpoint, typeof(MyEvent)); }); + EndpointSetup(c => { c.RegisterPublisherForType(typeof(MyEvent), PublisherEndpoint); }); } public class MyEventHandler : IHandleMessages @@ -90,7 +90,7 @@ public class SubscriberB : EndpointConfigurationBuilder { public SubscriberB() { - EndpointSetup(c => { c.UnicastRouting().AddPublisher(PublisherEndpoint, typeof(MyEvent)); }); + EndpointSetup(c => { c.RegisterPublisherForType(typeof(MyEvent), PublisherEndpoint); }); } public class MyEventHandler : IHandleMessages diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_using_root_type.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_using_root_type.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_using_root_type.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_using_root_type.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_with_only_local_messagehandlers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_with_only_local_messagehandlers.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_with_only_local_messagehandlers.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_with_only_local_messagehandlers.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_with_overridden_local_address.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_with_overridden_local_address.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_publishing_with_overridden_local_address.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_publishing_with_overridden_local_address.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_replying_to_message.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_replying_to_message.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_replying_to_message.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_replying_to_message.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_subscribing_to_a_polymorphic_event.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_subscribing_to_a_polymorphic_event.cs similarity index 75% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_subscribing_to_a_polymorphic_event.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_subscribing_to_a_polymorphic_event.cs index 639ffcadd..a6b6b6e6e 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_subscribing_to_a_polymorphic_event.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_subscribing_to_a_polymorphic_event.cs @@ -10,7 +10,7 @@ public class When_subscribing_to_a_polymorphic_event : NServiceBusAcceptanceTest { [Test] - public async Task Event_should_be_delivered() + public async Task Subclassed_event_should_be_delivered_to_base_subscribers() { var context = await Scenario.Define() .WithEndpoint(b => b.When(c => c.Subscriber1Subscribed && c.Subscriber2Subscribed, session => session.Publish(new MyEvent()))) @@ -39,6 +39,36 @@ public async Task Event_should_be_delivered() Assert.True(context.Subscriber2GotTheEvent); } + [Test] + public async Task Base_event_should_only_be_delivered_to_base_subscribers() + { + var context = await Scenario.Define() + .WithEndpoint(b => b.When(c => c.Subscriber1Subscribed && c.Subscriber2Subscribed, session => session.Publish())) + .WithEndpoint(b => b.When(async (session, c) => + { + await session.Subscribe(); + + if (c.HasNativePubSubSupport) + { + c.Subscriber1Subscribed = true; + } + })) + .WithEndpoint(b => b.When(async (session, c) => + { + await session.Subscribe(); + + if (c.HasNativePubSubSupport) + { + c.Subscriber2Subscribed = true; + } + })) + .Done(c => c.Subscriber1GotTheEvent) + .Run(); + + Assert.True(context.Subscriber1GotTheEvent); + Assert.False(context.Subscriber2GotTheEvent); + } + public class Context : ScenarioContext { public bool Subscriber1GotTheEvent { get; set; } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_using_assembly_level_message_mapping_for_pub_sub.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_using_assembly_level_message_mapping_for_pub_sub.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_using_assembly_level_message_mapping_for_pub_sub.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_using_assembly_level_message_mapping_for_pub_sub.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_using_instance_ids.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_using_instance_ids.cs similarity index 71% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_using_instance_ids.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_using_instance_ids.cs index 9fab9b7ce..1d53ed200 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_using_instance_ids.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_using_instance_ids.cs @@ -4,16 +4,14 @@ using System.Threading.Tasks; using AcceptanceTesting; using AcceptanceTesting.Customization; + using Configuration.AdvanceExtensibility; using EndpointTemplates; using NServiceBus.Routing; using NUnit.Framework; public class When_using_instance_ids : NServiceBusAcceptanceTest { - public static string GetReceiverEndpoint() - { - return Conventions.EndpointNamingConvention(typeof(Receiver)); - } + static string ReceiverEndpoint => Conventions.EndpointNamingConvention(typeof(Receiver)); [Test] public async Task Should_be_addressable_both_by_shared_queue_and_specific_queue() @@ -37,7 +35,10 @@ public class UnawareSender : EndpointConfigurationBuilder { public UnawareSender() { - EndpointSetup(c => { c.UnicastRouting().RouteToEndpoint(typeof(MyMessage), GetReceiverEndpoint()); }); + EndpointSetup((c, r) => + { + c.UseTransport(r.GetTransportType()).Routing().RouteToEndpoint(typeof(MyMessage), ReceiverEndpoint); + }); } } @@ -45,10 +46,10 @@ public class AwareSender : EndpointConfigurationBuilder { public AwareSender() { - EndpointSetup(c => + EndpointSetup((c, r) => { - c.UnicastRouting().RouteToEndpoint(typeof(MyMessage), GetReceiverEndpoint()); - c.UnicastRouting().Mapping.Physical.Add(new EndpointName(GetReceiverEndpoint()), new EndpointInstance(GetReceiverEndpoint(), "XYZ")); + c.UseTransport(r.GetTransportType()).Routing().RouteToEndpoint(typeof(MyMessage), ReceiverEndpoint); + c.GetSettings().GetOrCreate().Add(new EndpointInstance(ReceiverEndpoint, "XYZ")); }); } } @@ -57,7 +58,7 @@ public class Receiver : EndpointConfigurationBuilder { public Receiver() { - EndpointSetup(c => { c.ScaleOut().InstanceDiscriminator("XYZ"); }); + EndpointSetup(c => { c.MakeInstanceUniquelyAddressable("XYZ"); }); } public class MyMessageHandler : IHandleMessages diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_using_legacy_routing_configuration_combined_with_message_driven_pub_sub.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_using_legacy_routing_configuration_combined_with_message_driven_pub_sub.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/When_using_legacy_routing_configuration_combined_with_message_driven_pub_sub.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/When_using_legacy_routing_configuration_combined_with_message_driven_pub_sub.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/when_replying_to_a_message_sent_to_specific_instance.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/when_replying_to_a_message_sent_to_specific_instance.cs similarity index 83% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/when_replying_to_a_message_sent_to_specific_instance.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/when_replying_to_a_message_sent_to_specific_instance.cs index 3a3468651..7113908e0 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Routing/when_replying_to_a_message_sent_to_specific_instance.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Routing/when_replying_to_a_message_sent_to_specific_instance.cs @@ -3,6 +3,7 @@ using System.Threading.Tasks; using AcceptanceTesting; using AcceptanceTesting.Customization; + using Configuration.AdvanceExtensibility; using EndpointTemplates; using NServiceBus.Routing; using NUnit.Framework; @@ -32,10 +33,10 @@ public class Sender : EndpointConfigurationBuilder { public Sender() { - EndpointSetup(c => + EndpointSetup((c, r) => { - c.UnicastRouting().RouteToEndpoint(typeof(MyRequest), ReceiverEndpoint); - c.UnicastRouting().Mapping.Physical.Add(new EndpointName(ReceiverEndpoint), new EndpointInstance(ReceiverEndpoint, "XYZ")); + c.UseTransport(r.GetTransportType()).Routing().RouteToEndpoint(typeof(MyRequest), ReceiverEndpoint); + c.GetSettings().GetOrCreate().Add(new EndpointInstance(ReceiverEndpoint, "XYZ")); }); } @@ -55,7 +56,7 @@ public class Receiver : EndpointConfigurationBuilder { public Receiver() { - EndpointSetup(c => { c.ScaleOut().InstanceDiscriminator("XYZ"); }); + EndpointSetup(c => { c.MakeInstanceUniquelyAddressable("XYZ"); }); } public class MyRequestHandler : IHandleMessages diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/RunDescriptorExtensions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/RunDescriptorExtensions.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/RunDescriptorExtensions.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/RunDescriptorExtensions.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_base_class_message_hits_a_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_base_class_message_hits_a_saga.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_base_class_message_hits_a_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_base_class_message_hits_a_saga.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_existing_saga_instance_exists.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_existing_saga_instance_exists.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_existing_saga_instance_exists.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_existing_saga_instance_exists.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_finder_exists.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_finder_exists.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_finder_exists.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_finder_exists.cs index 052dbbb7a..fed634a25 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_finder_exists.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_finder_exists.cs @@ -5,9 +5,10 @@ using EndpointTemplates; using Extensibility; using Features; - using NServiceBus.Persistence; + using NServiceBus; using NServiceBus.Sagas; using NUnit.Framework; + using Persistence; [TestFixture] public class When_a_finder_exists : NServiceBusAcceptanceTest diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_finder_exists_and_context_information_added.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_finder_exists_and_context_information_added.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_finder_exists_and_context_information_added.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_finder_exists_and_context_information_added.cs index 177f5cb39..1806de8a7 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_finder_exists_and_context_information_added.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_finder_exists_and_context_information_added.cs @@ -6,10 +6,11 @@ namespace NServiceBus.AcceptanceTests.Sagas using EndpointTemplates; using Extensibility; using Features; - using NServiceBus.Persistence; + using NServiceBus; using NServiceBus.Pipeline; using NServiceBus.Sagas; using NUnit.Framework; + using Persistence; [TestFixture] public class When_a_finder_exists_and_context_information_added : NServiceBusAcceptanceTest diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_finder_exists_and_found_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_finder_exists_and_found_saga.cs similarity index 69% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_finder_exists_and_found_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_finder_exists_and_found_saga.cs index 4b8f81f92..b37b7d9ee 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_finder_exists_and_found_saga.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_finder_exists_and_found_saga.cs @@ -4,10 +4,10 @@ using AcceptanceTesting; using EndpointTemplates; using Extensibility; - using Features; - using NServiceBus.Persistence; + using NServiceBus; using NServiceBus.Sagas; using NUnit.Framework; + using Persistence; [TestFixture] public class When_a_finder_exists_and_found_saga : NServiceBusAcceptanceTest @@ -16,7 +16,7 @@ public class When_a_finder_exists_and_found_saga : NServiceBusAcceptanceTest public async Task Should_find_saga_and_not_correlate() { var context = await Scenario.Define() - .WithEndpoint(b => b.When(session => session.SendLocal(new StartSagaMessage()))) + .WithEndpoint(b => b.When(session => session.SendLocal(new StartSagaMessage { Property = "Test" }))) .Done(c => c.Completed) .Run(); @@ -33,7 +33,7 @@ public class SagaEndpoint : EndpointConfigurationBuilder { public SagaEndpoint() { - EndpointSetup(c => c.EnableFeature()); + EndpointSetup(); } public class CustomFinder : IFindSagas.Using @@ -41,13 +41,18 @@ public class CustomFinder : IFindSagas.Using FindBy(SomeOtherMessage message, SynchronizedStorageSession storageSession, ReadOnlyContextBag context) + public ISagaPersister SagaPersister { get; set; } + + public async Task FindBy(SomeOtherMessage message, SynchronizedStorageSession storageSession, ReadOnlyContextBag context) { Context.FinderUsed = true; - return Task.FromResult(new TestSaga08.SagaData08 + var sagaInstance = new TestSaga08.SagaData08 { Property = "jfbsjdfbsdjh" - }); + }; + //Make sure saga exists in the store. Persisters expect it there when they save saga instance after processing a message. + await SagaPersister.Save(sagaInstance, SagaCorrelationProperty.None, storageSession, new ContextBag()).ConfigureAwait(false); + return sagaInstance; } } @@ -70,7 +75,8 @@ public Task Handle(SomeOtherMessage message, IMessageHandlerContext context) protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) { - // not required because of CustomFinder + mapper.ConfigureMapping(saga => saga.Property).ToSaga(saga => saga.Property); + // Mapping not required for SomeOtherMessage because CustomFinder used } public class SagaData08 : ContainSagaData @@ -82,10 +88,12 @@ public class SagaData08 : ContainSagaData public class StartSagaMessage : IMessage { + public string Property { get; set; } } public class SomeOtherMessage : IMessage { + public string Property { get; set; } } } -} \ No newline at end of file +} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_saga_message_goes_through_the_slr.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_saga_message_goes_through_the_slr.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_saga_message_goes_through_the_slr.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_saga_message_goes_through_the_slr.cs index 3e5328bab..58e3f3741 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_a_saga_message_goes_through_the_slr.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_a_saga_message_goes_through_the_slr.cs @@ -40,7 +40,6 @@ public SagaMsgThruSlrEndpt() EndpointSetup(b => { b.EnableFeature(); - b.EnableFeature(); }).WithConfig(slr => { slr.NumberOfRetries = 1; diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_an_endpoint_replies_to_a_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_an_endpoint_replies_to_a_saga.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_an_endpoint_replies_to_a_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_an_endpoint_replies_to_a_saga.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_auto_correlated_property_is_changed.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_auto_correlated_property_is_changed.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_auto_correlated_property_is_changed.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_auto_correlated_property_is_changed.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_doing_request_response_between_sagas.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_doing_request_response_between_sagas.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_doing_request_response_between_sagas.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_doing_request_response_between_sagas.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_doing_request_response_between_sagas_first_handler_responding.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_doing_request_response_between_sagas_first_handler_responding.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_doing_request_response_between_sagas_first_handler_responding.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_doing_request_response_between_sagas_first_handler_responding.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_doing_request_response_between_sagas_response_from_noninitiating.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_doing_request_response_between_sagas_response_from_noninitiating.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_doing_request_response_between_sagas_response_from_noninitiating.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_doing_request_response_between_sagas_response_from_noninitiating.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_doing_request_response_between_sagas_with_timeout.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_doing_request_response_between_sagas_with_timeout.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_doing_request_response_between_sagas_with_timeout.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_doing_request_response_between_sagas_with_timeout.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_forgetting_to_set_a_corr_property.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_forgetting_to_set_a_corr_property.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_forgetting_to_set_a_corr_property.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_forgetting_to_set_a_corr_property.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_message_has_a_saga_id.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_message_has_a_saga_id.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_message_has_a_saga_id.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_message_has_a_saga_id.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_receiving_that_completes_the_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_receiving_that_completes_the_saga.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_receiving_that_completes_the_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_receiving_that_completes_the_saga.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_receiving_that_should_start_a_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_receiving_that_should_start_a_saga.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_receiving_that_should_start_a_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_receiving_that_should_start_a_saga.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_receiving_that_should_start_a_saga_with_interception.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_receiving_that_should_start_a_saga_with_interception.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_receiving_that_should_start_a_saga_with_interception.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_receiving_that_should_start_a_saga_with_interception.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_receiving_that_should_start_a_saga_without_interception.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_receiving_that_should_start_a_saga_without_interception.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_receiving_that_should_start_a_saga_without_interception.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_receiving_that_should_start_a_saga_without_interception.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_replies_to_message_published_by_a_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_replies_to_message_published_by_a_saga.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_replies_to_message_published_by_a_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_replies_to_message_published_by_a_saga.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_handles_unmapped_message.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_handles_unmapped_message.cs new file mode 100644 index 000000000..9b814b066 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_handles_unmapped_message.cs @@ -0,0 +1,123 @@ +namespace NServiceBus.AcceptanceTests.Sagas +{ + using System; + using System.Linq; + using System.Threading.Tasks; + using AcceptanceTesting; + using EndpointTemplates; + using NUnit.Framework; + + public class When_saga_handles_unmapped_message : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_throw_on_unmapped_uncorrelated_msg() + { + var id = Guid.NewGuid(); + + var context = await Scenario.Define() + .WithEndpoint(b => + { + b.DoNotFailOnErrorMessages(); + + b.When(session => session.SendLocal(new StartSagaMessage + { + SomeId = id + })); + }) + .Done(c => c.MappedEchoReceived && (c.EchoReceived || c.FailedMessages.Any())) + .Run(); + + Assert.AreEqual(true, context.StartReceived); + Assert.AreEqual(true, context.OutboundReceived); + Assert.AreEqual(true, context.MappedEchoReceived); + Assert.AreEqual(false, context.EchoReceived); + Assert.AreEqual(1, context.FailedMessages.Count); + } + + public class Context : ScenarioContext + { + public bool StartReceived { get; set; } + public bool OutboundReceived { get; set; } + public bool EchoReceived { get; set; } + public bool MappedEchoReceived { get; set; } + } + + public class UnmappedMsgEndpoint : EndpointConfigurationBuilder + { + public UnmappedMsgEndpoint() + { + EndpointSetup(); + } + + public class UnmappedMsgSaga : Saga, + IAmStartedByMessages, + IHandleMessages, + IHandleMessages + { + public Context Context { get; set; } + + protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) + { + mapper.ConfigureMapping(msg => msg.SomeId).ToSaga(saga => saga.SomeId); + mapper.ConfigureMapping(msg => msg.SomeId).ToSaga(saga => saga.SomeId); + // No mapping for EchoMessage, so saga can't possibly be found + } + + public Task Handle(StartSagaMessage message, IMessageHandlerContext context) + { + Context.StartReceived = true; + return context.SendLocal(new OutboundMessage { SomeId = message.SomeId }); + } + + public Task Handle(MappedEchoMessage message, IMessageHandlerContext context) + { + Context.MappedEchoReceived = true; + return Task.FromResult(0); + } + + public Task Handle(EchoMessage message, IMessageHandlerContext context) + { + Context.EchoReceived = true; + return Task.FromResult(0); + } + } + + public class UnmappedMsgSagaData : ContainSagaData + { + public virtual Guid SomeId { get; set; } + } + + public class OutboundMessageHandler : IHandleMessages + { + public Context Context { get; set; } + + public async Task Handle(OutboundMessage message, IMessageHandlerContext context) + { + Context.OutboundReceived = true; + await context.SendLocal(new EchoMessage { SomeId = message.SomeId }); + await context.SendLocal(new MappedEchoMessage { SomeId = message.SomeId }); + } + } + } + + public class StartSagaMessage : ICommand + { + public Guid SomeId { get; set; } + } + + public class OutboundMessage : ICommand + { + public Guid SomeId { get; set; } + } + + public class EchoMessage : ICommand + { + public Guid SomeId { get; set; } + } + + public class MappedEchoMessage : ICommand + { + public Guid SomeId { get; set; } + } + } +} diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_saga_has_a_non_empty_constructor.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_has_a_non_empty_constructor.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_saga_has_a_non_empty_constructor.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_has_a_non_empty_constructor.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_saga_id_changed.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_id_changed.cs similarity index 94% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_saga_id_changed.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_id_changed.cs index 0ed7ec894..b72663b22 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_saga_id_changed.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_id_changed.cs @@ -27,7 +27,7 @@ await Scenario.Define() Assert.That(exception.FailedMessages, Has.Count.EqualTo(1)); var failedMessage = exception.FailedMessages.Single(); - Assert.That(((Context)exception.ScenarioContext).MessageId, Is.EqualTo(failedMessage.MessageId), "Message should be moved to errorqueue"); + Assert.That(((Context) exception.ScenarioContext).MessageId, Is.EqualTo(failedMessage.MessageId), "Message should be moved to errorqueue"); Assert.That(failedMessage.Exception.Message, Contains.Substring("A modification of IContainSagaData.Id has been detected. This property is for infrastructure purposes only and should not be modified. SagaType:")); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_saga_is_mapped_to_complex_expression.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_is_mapped_to_complex_expression.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_saga_is_mapped_to_complex_expression.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_saga_is_mapped_to_complex_expression.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_sagas_cant_be_found.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_sagas_cant_be_found.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_sagas_cant_be_found.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_sagas_cant_be_found.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_sending_from_a_saga_handle.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_sending_from_a_saga_handle.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_sending_from_a_saga_handle.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_sending_from_a_saga_handle.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_sending_from_a_saga_timeout.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_sending_from_a_saga_timeout.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_sending_from_a_saga_timeout.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_sending_from_a_saga_timeout.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_started_by_base_event_from_other_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_started_by_base_event_from_other_saga.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_started_by_base_event_from_other_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_started_by_base_event_from_other_saga.cs index 3d7d6f702..f571c7963 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_started_by_base_event_from_other_saga.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_started_by_base_event_from_other_saga.cs @@ -80,7 +80,7 @@ public Task Handle(BaseEvent message, IMessageHandlerContext context) protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) { - mapper.ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); + mapper.ConfigureMapping(m => m.DataId).ToSaga(s => s.DataId); } public class SagaStartedByBaseEventSagaData : ContainSagaData diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_started_by_event_from_another_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_started_by_event_from_another_saga.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_started_by_event_from_another_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_started_by_event_from_another_saga.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_timeout_hit_not_found_saga.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_timeout_hit_not_found_saga.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_timeout_hit_not_found_saga.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_timeout_hit_not_found_saga.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_two_sagas_subscribe_to_the_same_event.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_two_sagas_subscribe_to_the_same_event.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_two_sagas_subscribe_to_the_same_event.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_two_sagas_subscribe_to_the_same_event.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_updating_existing_correlation_property.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_updating_existing_correlation_property.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_updating_existing_correlation_property.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_updating_existing_correlation_property.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_using_ReplyToOriginator.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_using_ReplyToOriginator.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_using_ReplyToOriginator.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_using_ReplyToOriginator.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_using_a_received_message_for_timeout.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_using_a_received_message_for_timeout.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_using_a_received_message_for_timeout.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_using_a_received_message_for_timeout.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_using_contain_saga_data.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_using_contain_saga_data.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/When_using_contain_saga_data.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/When_using_contain_saga_data.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/when_receiving_multiple_timeouts.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/when_receiving_multiple_timeouts.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/when_receiving_multiple_timeouts.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/when_receiving_multiple_timeouts.cs index d0089a005..35d22a466 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/when_receiving_multiple_timeouts.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/when_receiving_multiple_timeouts.cs @@ -41,9 +41,9 @@ public Endpoint() { EndpointSetup(c => { - c.EnableFeature(); c.EnableFeature(); c.ExecuteTheseHandlersFirst(typeof(CatchAllMessageHandler)); + c.Recoverability().Immediate(immediate => immediate.NumberOfRetries(5)); }); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/when_reply_from_saga_not_found_handler.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/when_reply_from_saga_not_found_handler.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Sagas/when_reply_from_saga_not_found_handler.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Sagas/when_reply_from_saga_not_found_handler.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Satellites/When_a_message_is_available.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Satellites/When_a_message_is_available.cs new file mode 100644 index 000000000..4df8aaf0a --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Satellites/When_a_message_is_available.cs @@ -0,0 +1,67 @@ +namespace NServiceBus.AcceptanceTests.Satellites +{ + using System.Threading.Tasks; + using AcceptanceTesting; + using EndpointTemplates; + using Features; + using NUnit.Framework; + using Transport; + + public class When_a_message_is_available : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_receive_the_message() + { + var context = await Scenario.Define() + .WithEndpoint(b => b.When((session, c) => session.Send(Endpoint.MySatelliteFeature.Address, new MyMessage()))) + .Done(c => c.MessageReceived) + .Run(); + + Assert.True(context.MessageReceived); + } + + class Context : ScenarioContext + { + public bool MessageReceived { get; set; } + } + + class Endpoint : EndpointConfigurationBuilder + { + public Endpoint() + { + EndpointSetup(); + } + + public class MySatelliteFeature : Feature + { + public MySatelliteFeature() + { + EnableByDefault(); + } + + protected override void Setup(FeatureConfigurationContext context) + { + var instanceName = context.Settings.EndpointInstanceName(); + var satelliteLogicalAddress = new LogicalAddress(instanceName, "MySatellite"); + var satelliteAddress = context.Settings.GetTransportAddress(satelliteLogicalAddress); + + context.AddSatelliteReceiver("Test satellite", satelliteAddress, TransportTransactionMode.ReceiveOnly, PushRuntimeSettings.Default, + (c, ec) => RecoverabilityAction.MoveToError(c.Failed.ErrorQueue), + (builder, pushContext) => + { + builder.Build().MessageReceived = true; + return Task.FromResult(true); + }); + + Address = satelliteAddress; + } + + public static string Address; + } + } + + class MyMessage : IMessage + { + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/AllOutboxCapableStorages.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/AllOutboxCapableStorages.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/AllOutboxCapableStorages.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/AllOutboxCapableStorages.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/AllTransports.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/AllTransports.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/AllTransports.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/AllTransports.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/Builders.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/Builders.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/Builders.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/Builders.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/EnvironmentHelper.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/EnvironmentHelper.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/EnvironmentHelper.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/EnvironmentHelper.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/Persistence.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/Persistence.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/Persistence.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/Persistence.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/Serializers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/Serializers.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/Serializers.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/Serializers.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/Transports.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/Transports.cs similarity index 98% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/Transports.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/Transports.cs index 4da1ed6e5..9b8d83fcf 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/ScenarioDescriptors/Transports.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/ScenarioDescriptors/Transports.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using AcceptanceTesting.Support; - using NServiceBus.Transports; + using Transport; public static class Transports { diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Scheduling/When_scheduling_a_recurring_task.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Scheduling/When_scheduling_a_recurring_task.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Scheduling/When_scheduling_a_recurring_task.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Scheduling/When_scheduling_a_recurring_task.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/SelfVerification/When_running_saga_tests.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/SelfVerification/When_running_saga_tests.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/SelfVerification/When_running_saga_tests.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/SelfVerification/When_running_saga_tests.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_configuring_custom_xml_namespace.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_configuring_custom_xml_namespace.cs new file mode 100644 index 000000000..38069ce4e --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_configuring_custom_xml_namespace.cs @@ -0,0 +1,83 @@ +namespace NServiceBus.AcceptanceTests.Serialization +{ + using System.Text; + using System.Threading.Tasks; + using System.Xml.Linq; + using AcceptanceTesting; + using EndpointTemplates; + using MessageMutator; + using NUnit.Framework; + + public class When_configuring_custom_xml_namespace : NServiceBusAcceptanceTest + { + const string CustomXmlNamespace = "http://particular.net"; + + [Test] + public async Task Should_use_as_root_namespace_in_messages() + { + var context = await Scenario.Define() + .WithEndpoint(e => e + .When(session => session.SendLocal(new SimpleMessage()))) + .Done(c => c.MessageReceived) + .Run(); + + Assert.AreEqual($"{CustomXmlNamespace}/{typeof(SimpleMessage).Namespace}", context.MessageNamespace); + } + + class Context : ScenarioContext + { + public bool MessageReceived { get; set; } + public string MessageNamespace { get; set; } + } + + class EndpointUsingCustomNamespace : EndpointConfigurationBuilder + { + public EndpointUsingCustomNamespace() + { + EndpointSetup(c => + { + c.UseSerialization().Namespace(CustomXmlNamespace); + c.RegisterComponents(r => r.ConfigureComponent(DependencyLifecycle.SingleInstance)); + }); + } + + class SimpleMessageHandler : IHandleMessages + { + public SimpleMessageHandler(Context scenarioContext) + { + this.scenarioContext = scenarioContext; + } + + public Task Handle(SimpleMessage message, IMessageHandlerContext context) + { + scenarioContext.MessageReceived = true; + return Task.FromResult(0); + } + + Context scenarioContext; + } + + public class IncomingMutator : IMutateIncomingTransportMessages + { + public IncomingMutator(Context scenarioContext) + { + this.scenarioContext = scenarioContext; + } + + public Task MutateIncoming(MutateIncomingTransportMessageContext context) + { + var document = XDocument.Parse(Encoding.UTF8.GetString(context.Body)); + var defaultNamespace = document.Root?.GetDefaultNamespace(); + scenarioContext.MessageNamespace = defaultNamespace?.NamespaceName; + return Task.FromResult(0); + } + + Context scenarioContext; + } + } + + class SimpleMessage : ICommand + { + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_registering_additional_deserializers.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_registering_additional_deserializers.cs similarity index 64% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_registering_additional_deserializers.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_registering_additional_deserializers.cs index 1a0afcf29..346d4392a 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_registering_additional_deserializers.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_registering_additional_deserializers.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AcceptanceTests.Basic +namespace NServiceBus.AcceptanceTests.Serialization { using System; using System.Collections.Generic; @@ -6,10 +6,11 @@ using System.Runtime.Serialization.Formatters.Binary; using System.Threading.Tasks; using AcceptanceTesting; + using Configuration.AdvanceExtensibility; using EndpointTemplates; using MessageInterfaces; + using NServiceBus.Serialization; using NUnit.Framework; - using Serialization; using Settings; public class When_registering_additional_deserializers : NServiceBusAcceptanceTest @@ -29,17 +30,21 @@ public async Task Two_endpoints_with_different_serializers_should_deserialize_th .Done(c => c.DeserializeCalled) .Run(); + Assert.True(context.HandlerGotTheRequest); + Assert.True(context.SerializeCalled); Assert.True(context.DeserializeCalled); + Assert.AreEqual("SomeFancySettings", context.ValueFromSettings); } - public class Context : ScenarioContext + class Context : ScenarioContext { public bool HandlerGotTheRequest { get; set; } public bool SerializeCalled { get; set; } public bool DeserializeCalled { get; set; } + public string ValueFromSettings { get; set; } } - public class CustomSerializationSender : EndpointConfigurationBuilder + class CustomSerializationSender : EndpointConfigurationBuilder { public CustomSerializationSender() { @@ -48,18 +53,18 @@ public CustomSerializationSender() } } - public class XmlCustomSerializationReceiver : EndpointConfigurationBuilder + class XmlCustomSerializationReceiver : EndpointConfigurationBuilder { public XmlCustomSerializationReceiver() { EndpointSetup(c => { c.UseSerialization(); - c.AddDeserializer(); + c.AddDeserializer().Settings("SomeFancySettings"); }); } - public class MyRequestHandler : IHandleMessages + class MyRequestHandler : IHandleMessages { public Context Context { get; set; } @@ -68,33 +73,44 @@ public Task Handle(MyRequest request, IMessageHandlerContext context) Context.HandlerGotTheRequest = true; Context.DeserializeCalled = request.DeserializerCalled; Context.SerializeCalled = request.SerializerCalled; + Context.ValueFromSettings = request.ValueFromSettings; return Task.FromResult(0); } } } [Serializable] - public class MyRequest : IMessage + class MyRequest : IMessage { public bool DeserializerCalled { get; set; } public bool SerializerCalled { get; set; } + public string ValueFromSettings { get; set; } } - class MyCustomSerializer : SerializationDefinition + + public class MyCustomSerializer : SerializationDefinition { public override Func Configure(ReadOnlySettings settings) { - return mapper => new MyCustomMessageSerializer(); + return mapper => new MyCustomMessageSerializer(settings.GetOrDefault("MyCustomSerializer.Settings")); } } class MyCustomMessageSerializer : IMessageSerializer { + readonly string valueFromSettings; + + public MyCustomMessageSerializer(string valueFromSettings) + { + this.valueFromSettings = valueFromSettings; + } + public void Serialize(object message, Stream stream) { var serializer = new BinaryFormatter(); ((MyRequest) message).SerializerCalled = true; + ((MyRequest) message).ValueFromSettings = valueFromSettings; serializer.Serialize(stream, message); } @@ -106,6 +122,7 @@ public object[] Deserialize(Stream stream, IList messageTypes = null) stream.Position = 0; var msg = serializer.Deserialize(stream); ((MyRequest) msg).DeserializerCalled = true; + ((MyRequest)msg).ValueFromSettings = valueFromSettings; return new[] { msg @@ -115,4 +132,13 @@ public object[] Deserialize(Stream stream, IList messageTypes = null) public string ContentType => "MyCustomSerializer"; } } + + static class CustomSettingsForMyCustomSerializer + { + public static SerializationExtensions Settings(this SerializationExtensions extensions, string valueFromSettings) + { + extensions.GetSettings().Set("MyCustomSerializer.Settings", valueFromSettings); + return extensions; + } + } } \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_registering_custom_serializer.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_registering_custom_serializer.cs similarity index 97% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_registering_custom_serializer.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_registering_custom_serializer.cs index 65311c632..a040e50a4 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Basic/When_registering_custom_serializer.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_registering_custom_serializer.cs @@ -1,4 +1,4 @@ -namespace NServiceBus.AcceptanceTests.Basic +namespace NServiceBus.AcceptanceTests.Serialization { using System; using System.Collections.Generic; @@ -8,8 +8,8 @@ using AcceptanceTesting; using EndpointTemplates; using MessageInterfaces; + using NServiceBus.Serialization; using NUnit.Framework; - using Serialization; using Settings; public class When_registering_custom_serializer : NServiceBusAcceptanceTest diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_sanitizing_xml_messages.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_sanitizing_xml_messages.cs new file mode 100644 index 000000000..97c08837e --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_sanitizing_xml_messages.cs @@ -0,0 +1,88 @@ +namespace NServiceBus.AcceptanceTests.Serialization +{ + using System.Text; + using System.Threading.Tasks; + using AcceptanceTesting; + using EndpointTemplates; + using MessageMutator; + using NUnit.Framework; + + public class When_sanitizing_xml_messages : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_remove_illegal_characters_from_messages() + { + var context = await Scenario.Define() + .WithEndpoint(e => e + .When(session => session.SendLocal(new SimpleMessage + { + Value = "Hello World!" + }))) + .Done(c => c.MessageReceived) + .Run(); + + Assert.That(context.Input, Is.EqualTo("Hello World!")); + } + + class Context : ScenarioContext + { + public bool MessageReceived { get; set; } + public string Input { get; set; } + } + + class EndpointSanitizingInput : EndpointConfigurationBuilder + { + public EndpointSanitizingInput() + { + EndpointSetup(c => + { + c.UseSerialization().SanitizeInput(); + c.RegisterComponents(r => r.ConfigureComponent(DependencyLifecycle.SingleInstance)); + }); + } + + class SimpleMessageHandler : IHandleMessages + { + public SimpleMessageHandler(Context scenarioContext) + { + this.scenarioContext = scenarioContext; + } + + public Task Handle(SimpleMessage message, IMessageHandlerContext context) + { + scenarioContext.MessageReceived = true; + scenarioContext.Input = message.Value; + + return Task.FromResult(0); + } + + Context scenarioContext; + } + + public class IncomingMutator : IMutateIncomingTransportMessages + { + public IncomingMutator(Context scenarioContext) + { + this.scenarioContext = scenarioContext; + } + + public Task MutateIncoming(MutateIncomingTransportMessageContext context) + { + var body = Encoding.UTF8.GetString(context.Body); + var invalidChar = char.ConvertFromUtf32(0x8); + + context.Body = Encoding.UTF8.GetBytes(body.Replace("Hello World!", $"{invalidChar}Hello {invalidChar}World!{invalidChar}")); + + return Task.FromResult(0); + } + + Context scenarioContext; + } + } + + class SimpleMessage : ICommand + { + public string Value { get; set; } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_skip_wrapping_xml.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_skip_wrapping_xml.cs new file mode 100644 index 000000000..c3caaf781 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_skip_wrapping_xml.cs @@ -0,0 +1,92 @@ +namespace NServiceBus.AcceptanceTests.Serialization +{ + using System.Linq; + using System.Text; + using System.Threading.Tasks; + using System.Xml.Linq; + using AcceptanceTesting; + using EndpointTemplates; + using MessageMutator; + using NUnit.Framework; + + public class When_skip_wrapping_xml : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_not_wrap_xml_content() + { + XNamespace ns = "demoNamepsace"; + var xmlContent = new XDocument(new XElement(ns + "Document", new XElement(ns + "Value", "content"))); + + var context = await Scenario.Define() + .WithEndpoint(e => e + .When(session => session.SendLocal(new MessageWithRawXml { Document = xmlContent }))) + .Done(c => c.MessageReceived) + .Run(); + + Assert.That(context.XmlPropertyValue.ToString(), Is.EqualTo(xmlContent.ToString())); + Assert.That(context.XmlMessage.Root.Name.LocalName, Is.EqualTo(nameof(MessageWithRawXml))); + Assert.That(context.XmlMessage.Root.Elements().Single().ToString(), Is.EqualTo(xmlContent.ToString())); + } + + class Context : ScenarioContext + { + public bool MessageReceived { get; set; } + + public XDocument XmlMessage { get; set; } + + public XDocument XmlPropertyValue { get; set; } + } + + class NonWrappingEndpoint : EndpointConfigurationBuilder + { + public NonWrappingEndpoint() + { + EndpointSetup(c => + { + c.UseSerialization().DontWrapRawXml(); + c.RegisterComponents(r => r.ConfigureComponent(DependencyLifecycle.SingleInstance)); + }); + } + + class RawXmlMessageHandler : IHandleMessages + { + public RawXmlMessageHandler(Context scenarioContext) + { + this.scenarioContext = scenarioContext; + } + + public Task Handle(MessageWithRawXml messageWithRawXml, IMessageHandlerContext context) + { + scenarioContext.MessageReceived = true; + scenarioContext.XmlPropertyValue = messageWithRawXml.Document; + + return Task.FromResult(0); + } + + Context scenarioContext; + } + + public class IncomingMutator : IMutateIncomingTransportMessages + { + public IncomingMutator(Context scenarioContext) + { + this.scenarioContext = scenarioContext; + } + + public Task MutateIncoming(MutateIncomingTransportMessageContext context) + { + scenarioContext.XmlMessage = XDocument.Parse(Encoding.UTF8.GetString(context.Body)); + + return Task.FromResult(0); + } + + Context scenarioContext; + } + } + + class MessageWithRawXml : ICommand + { + public XDocument Document { get; set; } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_wrapping_is_not_skipped.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_wrapping_is_not_skipped.cs new file mode 100644 index 000000000..a87d67f85 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Serialization/When_wrapping_is_not_skipped.cs @@ -0,0 +1,94 @@ +namespace NServiceBus.AcceptanceTests.Serialization +{ + using System.Linq; + using System.Text; + using System.Threading.Tasks; + using System.Xml.Linq; + using AcceptanceTesting; + using EndpointTemplates; + using MessageMutator; + using NUnit.Framework; + + public class When_wrapping_is_not_skipped : NServiceBusAcceptanceTest + { + [Test] + public async Task Should_wrap_xml_content() + { + XNamespace ns = "demoNamepsace"; + var xmlContent = new XDocument(new XElement(ns + "Document", new XElement(ns + "Value", "content"))); + + var context = await Scenario.Define() + .WithEndpoint(e => e + .When(session => session.SendLocal(new MessageWithRawXml { Document = xmlContent }))) + .Done(c => c.MessageReceived) + .Run(); + + Assert.That(context.XmlPropertyValue.ToString(), Is.EqualTo(xmlContent.ToString())); + Assert.That(context.XmlMessage.Root.Name.LocalName, Is.EqualTo(nameof(MessageWithRawXml))); + Assert.That(context.XmlMessage.Root.Elements().Single().Name.LocalName, Is.EqualTo("Document")); + Assert.That(context.XmlMessage.Root.Elements().Single().Elements().Single().Name.LocalName, Is.EqualTo("Document")); + Assert.That(context.XmlMessage.Root.Elements().Single().Elements().Single().ToString(), Is.EqualTo(xmlContent.ToString())); + } + + class Context : ScenarioContext + { + public bool MessageReceived { get; set; } + + public XDocument XmlMessage { get; set; } + + public XDocument XmlPropertyValue { get; set; } + } + + class WrappingEndpoint : EndpointConfigurationBuilder + { + public WrappingEndpoint() + { + EndpointSetup(c => + { + c.UseSerialization(); // wrapping is enabled by default + c.RegisterComponents(r => r.ConfigureComponent(DependencyLifecycle.SingleInstance)); + }); + } + + class RawXmlMessageHandler : IHandleMessages + { + public RawXmlMessageHandler(Context scenarioContext) + { + this.scenarioContext = scenarioContext; + } + + public Task Handle(MessageWithRawXml messageWithRawXml, IMessageHandlerContext context) + { + scenarioContext.MessageReceived = true; + scenarioContext.XmlPropertyValue = messageWithRawXml.Document; + + return Task.FromResult(0); + } + + Context scenarioContext; + } + + public class IncomingMutator : IMutateIncomingTransportMessages + { + public IncomingMutator(Context scenarioContext) + { + this.scenarioContext = scenarioContext; + } + + public Task MutateIncoming(MutateIncomingTransportMessageContext context) + { + scenarioContext.XmlMessage = XDocument.Parse(Encoding.UTF8.GetString(context.Body)); + + return Task.FromResult(0); + } + + Context scenarioContext; + } + } + + class MessageWithRawXml : ICommand + { + public XDocument Document { get; set; } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Timeout/CyclingOutageTimeoutPersister.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Timeout/CyclingOutageTimeoutPersister.cs similarity index 97% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Timeout/CyclingOutageTimeoutPersister.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Timeout/CyclingOutageTimeoutPersister.cs index f1e8e6d7e..ee376a59c 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Timeout/CyclingOutageTimeoutPersister.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Timeout/CyclingOutageTimeoutPersister.cs @@ -71,7 +71,7 @@ public Task GetNextChunk(DateTime startSlice) } } - var chunk = new TimeoutsChunk(timeoutsDue, DateTime.Now.AddSeconds(5)); + var chunk = new TimeoutsChunk(timeoutsDue.ToArray(), DateTime.Now.AddSeconds(5)); return Task.FromResult(chunk); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Timeout/When_timeout_storage_is_unavailable_temporarily.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Timeout/When_timeout_storage_is_unavailable_temporarily.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Timeout/When_timeout_storage_is_unavailable_temporarily.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Timeout/When_timeout_storage_is_unavailable_temporarily.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/FakePromotableResourceManager.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/FakePromotableResourceManager.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/FakePromotableResourceManager.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/FakePromotableResourceManager.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_using_scope_suppress.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_using_scope_suppress.cs similarity index 93% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_using_scope_suppress.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_using_scope_suppress.cs index 046cdf52e..f7beccbc5 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_using_scope_suppress.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_using_scope_suppress.cs @@ -5,6 +5,7 @@ using System.Transactions; using AcceptanceTesting; using EndpointTemplates; + using Logging; using NUnit.Framework; using ScenarioDescriptors; @@ -23,7 +24,7 @@ public Task Should_dispatch_immediately() .Should(c => { Assert.True(c.MessageDispatched, "Should dispatch the message immediately"); - Assert.True(c.Logs.Any(l => l.Level == "warn" && l.Message.Contains("We detected that you suppressed the ambient transaction"))); + Assert.True(c.Logs.Any(l => l.Level == LogLevel.Warn && l.Message.Contains("We detected that you suppressed the ambient transaction"))); }) .Run(); } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_least_once.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_least_once.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_least_once.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_least_once.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_most_once.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_most_once.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_most_once.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_at_most_once.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_exactly_once.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_exactly_once.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_exactly_once.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/ImmediateDispatch/When_requesting_immediate_dispatch_with_exactly_once.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/Issue_2481.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/Issue_2481.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/Issue_2481.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/Issue_2481.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/When_receiving_with_dtc_enabled.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/When_receiving_with_dtc_enabled.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/When_receiving_with_dtc_enabled.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/When_receiving_with_dtc_enabled.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/When_receiving_with_native_multi_queue_transaction.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/When_receiving_with_native_multi_queue_transaction.cs similarity index 96% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/When_receiving_with_native_multi_queue_transaction.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/When_receiving_with_native_multi_queue_transaction.cs index 18206b5ab..c5d752b4a 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/When_receiving_with_native_multi_queue_transaction.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/When_receiving_with_native_multi_queue_transaction.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; - using Features; using NUnit.Framework; using ScenarioDescriptors; @@ -38,7 +37,7 @@ public Endpoint() { EndpointSetup((config, context) => { - config.EnableFeature(); + config.Recoverability().Immediate(immediate => immediate.NumberOfRetries(1)); config.UseTransport(context.GetTransportType()) .Transactions(TransportTransactionMode.ReceiveOnly); }); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/When_receiving_with_the_default_settings.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/When_receiving_with_the_default_settings.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/When_receiving_with_the_default_settings.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/When_receiving_with_the_default_settings.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/When_sending_within_an_ambient_transaction.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/When_sending_within_an_ambient_transaction.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Tx/When_sending_within_an_ambient_transaction.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Tx/When_sending_within_an_ambient_transaction.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/UnicastPubSubExtensions.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/UnicastPubSubExtensions.cs new file mode 100644 index 000000000..5d6a262c0 --- /dev/null +++ b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/UnicastPubSubExtensions.cs @@ -0,0 +1,14 @@ +namespace NServiceBus.AcceptanceTests.Routing +{ + using System; + using Configuration.AdvanceExtensibility; + using NServiceBus.Routing.MessageDrivenSubscriptions; + + static class UnicastPubSubExtensions + { + public static void RegisterPublisherForType(this EndpointConfiguration config, Type eventType, string publisherEndpoint) + { + config.GetSettings().GetOrCreate().Add(eventType, publisherEndpoint); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Versioning/When_multiple_versions_of_a_message_is_published.cs b/src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Versioning/When_multiple_versions_of_a_message_is_published.cs similarity index 100% rename from src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0003/Versioning/When_multiple_versions_of_a_message_is_published.cs rename to src/NServiceBus.SqlServer.AcceptanceTests/App_Packages/NSB.AcceptanceTests.6.0.0-beta0006/Versioning/When_multiple_versions_of_a_message_is_published.cs diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/ConfigureEndpointSqlServerTransport.cs b/src/NServiceBus.SqlServer.AcceptanceTests/ConfigureEndpointSqlServerTransport.cs index 502ce26be..b988bd543 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/ConfigureEndpointSqlServerTransport.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/ConfigureEndpointSqlServerTransport.cs @@ -7,7 +7,7 @@ using NServiceBus.AcceptanceTesting.Support; using NServiceBus.AcceptanceTests.ScenarioDescriptors; using NServiceBus.Configuration.AdvanceExtensibility; -using NServiceBus.Transports; +using NServiceBus.Transport; public class ConfigureScenariosForSqlServerTransport : IConfigureSupportedScenariosForTestExecution { @@ -35,7 +35,7 @@ public Task Cleanup() { conn.Open(); - var qn = queueBindings.ReceivingAddresses.ToList().ToList(); + var qn = queueBindings.ReceivingAddresses.ToList(); qn.ForEach(n => { var nameParts = n.Split('@'); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_bracketed_transport_discriminator.cs b/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_bracketed_transport_discriminator.cs index 2c41a72ea..6fa9b2832 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_bracketed_transport_discriminator.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_bracketed_transport_discriminator.cs @@ -2,9 +2,12 @@ { using System.Threading.Tasks; using AcceptanceTesting; + using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NServiceBus.AcceptanceTests.ScenarioDescriptors; + using NServiceBus.Configuration.AdvanceExtensibility; using NUnit.Framework; + using Routing; using static AcceptanceTesting.Customization.Conventions; public class When_custom_schema_configured_with_bracketed_transport_discriminator : When_custom_schema_configured @@ -25,11 +28,11 @@ public class Sender : EndpointConfigurationBuilder { public Sender() { - EndpointSetup(c => + EndpointSetup((c,r) => { var ReceiverName = $"{EndpointNamingConvention(typeof(Receiver))}"; - c.UnicastRouting().RouteToEndpoint(typeof(Message), $"{ReceiverName}@[{ReceiverSchema}]"); + c.UseTransport(r.GetTransportType()).GetSettings().GetOrCreate().RouteToAddress(typeof(Message), $"{ReceiverName}@[{ReceiverSchema}]"); }); } } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_message_mappings.cs b/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_message_mappings.cs index ab4428ee2..8dceeaf05 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_message_mappings.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_message_mappings.cs @@ -2,9 +2,12 @@ { using System.Threading.Tasks; using AcceptanceTesting; + using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NServiceBus.AcceptanceTests.ScenarioDescriptors; + using NServiceBus.Configuration.AdvanceExtensibility; using NUnit.Framework; + using Routing; using static AcceptanceTesting.Customization.Conventions; public class When_custom_schema_configured_with_message_mappings : When_custom_schema_configured @@ -25,7 +28,10 @@ public class Sender : EndpointConfigurationBuilder { public Sender() { - EndpointSetup(c => { c.UnicastRouting().RouteToEndpoint(typeof(Message), $"{EndpointNamingConvention(typeof(Receiver))}@{ReceiverSchema}"); }); + EndpointSetup((c, r) => + { + c.UseTransport(r.GetTransportType()).GetSettings().GetOrCreate().RouteToAddress(typeof(Message), $"{EndpointNamingConvention(typeof(Receiver))}@{ReceiverSchema}"); + }); } } } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_transport_discriminator.cs b/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_transport_discriminator.cs index adeecd6e6..bedabaebb 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_transport_discriminator.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/MultiSchema/When_custom_schema_configured_with_transport_discriminator.cs @@ -2,9 +2,12 @@ { using System.Threading.Tasks; using AcceptanceTesting; + using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NServiceBus.AcceptanceTests.ScenarioDescriptors; + using NServiceBus.Configuration.AdvanceExtensibility; using NUnit.Framework; + using Routing; using static AcceptanceTesting.Customization.Conventions; public class When_custom_schema_configured_with_transport_discriminator : When_custom_schema_configured @@ -25,11 +28,11 @@ public class Sender : EndpointConfigurationBuilder { public Sender() { - EndpointSetup(c => + EndpointSetup((c, r) => { var ReceiverName = $"{EndpointNamingConvention(typeof(Receiver))}"; - c.UnicastRouting().RouteToEndpoint(typeof(Message), $"{ReceiverName}@{ReceiverSchema}"); + c.UseTransport(r.GetTransportType()).GetSettings().GetOrCreate().RouteToAddress(typeof(Message), $"{ReceiverName}@{ReceiverSchema}"); }); } } diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj b/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj index d8a07078a..0d11a043f 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj +++ b/src/NServiceBus.SqlServer.AcceptanceTests/NServiceBus.SqlServer.AcceptanceTests.csproj @@ -44,15 +44,15 @@ - ..\packages\NServiceBus.AcceptanceTesting.6.0.0-beta0003\lib\net452\NServiceBus.AcceptanceTesting.dll + ..\packages\NServiceBus.AcceptanceTesting.6.0.0-beta0006\lib\net452\NServiceBus.AcceptanceTesting.dll True - ..\packages\NServiceBus.6.0.0-beta0003\lib\net452\NServiceBus.Core.dll + ..\packages\NServiceBus.6.0.0-beta0006\lib\net452\NServiceBus.Core.dll True - - ..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll True @@ -64,6 +64,7 @@ + @@ -71,213 +72,222 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/TimeToBeReceived/When_queue_contains_expired_messages.cs b/src/NServiceBus.SqlServer.AcceptanceTests/TimeToBeReceived/When_queue_contains_expired_messages.cs index e7b0d91be..eceb420b8 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/TimeToBeReceived/When_queue_contains_expired_messages.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/TimeToBeReceived/When_queue_contains_expired_messages.cs @@ -1,11 +1,13 @@ namespace NServiceBus.SqlServer.AcceptanceTests.TimeToBeReceived { + using System; using System.Data.SqlClient; using System.Threading.Tasks; using AcceptanceTesting; using AcceptanceTesting.Customization; using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; + using NServiceBus.Configuration.AdvanceExtensibility; using NUnit.Framework; public class When_queue_contains_expired_messages : NServiceBusAcceptanceTest @@ -59,7 +61,13 @@ class Endpoint : EndpointConfigurationBuilder { public Endpoint() { - EndpointSetup(c => c.LimitMessageProcessingConcurrencyTo(1)); + EndpointSetup(c => + { + // Make sure the purger is fired often enough to clean expired messages from + // the queue before the test times out. + c.GetSettings().Set("SqlServer.PurgeTaskDelayTimeSpan", TimeSpan.FromSeconds(2)); + c.LimitMessageProcessingConcurrencyTo(1); + }); } class Handler : IHandleMessages diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/When_a_corrupted_message_is_received.cs b/src/NServiceBus.SqlServer.AcceptanceTests/When_a_corrupted_message_is_received.cs index 6520e7e59..642a99eac 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/When_a_corrupted_message_is_received.cs +++ b/src/NServiceBus.SqlServer.AcceptanceTests/When_a_corrupted_message_is_received.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using AcceptanceTesting; using AcceptanceTesting.Customization; + using Logging; using NServiceBus.AcceptanceTests; using NServiceBus.AcceptanceTests.EndpointTemplates; using NUnit.Framework; @@ -57,7 +58,7 @@ await Scenario.Define() } }); }) - .Done(c => c.Logs.Any(l => l.Level == "error")) + .Done(c => c.Logs.Any(l => l.Level == LogLevel.Error)) .Run(); Assert.True(MessageExistsInErrorQueue(), "The message should have been moved to the error queue"); @@ -121,7 +122,7 @@ await Scenario.Define() } }); }) - .Done(c => c.Logs.Any(l => l.Level == "error")) + .Done(c => c.Logs.Any(l => l.Level == LogLevel.Error)) .Run(); Assert.True(MessageExistsInErrorQueue(), "The message should have been moved to the error queue"); diff --git a/src/NServiceBus.SqlServer.AcceptanceTests/packages.config b/src/NServiceBus.SqlServer.AcceptanceTests/packages.config index c72d49ea1..ffb1d6956 100644 --- a/src/NServiceBus.SqlServer.AcceptanceTests/packages.config +++ b/src/NServiceBus.SqlServer.AcceptanceTests/packages.config @@ -1,8 +1,8 @@  - - - - + + + + \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.IntegrationTests/NServiceBus.SqlServer.IntegrationTests.csproj b/src/NServiceBus.SqlServer.IntegrationTests/NServiceBus.SqlServer.IntegrationTests.csproj index 5ffb6d0f6..60358ff06 100644 --- a/src/NServiceBus.SqlServer.IntegrationTests/NServiceBus.SqlServer.IntegrationTests.csproj +++ b/src/NServiceBus.SqlServer.IntegrationTests/NServiceBus.SqlServer.IntegrationTests.csproj @@ -49,15 +49,15 @@ True - ..\packages\NServiceBus.6.0.0-beta0003\lib\net452\NServiceBus.Core.dll + ..\packages\NServiceBus.6.0.0-beta0006\lib\net452\NServiceBus.Core.dll True - ..\packages\NServiceBus.NHibernate.7.0.0-beta0001\lib\net452\NServiceBus.NHibernate.dll + ..\packages\NServiceBus.NHibernate.7.0.0-beta0005\lib\net452\NServiceBus.NHibernate.dll True - - ..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll True diff --git a/src/NServiceBus.SqlServer.IntegrationTests/When_dispatching_messages.cs b/src/NServiceBus.SqlServer.IntegrationTests/When_dispatching_messages.cs index 0a4acdf74..042588f1f 100644 --- a/src/NServiceBus.SqlServer.IntegrationTests/When_dispatching_messages.cs +++ b/src/NServiceBus.SqlServer.IntegrationTests/When_dispatching_messages.cs @@ -1,5 +1,6 @@ // ReSharper disable RedundantArgumentNameForLiteralExpression // ReSharper disable RedundantArgumentName + namespace NServiceBus.SqlServer.AcceptanceTests.TransportTransaction { using System; @@ -9,19 +10,12 @@ namespace NServiceBus.SqlServer.AcceptanceTests.TransportTransaction using Extensibility; using NUnit.Framework; using Routing; - using Transports; + using Transport; using Transport.SQLServer; using Unicast.Queuing; public class When_dispatching_messages { - const string validAddress = "TableBasedQueueDispatcherTests"; - const string invalidAddress = "TableBasedQueueDispatcherTests.Invalid"; - - QueuePurger purger; - MessageDispatcher dispatcher; - TableBasedQueue queue; - [TestCase(typeof(SendOnlyContextProvider), DispatchConsistency.Default)] [TestCase(typeof(HandlerContextProvider), DispatchConsistency.Default)] [TestCase(typeof(SendOnlyContextProvider), DispatchConsistency.Isolated)] @@ -35,7 +29,7 @@ public async Task Outgoing_operations_are_stored_in_destination_queue(Type conte CreateTransportOperation(id: "2", destination: validAddress, consistency: dispatchConsistency) ); - await dispatcher.Dispatch(operations, contextProvider.Context); + await dispatcher.Dispatch(operations, contextProvider.TransportTransaction, contextProvider.Context); contextProvider.Complete(); @@ -54,13 +48,13 @@ public async Task Outgoing_operations_are_stored_atomically(Type contextProvider using (var contextProvider = CreateContext(contextProviderType)) { var invalidOperations = new TransportOperations( - CreateTransportOperation(id: "3", destination: validAddress, consistency: dispatchConsistency), - CreateTransportOperation(id: "4", destination: invalidAddress, consistency: dispatchConsistency) - ); + CreateTransportOperation(id: "3", destination: validAddress, consistency: dispatchConsistency), + CreateTransportOperation(id: "4", destination: invalidAddress, consistency: dispatchConsistency) + ); Assert.ThrowsAsync(Is.AssignableTo(), async () => { - await dispatcher.Dispatch(invalidOperations, contextProvider.Context); + await dispatcher.Dispatch(invalidOperations, contextProvider.TransportTransaction, contextProvider.Context); contextProvider.Complete(); }); } @@ -74,11 +68,9 @@ public async Task Outgoing_operations_are_stored_atomically(Type contextProvider public void Proper_exception_is_thrown_if_queue_does_not_exist() { var operation = new TransportOperation(new OutgoingMessage("1", new Dictionary(), new byte[0]), new UnicastAddressTag("InvalidQueue")); - Assert.That(async () => await dispatcher.Dispatch(new TransportOperations(operation), new ContextBag()), Throws.TypeOf()); + Assert.That(async () => await dispatcher.Dispatch(new TransportOperations(operation), new TransportTransaction(), new ContextBag()), Throws.TypeOf()); } - static SqlConnectionFactory sqlConnectionFactory = SqlConnectionFactory.Default(@"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True"); - static TransportOperation CreateTransportOperation(string id, string destination, DispatchConsistency consistency) { return new TransportOperation( @@ -128,9 +120,18 @@ static Task CreateOutputQueueIfNecessary(QueueAddressParser addressParser) return queueCreator.CreateQueueIfNecessary(queueBindings, ""); } + QueuePurger purger; + MessageDispatcher dispatcher; + TableBasedQueue queue; + const string validAddress = "TableBasedQueueDispatcherTests"; + const string invalidAddress = "TableBasedQueueDispatcherTests.Invalid"; + + static SqlConnectionFactory sqlConnectionFactory = SqlConnectionFactory.Default(@"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True"); + interface IContextProvider : IDisposable { ContextBag Context { get; } + TransportTransaction TransportTransaction { get; } void Complete(); } @@ -141,6 +142,7 @@ public virtual void Dispose() } public ContextBag Context { get; } = new ContextBag(); + public TransportTransaction TransportTransaction { get; } = new TransportTransaction(); public virtual void Complete() { @@ -149,19 +151,15 @@ public virtual void Complete() class HandlerContextProvider : SendOnlyContextProvider { - SqlTransaction sqlTransaction; - SqlConnection sqlConnection; - public HandlerContextProvider() { - var transportTransaction = new TransportTransaction(); sqlConnection = sqlConnectionFactory.OpenNewConnection().GetAwaiter().GetResult(); sqlTransaction = sqlConnection.BeginTransaction(); - transportTransaction.Set(sqlConnection); - transportTransaction.Set(sqlTransaction); + TransportTransaction.Set(sqlConnection); + TransportTransaction.Set(sqlTransaction); - Context.Set(transportTransaction); + Context.Set(TransportTransaction); } public override void Dispose() @@ -174,6 +172,9 @@ public override void Complete() { sqlTransaction.Commit(); } + + SqlTransaction sqlTransaction; + SqlConnection sqlConnection; } } } \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.IntegrationTests/When_message_receive_takes_long.cs b/src/NServiceBus.SqlServer.IntegrationTests/When_message_receive_takes_long.cs index 3760dea43..2ff82d3ce 100644 --- a/src/NServiceBus.SqlServer.IntegrationTests/When_message_receive_takes_long.cs +++ b/src/NServiceBus.SqlServer.IntegrationTests/When_message_receive_takes_long.cs @@ -8,7 +8,7 @@ using System.Transactions; using NUnit.Framework; using Transport.SQLServer; - using Transports; + using Transport; public class When_message_receive_takes_long { diff --git a/src/NServiceBus.SqlServer.IntegrationTests/When_receiving_messages.cs b/src/NServiceBus.SqlServer.IntegrationTests/When_receiving_messages.cs index 6fa96451f..06767a9cd 100644 --- a/src/NServiceBus.SqlServer.IntegrationTests/When_receiving_messages.cs +++ b/src/NServiceBus.SqlServer.IntegrationTests/When_receiving_messages.cs @@ -7,7 +7,7 @@ using System.Threading; using System.Threading.Tasks; using NUnit.Framework; - using Transports; + using Transport; using Transport.SQLServer; public class When_receiving_messages @@ -31,6 +31,7 @@ public async Task Should_stop_pumping_messages_after_first_unsuccessful_receive( await pump.Init( _ => Task.FromResult(0), + _ => Task.FromResult(ErrorHandleResult.Handled), new CriticalError(_ => Task.FromResult(0)), new PushSettings("input", "error", false, TransportTransactionMode.None)); diff --git a/src/NServiceBus.SqlServer.IntegrationTests/When_using_transaction_scope.cs b/src/NServiceBus.SqlServer.IntegrationTests/When_using_transaction_scope.cs index 5d8f56c43..a36bcbb60 100644 --- a/src/NServiceBus.SqlServer.IntegrationTests/When_using_transaction_scope.cs +++ b/src/NServiceBus.SqlServer.IntegrationTests/When_using_transaction_scope.cs @@ -17,7 +17,7 @@ public void SetUp() configuration.PurgeOnStartup(true); configuration.LimitMessageProcessingConcurrencyTo(1); configuration.EnableInstallers(); - configuration.ScaleOut().InstanceDiscriminator("1"); + configuration.MakeInstanceUniquelyAddressable("1"); configuration.UseTransport() .Transactions(TransportTransactionMode.TransactionScope) @@ -122,7 +122,6 @@ public class Registration : RegisterStep { public Registration() : base("BehaviorThatThrowsAfterFirstMessage", typeof(BehaviorThatThrowsAfterFirstMessage), "BehaviorThatThrowsAfterFirstMessage") { - InsertAfter("FirstLevelRetries"); } } } diff --git a/src/NServiceBus.SqlServer.IntegrationTests/packages.config b/src/NServiceBus.SqlServer.IntegrationTests/packages.config index d624945ce..2f56876d3 100644 --- a/src/NServiceBus.SqlServer.IntegrationTests/packages.config +++ b/src/NServiceBus.SqlServer.IntegrationTests/packages.config @@ -2,7 +2,7 @@ - - - + + + \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/IConfigureTransportInfrastructure.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/IConfigureTransportInfrastructure.cs new file mode 100644 index 000000000..283bc9124 --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/IConfigureTransportInfrastructure.cs @@ -0,0 +1,27 @@ +namespace NServiceBus.TransportTests +{ + using System.Threading.Tasks; + using Settings; + + /// + /// Provide a mechanism in components tests for transports + /// to configure a transport infrastructure for a test and then clean up afterwards. + /// + public interface IConfigureTransportInfrastructure + { + /// + /// Gives the transport a chance to configure before the test starts. + /// + /// The settings to be passed into the infrastructure. + /// Transaction mode for which transport seam should be configured. + /// Transport configuration result + TransportConfigurationResult Configure(SettingsHolder settings, TransportTransactionMode transactionMode); + + /// + /// Gives the transport chance to clean up after the test is complete. Implementations of this class may store + /// private variables during Configure to use during the cleanup phase. + /// + /// An async Task. + Task Cleanup(); + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/NServiceBusTransportTest.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/NServiceBusTransportTest.cs new file mode 100644 index 000000000..51feada78 --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/NServiceBusTransportTest.cs @@ -0,0 +1,241 @@ +namespace NServiceBus.TransportTests +{ + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.Linq; + using System.Security.Principal; + using System.Threading; + using System.Threading.Tasks; + using Extensibility; + using NUnit.Framework; + using Routing; + using Settings; + using Transport; + + public abstract class NServiceBusTransportTest + { + public static string SpecificTransport + { + get + { + var specificTransport = EnvironmentHelper.GetEnvironmentVariable("Transport.UseSpecific"); + + return !string.IsNullOrEmpty(specificTransport) ? specificTransport : MsmqDescriptorKey; + } + } + + [SetUp] + public void SetUp() + { + testId = Guid.NewGuid().ToString(); + } + + static IConfigureTransportInfrastructure CreateConfigurer() + { + var typeName = "Configure" + SpecificTransport + "Infrastructure"; + + var configurerType = Type.GetType(typeName, false); + + if (configurerType == null) + { + throw new InvalidOperationException($"Transport Test project must include a non-namespaced class named '{typeName}' implementing {typeof(IConfigureTransportInfrastructure).Name}."); + } + + var configurer = Activator.CreateInstance(configurerType) as IConfigureTransportInfrastructure; + + if (configurer == null) + { + throw new InvalidOperationException($"{typeName} does not implement {typeof(IConfigureTransportInfrastructure).Name}."); + } + return configurer; + } + + [TearDown] + public void TearDown() + { + testCancellationTokenSource?.Dispose(); + MessagePump?.Stop().GetAwaiter().GetResult(); + Configurer?.Cleanup().GetAwaiter().GetResult(); + + transportSettings.Clear(); + } + + protected async Task StartPump(Func onMessage, Func> onError, TransportTransactionMode transactionMode, Action onCriticalError = null) + { + InputQueueName = GetTestName() + transactionMode; + ErrorQueueName = $"{InputQueueName}.error"; + + transportSettings.Set("NServiceBus.Routing.EndpointName", InputQueueName); + + var queueBindings = new QueueBindings(); + queueBindings.BindReceiving(InputQueueName); + queueBindings.BindSending(ErrorQueueName); + transportSettings.Set(queueBindings); + + Configurer = CreateConfigurer(); + + var configuration = Configurer.Configure(transportSettings, transactionMode); + + TransportInfrastructure = configuration.TransportInfrastructure; + + IgnoreUnsupportedTransactionModes(transactionMode); + + ReceiveInfrastructure = TransportInfrastructure.ConfigureReceiveInfrastructure(); + SendInfrastructure = TransportInfrastructure.ConfigureSendInfrastructure(); + + lazyDispatcher = new Lazy(() => SendInfrastructure.DispatcherFactory()); + + MessagePump = ReceiveInfrastructure.MessagePumpFactory(); + + var queueCreator = ReceiveInfrastructure.QueueCreatorFactory(); + await queueCreator.CreateQueueIfNecessary(queueBindings, WindowsIdentity.GetCurrent().Name); + + var pushSettings = new PushSettings(InputQueueName, ErrorQueueName, configuration.PurgeInputQueueOnStartup, transactionMode); + await MessagePump.Init( + context => + { + if (context.Headers.ContainsKey(TestIdHeaderName) && + context.Headers[TestIdHeaderName] == testId) + { + return onMessage(context); + } + + return Task.FromResult(0); + }, + context => + { + if (context.Message.Headers.ContainsKey(TestIdHeaderName) && + context.Message.Headers[TestIdHeaderName] == testId) + { + return onError(context); + } + + return Task.FromResult(ErrorHandleResult.Handled); + }, + new FakeCriticalError(onCriticalError), + pushSettings); + + MessagePump.Start(PushRuntimeSettings.Default); + } + + void IgnoreUnsupportedTransactionModes(TransportTransactionMode requestedTransactionMode) + { + if (TransportInfrastructure.TransactionMode < requestedTransactionMode) + { + Assert.Ignore($"Only relevant for transports supporting {requestedTransactionMode} or higher"); + } + } + + protected Task SendMessage(string address, Dictionary headers = null, TransportTransaction transportTransaction = null) + { + var messageId = Guid.NewGuid().ToString(); + var message = new OutgoingMessage(messageId, headers ?? new Dictionary(), new byte[0]); + + if (message.Headers.ContainsKey(TestIdHeaderName) == false) + { + message.Headers.Add(TestIdHeaderName, testId); + } + + var dispatcher = lazyDispatcher.Value; + + if (transportTransaction == null) + { + transportTransaction = new TransportTransaction(); + } + + return dispatcher.Dispatch(new TransportOperations(new TransportOperation(message, new UnicastAddressTag(address))), transportTransaction, new ContextBag()); + } + + protected void OnTestTimeout(Action onTimeoutAction) + { + testCancellationTokenSource = new CancellationTokenSource(); + + testCancellationTokenSource.CancelAfter(TimeSpan.FromSeconds(10)); + testCancellationTokenSource.Token.Register(onTimeoutAction); + } + + protected virtual TransportInfrastructure CreateTransportInfrastructure() + { + var msmqTransportDefinition = new MsmqTransport(); + return msmqTransportDefinition.Initialize(new SettingsHolder(), ""); + } + + static string GetTestName() + { + var index = 1; + var frame = new StackFrame(index); + Type type; + + while (true) + { + type = frame.GetMethod().DeclaringType; + if (type != null && !type.IsAbstract && typeof(NServiceBusTransportTest).IsAssignableFrom(type)) + { + break; + } + + frame = new StackFrame(++index); + } + + var classCallingUs = type.FullName.Split('.').Last(); + + var testName = classCallingUs.Split('+').First(); + + testName = testName.Replace("When_", ""); + + testName = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(testName); + + testName = testName.Replace("_", ""); + + return testName; + } + + protected string InputQueueName; + protected string ErrorQueueName; + + string testId; + + SettingsHolder transportSettings = new SettingsHolder(); + Lazy lazyDispatcher; + TransportReceiveInfrastructure ReceiveInfrastructure; + TransportSendInfrastructure SendInfrastructure; + TransportInfrastructure TransportInfrastructure; + IPushMessages MessagePump; + CancellationTokenSource testCancellationTokenSource; + IConfigureTransportInfrastructure Configurer; + + static string MsmqDescriptorKey = "MsmqTransport"; + static string TestIdHeaderName = "TransportTest.TestId"; + + class FakeCriticalError : CriticalError + { + public FakeCriticalError(Action errorAction) : base(null) + { + this.errorAction = errorAction ?? ((s, e) => { }); + } + + public override void Raise(string errorMessage, Exception exception) + { + errorAction(errorMessage, exception); + } + + Action errorAction; + } + + class EnvironmentHelper + { + public static string GetEnvironmentVariable(string variable) + { + var candidate = Environment.GetEnvironmentVariable(variable, EnvironmentVariableTarget.User); + + if (string.IsNullOrWhiteSpace(candidate)) + { + return Environment.GetEnvironmentVariable(variable); + } + + return candidate; + } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/TransportConfigurationResult.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/TransportConfigurationResult.cs new file mode 100644 index 000000000..09640f95c --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/TransportConfigurationResult.cs @@ -0,0 +1,30 @@ +namespace NServiceBus.TransportTests +{ + using Transport; + + /// + /// Transport configuration result returned by . + /// + public class TransportConfigurationResult + { + + /// + /// Transport infrastructure. + /// + public TransportInfrastructure TransportInfrastructure { get; set; } + + /// + /// Flag representing if input queue should be purged before running any test. + /// + public bool PurgeInputQueueOnStartup { get; set; } + + + /// + /// Creates . + /// + public TransportConfigurationResult() + { + PurgeInputQueueOnStartup = true; + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_failure_happens_after_send.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_failure_happens_after_send.cs new file mode 100644 index 000000000..f9410496b --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_failure_happens_after_send.cs @@ -0,0 +1,52 @@ +namespace NServiceBus.TransportTests +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using NUnit.Framework; + using Transport; + + public class When_failure_happens_after_send : NServiceBusTransportTest + { + //[TestCase(TransportTransactionMode.None)] - not relevant + //[TestCase(TransportTransactionMode.ReceiveOnly)] - not relevant + [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] + [TestCase(TransportTransactionMode.TransactionScope)] + public async Task Should_not_emit_messages(TransportTransactionMode transactionMode) + { + var onMessageCalled = new TaskCompletionSource(); + + OnTestTimeout(() => onMessageCalled.SetCanceled()); + + await StartPump(async context => + { + if (context.Headers.ContainsKey("CompleteTest")) + { + onMessageCalled.SetResult(true); + return; + } + + if (context.Headers.ContainsKey("EnlistedSend")) + { + onMessageCalled.SetResult(false); + return; + } + + await SendMessage(InputQueueName, new Dictionary { { "EnlistedSend", "true" } }, context.TransportTransaction); + + throw new Exception("Simulated exception"); + + }, + async context => + { + await SendMessage(InputQueueName, new Dictionary { { "CompleteTest", "true" } }, context.TransportTransaction); + + return ErrorHandleResult.Handled; + }, transactionMode); + + await SendMessage(InputQueueName, new Dictionary { { "MyHeader", "MyValue" } }); + + Assert.True(await onMessageCalled.Task, "Should not emit enlisted sends"); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_message_is_available.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_message_is_available.cs new file mode 100644 index 000000000..1e0056ca6 --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_message_is_available.cs @@ -0,0 +1,43 @@ +namespace NServiceBus.TransportTests +{ + using System.Collections.Generic; + using System.Text; + using System.Threading.Tasks; + using NUnit.Framework; + using Transport; + + public class When_message_is_available : NServiceBusTransportTest + { + [TestCase(TransportTransactionMode.None)] + [TestCase(TransportTransactionMode.ReceiveOnly)] + [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] + [TestCase(TransportTransactionMode.TransactionScope)] + public async Task Should_invoke_on_message(TransportTransactionMode transactionMode) + { + var onMessageCalled = new TaskCompletionSource(); + + OnTestTimeout(() => onMessageCalled.SetCanceled()); + + await StartPump(context => + { + var body = Encoding.UTF8.GetString(context.Body); + + Assert.AreEqual("", body, "Should pass the body"); + + onMessageCalled.SetResult(context); + return Task.FromResult(0); + }, + context => Task.FromResult(ErrorHandleResult.Handled), transactionMode); + + await SendMessage(InputQueueName, new Dictionary + { + {"MyHeader", "MyValue"} + }); + + var messageContext = await onMessageCalled.Task; + + Assert.False(string.IsNullOrEmpty(messageContext.MessageId), "Should pass the native message id"); + Assert.AreEqual("MyValue", messageContext.Headers["MyHeader"], "Should pass the message headers"); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_error_throws.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_error_throws.cs new file mode 100644 index 000000000..33b9547bf --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_error_throws.cs @@ -0,0 +1,48 @@ +namespace NServiceBus.TransportTests +{ + using System; + using System.Threading.Tasks; + using NUnit.Framework; + using Transport; + + public class When_on_error_throws : NServiceBusTransportTest + { + // [TestCase(TransportTransactionMode.None)] -- not relevant + [TestCase(TransportTransactionMode.ReceiveOnly)] + [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] + [TestCase(TransportTransactionMode.TransactionScope)] + public async Task Should_reinvoke_on_error_with_orignal_exception(TransportTransactionMode transactionMode) + { + var onErrorCalled = new TaskCompletionSource(); + + OnTestTimeout(() => onErrorCalled.SetCanceled()); + + var firstInvocation = true; + + await StartPump( + context => + { + throw new Exception("Simulated exception"); + }, + context => + { + if (firstInvocation) + { + firstInvocation = false; + + throw new Exception("Exception from onError"); + } + + onErrorCalled.SetResult(context); + + return Task.FromResult(ErrorHandleResult.Handled); + }, transactionMode); + + await SendMessage(InputQueueName); + + var errorContext = await onErrorCalled.Task; + + Assert.AreEqual(errorContext.Exception.Message, "Simulated exception"); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws.cs new file mode 100644 index 000000000..e6be8a3da --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws.cs @@ -0,0 +1,41 @@ +namespace NServiceBus.TransportTests +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using NUnit.Framework; + using Transport; + + public class When_on_message_throws : NServiceBusTransportTest + { + [TestCase(TransportTransactionMode.None)] + [TestCase(TransportTransactionMode.ReceiveOnly)] + [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] + [TestCase(TransportTransactionMode.TransactionScope)] + public async Task Should_call_on_error(TransportTransactionMode transactionMode) + { + var onErrorCalled = new TaskCompletionSource(); + + OnTestTimeout(() => onErrorCalled.SetCanceled()); + + await StartPump(context => + { + throw new Exception("Simulated exception"); + }, + context => + { + onErrorCalled.SetResult(context); + + return Task.FromResult(ErrorHandleResult.Handled); + }, transactionMode); + + await SendMessage(InputQueueName, new Dictionary { { "MyHeader", "MyValue" } }); + + var errorContext = await onErrorCalled.Task; + + Assert.AreEqual(errorContext.Exception.Message, "Simulated exception", "Should preserve the exception"); + Assert.AreEqual(1, errorContext.ImmediateProcessingFailures, "Should track the number of delivery attempts"); + Assert.AreEqual("MyValue", errorContext.Message.Headers["MyHeader"], "Should pass the message headers"); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws_after_delayed_retry.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws_after_delayed_retry.cs new file mode 100644 index 000000000..30efdab96 --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws_after_delayed_retry.cs @@ -0,0 +1,51 @@ +namespace NServiceBus.TransportTests +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using NUnit.Framework; + using Transport; + + public class When_on_message_throws_after_delayed_retry : NServiceBusTransportTest + { + //[TestCase(TransportTransactionMode.None)] - not relevant + [TestCase(TransportTransactionMode.ReceiveOnly)] + [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] + [TestCase(TransportTransactionMode.TransactionScope)] + public async Task Should_reset_delivery_counter(TransportTransactionMode transactionMode) + { + var onErrorInvoked = new TaskCompletionSource(); + + OnTestTimeout(() => onErrorInvoked.SetCanceled()); + + var numberOfOnErrorInvocations = 0; + + await StartPump( + context => + { + throw new Exception("Simulated exception"); + }, + async context => + { + numberOfOnErrorInvocations += 1; + + if (numberOfOnErrorInvocations == 1) + { + await SendMessage(InputQueueName, context.Message.Headers, context.TransportTransaction); + } + else + { + onErrorInvoked.SetResult(context); + } + + return ErrorHandleResult.Handled; + }, transactionMode); + + await SendMessage(InputQueueName, new Dictionary { { "MyHeader", "MyValue" } }); + + var errorContext = await onErrorInvoked.Task; + + Assert.AreEqual(1, errorContext.ImmediateProcessingFailures, "Should track delivery attempts between immediate retries"); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws_after_immediate_retry.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws_after_immediate_retry.cs new file mode 100644 index 000000000..a96611c55 --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_on_message_throws_after_immediate_retry.cs @@ -0,0 +1,49 @@ +namespace NServiceBus.TransportTests +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using NUnit.Framework; + using Transport; + + public class When_on_message_throws_after_immediate_retry : NServiceBusTransportTest + { + //[TestCase(TransportTransactionMode.None)] - not relevant + [TestCase(TransportTransactionMode.ReceiveOnly)] + [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] + [TestCase(TransportTransactionMode.TransactionScope)] + public async Task Should_persist_message_delivery_count_between_on_error_calls(TransportTransactionMode transactionMode) + { + var onErrorInvoked = new TaskCompletionSource(); + + OnTestTimeout(() => onErrorInvoked.SetCanceled()); + + var numberOfOnErrorInvocations = 0; + + await StartPump( + context => + { + throw new Exception("Simulated exception"); + }, + context => + { + numberOfOnErrorInvocations += 1; + + if (numberOfOnErrorInvocations == 3) + { + onErrorInvoked.SetResult(context); + + return Task.FromResult(ErrorHandleResult.Handled); + } + + return Task.FromResult(ErrorHandleResult.RetryRequired); + }, transactionMode); + + await SendMessage(InputQueueName, new Dictionary { { "MyHeader", "MyValue" } }); + + var errorContext = await onErrorInvoked.Task; + + Assert.AreEqual(numberOfOnErrorInvocations, errorContext.ImmediateProcessingFailures, "Should track delivery attempts between immediate retries"); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_requesting_immediate_retry.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_requesting_immediate_retry.cs new file mode 100644 index 000000000..6a2f69f69 --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_requesting_immediate_retry.cs @@ -0,0 +1,40 @@ +namespace NServiceBus.TransportTests +{ + using System; + using System.Threading.Tasks; + using NUnit.Framework; + using Transport; + + public class When_requesting_immediate_retry : NServiceBusTransportTest + { + //[TestCase(TransportTransactionMode.None)] - Currently not supported, but there are plans to change that: https://github.com/Particular/NServiceBus/issues/2750 + [TestCase(TransportTransactionMode.ReceiveOnly)] + [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] + [TestCase(TransportTransactionMode.TransactionScope)] + public async Task Should_retry_immediately(TransportTransactionMode transactionMode) + { + var messageRetried = new TaskCompletionSource(); + + OnTestTimeout(() => messageRetried.SetResult(false)); + + var hasBeenCalled = false; + + await StartPump( + context => + { + if (hasBeenCalled) + { + messageRetried.SetResult(true); + return Task.FromResult(0); + } + hasBeenCalled = true; + throw new Exception("Simulated exception"); + }, + context => Task.FromResult(ErrorHandleResult.RetryRequired), transactionMode); + + await SendMessage(InputQueueName); + + Assert.True(await messageRetried.Task, "Should retry if asked so"); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_scope_dispose_throws.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_scope_dispose_throws.cs new file mode 100644 index 000000000..23736b4bd --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_scope_dispose_throws.cs @@ -0,0 +1,69 @@ +namespace NServiceBus.TransportTests +{ + using System; + using System.Threading.Tasks; + using System.Transactions; + using NUnit.Framework; + using Transport; + + public class When_scope_dispose_throws : NServiceBusTransportTest + { + [Test] + public async Task Should_call_on_error() + { + var onErrorCalled = new TaskCompletionSource(); + + OnTestTimeout(() => onErrorCalled.SetResult(null)); + + await StartPump(context => + { + // handler enlists a failing transaction enlistment to the DTC transaction which will fail when commiting the transaction. + Transaction.Current.EnlistDurable(EnlistmentWhichFailesDuringPrepare.Id, new EnlistmentWhichFailesDuringPrepare(), EnlistmentOptions.None); + + return Task.FromResult(0); + }, + context => + { + onErrorCalled.SetResult(context); + return Task.FromResult(ErrorHandleResult.Handled); + } + ,TransportTransactionMode.TransactionScope); + + await SendMessage(InputQueueName); + + var errorContext = await onErrorCalled.Task; + + Assert.IsInstanceOf(errorContext.Exception); + + // since some transports doesn't have native retry counters we can't expect the attempts to be fully consistent since if + // dispose throws the message might be picked up before the counter is incremented + Assert.LessOrEqual(1, errorContext.ImmediateProcessingFailures); + } + } + + class EnlistmentWhichFailesDuringPrepare : IEnlistmentNotification + { + public static readonly Guid Id = Guid.NewGuid(); + + public void Prepare(PreparingEnlistment preparingEnlistment) + { + // fail during prepare, this will cause scope.Dispose to throw + preparingEnlistment.ForceRollback(); + } + + public void Commit(Enlistment enlistment) + { + enlistment.Done(); + } + + public void Rollback(Enlistment enlistment) + { + enlistment.Done(); + } + + public void InDoubt(Enlistment enlistment) + { + enlistment.Done(); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_sending_from_on_error.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_sending_from_on_error.cs new file mode 100644 index 000000000..574ad34cc --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_sending_from_on_error.cs @@ -0,0 +1,44 @@ +namespace NServiceBus.TransportTests +{ + using System; + using System.Collections.Generic; + using System.Threading.Tasks; + using NUnit.Framework; + using Transport; + + public class When_sending_from_on_error : NServiceBusTransportTest + { + [TestCase(TransportTransactionMode.None)] + [TestCase(TransportTransactionMode.ReceiveOnly)] + [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] + [TestCase(TransportTransactionMode.TransactionScope)] + public async Task Should_dispatch_the_message(TransportTransactionMode transactionMode) + { + var messageReceived = new TaskCompletionSource(); + + OnTestTimeout(() => messageReceived.SetResult(false)); + + await StartPump( + context => + { + if (context.Headers.ContainsKey("FromOnError")) + { + messageReceived.SetResult(true); + return Task.FromResult(0); + } + + throw new Exception("Simulated exception"); + }, + async context => + { + await SendMessage(InputQueueName, new Dictionary { { "FromOnError", "true" } }, context.TransportTransaction); + + return ErrorHandleResult.Handled; + }, transactionMode); + + await SendMessage(InputQueueName); + + Assert.True(await messageReceived.Task, "Message not dispatched properly"); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_user_aborts_processing.cs b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_user_aborts_processing.cs new file mode 100644 index 000000000..3890200f5 --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/App_Packages/NSB.TransportTests.6.0.0-beta0006/When_user_aborts_processing.cs @@ -0,0 +1,47 @@ +namespace NServiceBus.TransportTests +{ + using System.Threading.Tasks; + using NUnit.Framework; + using Transport; + + public class When_user_aborts_processing : NServiceBusTransportTest + { + //[TestCase(TransportTransactionMode.None)] - Not currently supported since we can't rollback the message. We could consider inmemory retry similar to https://github.com/Particular/NServiceBus/issues/2750 in the future + [TestCase(TransportTransactionMode.ReceiveOnly)] + [TestCase(TransportTransactionMode.SendsAtomicWithReceive)] + [TestCase(TransportTransactionMode.TransactionScope)] + public async Task Should_retry_immediately(TransportTransactionMode transactionMode) + { + var messageRedelivered = new TaskCompletionSource(); + + OnTestTimeout(() => messageRedelivered.SetResult(false)); + + var hasBeenCalled = false; + var onErrorCalled = false; + + await StartPump( + context => + { + if (hasBeenCalled) + { + messageRedelivered.SetResult(true); + return Task.FromResult(0); + } + hasBeenCalled = true; + context.ReceiveCancellationTokenSource.Cancel(); + + return Task.FromResult(0); + }, + context => + { + onErrorCalled = true; + return Task.FromResult(ErrorHandleResult.RetryRequired); + }, transactionMode); + + await SendMessage(InputQueueName); + + Assert.True(await messageRedelivered.Task, "Should redeliver message"); + Assert.False(onErrorCalled, "Abort should not invoke on error"); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/ConfigureSqlServerTransportInfrastructure.cs b/src/NServiceBus.SqlServer.TransportTests/ConfigureSqlServerTransportInfrastructure.cs new file mode 100644 index 000000000..639387526 --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/ConfigureSqlServerTransportInfrastructure.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Linq; +using System.Threading.Tasks; +using NServiceBus; +using NServiceBus.Settings; +using NServiceBus.Transport; +using NServiceBus.TransportTests; + +public class ConfigureSqlServerTransportInfrastructure : IConfigureTransportInfrastructure +{ + public TransportConfigurationResult Configure(SettingsHolder settings, TransportTransactionMode transportTransactionMode) + { + this.settings = settings; + + return new TransportConfigurationResult + { + TransportInfrastructure = new SqlServerTransport().Initialize(settings, ConnectionString) + }; + } + + public async Task Cleanup() + { + var queueBindings = settings.Get(); + var queueNames = new List(); + + using (var conn = new SqlConnection(ConnectionString)) + { + await conn.OpenAsync(); + + var qn = queueBindings.ReceivingAddresses.ToList(); + qn.ForEach(n => + { + var nameParts = n.Split('@'); + if (nameParts.Length == 2) + { + using (var sanitizer = new SqlCommandBuilder()) + { + var sanitizedSchemaName = SanitizeIdentifier(nameParts[1], sanitizer); + var sanitizedTableName = SanitizeIdentifier(nameParts[0], sanitizer); + + queueNames.Add($"{sanitizedSchemaName}.{sanitizedTableName}"); + } + } + else + { + queueNames.Add(n); + } + }); + foreach (var queue in queueNames) + { + using (var comm = conn.CreateCommand()) + { + comm.CommandText = $"IF OBJECT_ID('{queue}', 'U') IS NOT NULL DROP TABLE {queue}"; + await comm.ExecuteNonQueryAsync(); + } + } + } + } + + static string SanitizeIdentifier(string identifier, SqlCommandBuilder sanitizer) + { + // Identifier may initially quoted or unquoted. + return sanitizer.QuoteIdentifier(sanitizer.UnquoteIdentifier(identifier)); + } + + SettingsHolder settings; + const string ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True"; +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/NServiceBus.SqlServer.TransportTests.csproj b/src/NServiceBus.SqlServer.TransportTests/NServiceBus.SqlServer.TransportTests.csproj new file mode 100644 index 000000000..57bec5eca --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/NServiceBus.SqlServer.TransportTests.csproj @@ -0,0 +1,87 @@ + + + + + Debug + AnyCPU + {165C21AA-A7ED-48F2-A122-C2418B2DEB59} + Library + Properties + NServiceBus.SqlServer.TransportTests + NServiceBus.SqlServer.TransportTests + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NServiceBus.6.0.0-beta0006\lib\net452\NServiceBus.Core.dll + True + + + ..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll + True + + + + + + + + + + + + + + + {fa1193bf-325c-4201-bb78-484032e09809} + NServiceBus.SqlServer + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.TransportTests/packages.config b/src/NServiceBus.SqlServer.TransportTests/packages.config new file mode 100644 index 000000000..ca13bbfe1 --- /dev/null +++ b/src/NServiceBus.SqlServer.TransportTests/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.UnitTests/APIApprovals.Approve.approved.txt b/src/NServiceBus.SqlServer.UnitTests/APIApprovals.Approve.approved.txt index 564150c5c..02ee9c994 100644 --- a/src/NServiceBus.SqlServer.UnitTests/APIApprovals.Approve.approved.txt +++ b/src/NServiceBus.SqlServer.UnitTests/APIApprovals.Approve.approved.txt @@ -4,12 +4,12 @@ [assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5.2", FrameworkDisplayName=".NET Framework 4.5.2")] namespace NServiceBus { - public class SqlServerTransport : NServiceBus.Transports.TransportDefinition + public class SqlServerTransport : NServiceBus.Transport.TransportDefinition { public SqlServerTransport() { } public override string ExampleConnectionStringForErrorMessage { get; } public override bool RequiresConnectionString { get; } - protected override NServiceBus.Transports.TransportInfrastructure Initialize(NServiceBus.Settings.SettingsHolder settings, string connectionString) { } + public override NServiceBus.Transport.TransportInfrastructure Initialize(NServiceBus.Settings.SettingsHolder settings, string connectionString) { } } } namespace NServiceBus.Transport.SQLServer.ConnectionStrings diff --git a/src/NServiceBus.SqlServer.UnitTests/NServiceBus.SqlServer.UnitTests.csproj b/src/NServiceBus.SqlServer.UnitTests/NServiceBus.SqlServer.UnitTests.csproj index 601a8b5ee..dad43c9d9 100644 --- a/src/NServiceBus.SqlServer.UnitTests/NServiceBus.SqlServer.UnitTests.csproj +++ b/src/NServiceBus.SqlServer.UnitTests/NServiceBus.SqlServer.UnitTests.csproj @@ -52,10 +52,6 @@ ..\packages\ApprovalUtilities.3.0.11\lib\net45\ApprovalUtilities.Net45.dll True - - ..\packages\HdrHistogram.1.0.120-prerelease\lib\net45\HdrHistogram.dll - True - ..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll True @@ -73,11 +69,11 @@ True - ..\packages\NServiceBus.6.0.0-beta0003\lib\net452\NServiceBus.Core.dll + ..\packages\NServiceBus.6.0.0-beta0006\lib\net452\NServiceBus.Core.dll True - - ..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dll + + ..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll True @@ -96,6 +92,7 @@ + diff --git a/src/NServiceBus.SqlServer.UnitTests/Receiving/FailureInfoStorageTests.cs b/src/NServiceBus.SqlServer.UnitTests/Receiving/FailureInfoStorageTests.cs new file mode 100644 index 000000000..938b878e6 --- /dev/null +++ b/src/NServiceBus.SqlServer.UnitTests/Receiving/FailureInfoStorageTests.cs @@ -0,0 +1,127 @@ +namespace NServiceBus.SqlServer.UnitTests +{ + using System; + using System.Collections.Generic; + using NUnit.Framework; + using Transport.SQLServer; + + public class FailureInfoStorageTests + { + [Test] + public void When_recording_failure_initially_should_store_one_failed_attempt_and_exception() + { + var messageId = Guid.NewGuid().ToString("D"); + var exception = new Exception(); + + var storage = GetFailureInfoStorage(); + + storage.RecordFailureInfoForMessage(messageId, exception); + + FailureInfoStorage.ProcessingFailureInfo failureInfo; + storage.TryGetFailureInfoForMessage(messageId, out failureInfo); + + Assert.NotNull(failureInfo); + Assert.AreEqual(1, failureInfo.NumberOfProcessingAttempts); + Assert.AreSame(exception, failureInfo.Exception); + } + + [Test] + public void When_recording_failure_many_times_should_store_number_of_attempts_and_last_exception() + { + var messageId = Guid.NewGuid().ToString("D"); + var secondException = new Exception(); + + var storage = GetFailureInfoStorage(); + + storage.RecordFailureInfoForMessage(messageId, new Exception()); + storage.RecordFailureInfoForMessage(messageId, secondException); + + FailureInfoStorage.ProcessingFailureInfo failureInfo; + storage.TryGetFailureInfoForMessage(messageId, out failureInfo); + + Assert.NotNull(failureInfo); + Assert.AreEqual(2, failureInfo.NumberOfProcessingAttempts); + Assert.AreSame(secondException, failureInfo.Exception); + } + + [Test] + public void When_clearing_failure_should_return_null_on_subsequent_retrieval() + { + var messageId = Guid.NewGuid().ToString("D"); + + var storage = GetFailureInfoStorage(); + + storage.RecordFailureInfoForMessage(messageId, new Exception()); + + FailureInfoStorage.ProcessingFailureInfo failureInfo; + + storage.TryGetFailureInfoForMessage(messageId, out failureInfo); + Assert.NotNull(failureInfo); + + storage.ClearFailureInfoForMessage(messageId); + + storage.TryGetFailureInfoForMessage(messageId, out failureInfo); + Assert.IsNull(failureInfo); + } + + [Test] + public void When_recording_more_than_max_number_of_failures_should_remove_least_recently_used_entry() + { + const int MaxElements = 50; + var storage = new FailureInfoStorage(maxElements: MaxElements); + + var lruMessageId = Guid.NewGuid().ToString("D"); + + storage.RecordFailureInfoForMessage(lruMessageId, new Exception()); + + for (var i = 0; i < MaxElements; ++i) + { + var messageId = Guid.NewGuid().ToString("D"); + var exception = new Exception(); + + storage.RecordFailureInfoForMessage(messageId, exception); + } + + FailureInfoStorage.ProcessingFailureInfo failureInfo; + storage.TryGetFailureInfoForMessage(lruMessageId, out failureInfo); + + Assert.IsNull(failureInfo); + } + + [Test] + public void When_recording_a_failure_for_a_message_it_should_not_be_treated_as_least_recently_used() + { + const int MaxElements = 50; + var storage = new FailureInfoStorage(MaxElements); + + var lruMessageId = Guid.NewGuid().ToString("D"); + + storage.RecordFailureInfoForMessage(lruMessageId, new Exception()); + + var messageIds = new List(MaxElements); + for (var i = 0; i < MaxElements; ++i) + { + messageIds.Add(Guid.NewGuid().ToString("D")); + } + + for (var i = 0; i < MaxElements - 1; ++i) + { + storage.RecordFailureInfoForMessage(messageIds[i], new Exception()); + } + + storage.RecordFailureInfoForMessage(lruMessageId, new Exception()); + + storage.RecordFailureInfoForMessage(messageIds[MaxElements - 1], new Exception()); + + FailureInfoStorage.ProcessingFailureInfo failureInfo; + storage.TryGetFailureInfoForMessage(lruMessageId, out failureInfo); + + Assert.IsNotNull(failureInfo); + } + + static FailureInfoStorage GetFailureInfoStorage() + { + return new FailureInfoStorage(10); + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.UnitTests/Sending/MessageDispatcherTests.cs b/src/NServiceBus.SqlServer.UnitTests/Sending/MessageDispatcherTests.cs index 03c6ab162..d1ca12cee 100644 --- a/src/NServiceBus.SqlServer.UnitTests/Sending/MessageDispatcherTests.cs +++ b/src/NServiceBus.SqlServer.UnitTests/Sending/MessageDispatcherTests.cs @@ -6,7 +6,7 @@ using Extensibility; using NUnit.Framework; using Routing; - using Transports; + using Transport; using Transport.SQLServer; [TestFixture] @@ -19,7 +19,7 @@ public async Task It_deduplicates_based_on_message_id_and_address(TransportOpera var dispatcher = new MessageDispatcher(queueDispatcher, new QueueAddressParser("dbo", null, s => null)); - await dispatcher.Dispatch(transportOperations, new ContextBag()); + await dispatcher.Dispatch(transportOperations, new TransportTransaction(), new ContextBag()); Assert.AreEqual(expectedDispatchedMessageCount, queueDispatcher.DispatchedMessageIds.Count); } @@ -70,7 +70,7 @@ class FakeTableBasedQueueDispatcher : IQueueDispatcher { public List DispatchedMessageIds = new List(); - public Task DispatchAsNonIsolated(HashSet operations, ContextBag context) + public Task DispatchAsNonIsolated(HashSet operations, TransportTransaction transportTransaction) { DispatchedMessageIds.AddRange(operations.Select(x => x.Message.MessageId)); return Task.FromResult(0); diff --git a/src/NServiceBus.SqlServer.UnitTests/packages.config b/src/NServiceBus.SqlServer.UnitTests/packages.config index 14570dc51..e0255c36c 100644 --- a/src/NServiceBus.SqlServer.UnitTests/packages.config +++ b/src/NServiceBus.SqlServer.UnitTests/packages.config @@ -3,8 +3,7 @@ - - - + + \ No newline at end of file diff --git a/src/NServiceBus.SqlServer.sln b/src/NServiceBus.SqlServer.sln index 7c323ea89..a7b8ac75a 100644 --- a/src/NServiceBus.SqlServer.sln +++ b/src/NServiceBus.SqlServer.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.SqlServer", "NServiceBus.SqlServer\NServiceBus.SqlServer.csproj", "{FA1193BF-325C-4201-BB78-484032E09809}" EndProject @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.SqlServer.UnitT EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.SqlServer.IntegrationTests", "NServiceBus.SqlServer.IntegrationTests\NServiceBus.SqlServer.IntegrationTests.csproj", "{BEFACD2C-02EC-488B-9FB7-696A5EAF4FEB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.SqlServer.TransportTests", "NServiceBus.SqlServer.TransportTests\NServiceBus.SqlServer.TransportTests.csproj", "{165C21AA-A7ED-48F2-A122-C2418B2DEB59}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +41,10 @@ Global {BEFACD2C-02EC-488B-9FB7-696A5EAF4FEB}.Debug|Any CPU.Build.0 = Debug|Any CPU {BEFACD2C-02EC-488B-9FB7-696A5EAF4FEB}.Release|Any CPU.ActiveCfg = Release|Any CPU {BEFACD2C-02EC-488B-9FB7-696A5EAF4FEB}.Release|Any CPU.Build.0 = Release|Any CPU + {165C21AA-A7ED-48F2-A122-C2418B2DEB59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {165C21AA-A7ED-48F2-A122-C2418B2DEB59}.Debug|Any CPU.Build.0 = Debug|Any CPU + {165C21AA-A7ED-48F2-A122-C2418B2DEB59}.Release|Any CPU.ActiveCfg = Release|Any CPU + {165C21AA-A7ED-48F2-A122-C2418B2DEB59}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyQueueCreator.cs b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyQueueCreator.cs index 820651adc..925504a94 100644 --- a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyQueueCreator.cs +++ b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyQueueCreator.cs @@ -3,7 +3,7 @@ using System.Data; using System.Data.SqlClient; using System.Threading.Tasks; - using Transports; + using Transport; class LegacyQueueCreator : ICreateQueues { diff --git a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyReceiveWithTransactionScope.cs b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyReceiveWithTransactionScope.cs index e99050185..2261cebf9 100644 --- a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyReceiveWithTransactionScope.cs +++ b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyReceiveWithTransactionScope.cs @@ -1,70 +1,115 @@ namespace NServiceBus.Transport.SQLServer { using System; + using System.Data.SqlClient; using System.Threading; using System.Threading.Tasks; using System.Transactions; - using Extensibility; - using Transports; class LegacyReceiveWithTransactionScope : ReceiveStrategy { - public LegacyReceiveWithTransactionScope(TransactionOptions transactionOptions, LegacySqlConnectionFactory connectionFactory) + public LegacyReceiveWithTransactionScope(TransactionOptions transactionOptions, LegacySqlConnectionFactory connectionFactory, FailureInfoStorage failureInfoStorage) { this.transactionOptions = transactionOptions; this.connectionFactory = connectionFactory; + this.failureInfoStorage = failureInfoStorage; } - public async Task ReceiveMessage(TableBasedQueue inputQueue, TableBasedQueue errorQueue, CancellationTokenSource receiveCancellationTokenSource, Func onMessage) + public override async Task ReceiveMessage(CancellationTokenSource receiveCancellationTokenSource) { - using (var scope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled)) - - using (var inputConnection = await connectionFactory.OpenNewConnection(inputQueue.TransportAddress).ConfigureAwait(false)) + Message message = null; + try { - var readResult = await inputQueue.TryReceive(inputConnection, null).ConfigureAwait(false); - - if (readResult.IsPoison) + using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, transactionOptions, TransactionScopeAsyncFlowOption.Enabled)) + using (var inputConnection = await connectionFactory.OpenNewConnection(InputQueue.TransportAddress).ConfigureAwait(false)) { - using (var errorConnection = await connectionFactory.OpenNewConnection(errorQueue.TransportAddress).ConfigureAwait(false)) - { - await errorQueue.DeadLetter(readResult.PoisonMessage, errorConnection, null).ConfigureAwait(false); + message = await TryReceive(inputConnection, receiveCancellationTokenSource).ConfigureAwait(false); + if (message == null) + { + // The message was received but is not fit for processing (e.g. was DLQd). + // In such a case we still need to commit the transport tx to remove message + // from the queue table. scope.Complete(); return; } - } - if (!readResult.Successful) + if (await TryProcess(message, PrepareTransportTransaction(inputConnection)).ConfigureAwait(false)) + { + scope.Complete(); + } + } + } + catch (Exception exception) + { + if (message == null) { - scope.Complete(); - receiveCancellationTokenSource.Cancel(); - return; + throw; } + failureInfoStorage.RecordFailureInfoForMessage(message.TransportId, exception); + } + } - var message = readResult.Message; + async Task TryReceive(SqlConnection connection, CancellationTokenSource receiveCancellationTokenSource) + { + var receiveResult = await InputQueue.TryReceive(connection, null).ConfigureAwait(false); - using (var pushCancellationTokenSource = new CancellationTokenSource()) - using (var bodyStream = message.BodyStream) + if (!receiveResult.Successful) + { + receiveCancellationTokenSource.Cancel(); + return null; + } + + if (receiveResult.IsPoison) + { + using (var errorConnection = await connectionFactory.OpenNewConnection(ErrorQueue.TransportAddress).ConfigureAwait(false)) { - var transportTransaction = new TransportTransaction(); - transportTransaction.Set(inputConnection); - transportTransaction.Set(Transaction.Current); + await ErrorQueue.DeadLetter(receiveResult.PoisonMessage, errorConnection, null).ConfigureAwait(false); + return null; + } + } - var pushContext = new PushContext(message.TransportId, message.Headers, bodyStream, transportTransaction, pushCancellationTokenSource, new ContextBag()); + return receiveResult.Message; + } - await onMessage(pushContext).ConfigureAwait(false); + TransportTransaction PrepareTransportTransaction(SqlConnection connection) + { + var transportTransaction = new TransportTransaction(); - if (pushCancellationTokenSource.Token.IsCancellationRequested) - { - return; - } + //those resources are meant to be used by anyone except message dispatcher e.g. persister + transportTransaction.Set(connection); + transportTransaction.Set(Transaction.Current); + + return transportTransaction; + } + + async Task TryProcess(Message message, TransportTransaction transportTransaction) + { + FailureInfoStorage.ProcessingFailureInfo failure; + if (failureInfoStorage.TryGetFailureInfoForMessage(message.TransportId, out failure)) + { + var errorHandlingResult = await HandleError(failure.Exception, message, transportTransaction, failure.NumberOfProcessingAttempts).ConfigureAwait(false); + + if (errorHandlingResult == ErrorHandleResult.Handled) + { + failureInfoStorage.ClearFailureInfoForMessage(message.TransportId); + return true; } + } - scope.Complete(); + using (var bodyStream = message.BodyStream) + { + var messageProcessed = await TryProcessingMessage(message, bodyStream, transportTransaction).ConfigureAwait(false); + if (messageProcessed) + { + failureInfoStorage.ClearFailureInfoForMessage(message.TransportId); + } + return messageProcessed; } } TransactionOptions transactionOptions; LegacySqlConnectionFactory connectionFactory; + FailureInfoStorage failureInfoStorage; } } \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacySqlServerTransportInfrastructure.cs b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacySqlServerTransportInfrastructure.cs index e15cf60b4..92f103600 100644 --- a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacySqlServerTransportInfrastructure.cs +++ b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacySqlServerTransportInfrastructure.cs @@ -4,7 +4,7 @@ using System.Data.SqlClient; using System.Threading.Tasks; using Settings; - using Transports; + using Transport; class LegacySqlServerTransportInfrastructure : SqlServerTransportInfrastructure { @@ -51,7 +51,7 @@ public override TransportReceiveInfrastructure ConfigureReceiveInfrastructure() throw new Exception("Legacy multiinstance mode is supported only with TransportTransactionMode=TransactionScope"); } - return new LegacyReceiveWithTransactionScope(scopeOptions.TransactionOptions, connectionFactory); + return new LegacyReceiveWithTransactionScope(scopeOptions.TransactionOptions, connectionFactory, new FailureInfoStorage(1000)); }; Func queueFactory = qa => new TableBasedQueue(qa); diff --git a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyTableBasedQueueDispatcher.cs b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyTableBasedQueueDispatcher.cs index d0cf42c40..810f0c894 100644 --- a/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyTableBasedQueueDispatcher.cs +++ b/src/NServiceBus.SqlServer/Legacy/MultiInstance/LegacyTableBasedQueueDispatcher.cs @@ -3,7 +3,6 @@ namespace NServiceBus.Transport.SQLServer using System.Collections.Generic; using System.Threading.Tasks; using System.Transactions; - using Extensibility; class LegacyTableBasedQueueDispatcher : IQueueDispatcher { @@ -12,7 +11,7 @@ public LegacyTableBasedQueueDispatcher(LegacySqlConnectionFactory connectionFact this.connectionFactory = connectionFactory; } - public virtual async Task DispatchAsNonIsolated(HashSet operations, ContextBag context) + public virtual async Task DispatchAsNonIsolated(HashSet operations, TransportTransaction transportTransaction) { //If dispatch is not isolated then either TS has been created by the receive operation or needs to be created here. using (var scope = new TransactionScope(TransactionScopeOption.Required, TransactionScopeAsyncFlowOption.Enabled)) diff --git a/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj b/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj index 0fa12fdc8..4942f8bc2 100644 --- a/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj +++ b/src/NServiceBus.SqlServer/NServiceBus.SqlServer.csproj @@ -56,7 +56,7 @@ - ..\packages\NServiceBus.6.0.0-beta0003\lib\net452\NServiceBus.Core.dll + ..\packages\NServiceBus.6.0.0-beta0006\lib\net452\NServiceBus.Core.dll True @@ -97,7 +97,6 @@ - @@ -114,7 +113,7 @@ - + @@ -123,6 +122,7 @@ + diff --git a/src/NServiceBus.SqlServer/Queuing/TableBasedQueue.cs b/src/NServiceBus.SqlServer/Queuing/TableBasedQueue.cs index 76e87b8bb..cf983a686 100644 --- a/src/NServiceBus.SqlServer/Queuing/TableBasedQueue.cs +++ b/src/NServiceBus.SqlServer/Queuing/TableBasedQueue.cs @@ -6,7 +6,7 @@ namespace NServiceBus.Transport.SQLServer using System.Threading; using System.Threading.Tasks; using Logging; - using Transports; + using Transport; using Unicast.Queuing; using static System.String; diff --git a/src/NServiceBus.SqlServer/Receiving/FailureInfoStorage.cs b/src/NServiceBus.SqlServer/Receiving/FailureInfoStorage.cs new file mode 100644 index 000000000..cb93277a7 --- /dev/null +++ b/src/NServiceBus.SqlServer/Receiving/FailureInfoStorage.cs @@ -0,0 +1,108 @@ +namespace NServiceBus.Transport.SQLServer +{ + using System; + using System.Collections.Generic; + using System.Runtime.ExceptionServices; + + // The data structure has fixed maximum size. When the data structure reaches its maximum size, + // the least recently used (LRU) message processing failure is removed from the storage. + class FailureInfoStorage + { + public FailureInfoStorage(int maxElements) + { + this.maxElements = maxElements; + } + + public void RecordFailureInfoForMessage(string messageId, Exception exception) + { + lock (lockObject) + { + FailureInfoNode node; + if (failureInfoPerMessage.TryGetValue(messageId, out node)) + { + // We have seen this message before, just update the counter and store exception. + node.FailureInfo = new ProcessingFailureInfo(node.FailureInfo.NumberOfProcessingAttempts + 1, ExceptionDispatchInfo.Capture(exception)); + + // Maintain invariant: leastRecentlyUsedMessages.First contains the LRU item. + leastRecentlyUsedMessages.Remove(node.LeastRecentlyUsedEntry); + leastRecentlyUsedMessages.AddLast(node.LeastRecentlyUsedEntry); + } + else + { + if (failureInfoPerMessage.Count == maxElements) + { + // We have reached the maximum allowed capacity. Remove the LRU item. + var leastRecentlyUsedEntry = leastRecentlyUsedMessages.First; + failureInfoPerMessage.Remove(leastRecentlyUsedEntry.Value); + leastRecentlyUsedMessages.RemoveFirst(); + } + + var newNode = new FailureInfoNode( + messageId, + new ProcessingFailureInfo(1, ExceptionDispatchInfo.Capture(exception))); + + failureInfoPerMessage[messageId] = newNode; + + // Maintain invariant: leastRecentlyUsedMessages.First contains the LRU item. + leastRecentlyUsedMessages.AddLast(newNode.LeastRecentlyUsedEntry); + } + } + } + + public bool TryGetFailureInfoForMessage(string messageId, out ProcessingFailureInfo processingFailureInfo) + { + lock (lockObject) + { + FailureInfoNode node; + if (!failureInfoPerMessage.TryGetValue(messageId, out node)) + { + processingFailureInfo = null; + return false; + } + processingFailureInfo = node.FailureInfo; + + return true; + } + } + + public void ClearFailureInfoForMessage(string messageId) + { + lock (lockObject) + { + failureInfoPerMessage.Remove(messageId); + leastRecentlyUsedMessages.Remove(messageId); + } + } + + Dictionary failureInfoPerMessage = new Dictionary(); + LinkedList leastRecentlyUsedMessages = new LinkedList(); + object lockObject = new object(); + + int maxElements; + + class FailureInfoNode + { + public FailureInfoNode(string messageId, ProcessingFailureInfo failureInfo) + { + FailureInfo = failureInfo; + LeastRecentlyUsedEntry = new LinkedListNode(messageId); + } + + public ProcessingFailureInfo FailureInfo { get; set; } + public LinkedListNode LeastRecentlyUsedEntry { get; } + } + + public class ProcessingFailureInfo + { + public ProcessingFailureInfo(int numberOfProcessingAttempts, ExceptionDispatchInfo exceptionDispatchInfo) + { + NumberOfProcessingAttempts = numberOfProcessingAttempts; + ExceptionDispatchInfo = exceptionDispatchInfo; + } + + public int NumberOfProcessingAttempts { get; } + public Exception Exception => ExceptionDispatchInfo.SourceException; + ExceptionDispatchInfo ExceptionDispatchInfo { get; } + } + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/Receiving/MessagePump.cs b/src/NServiceBus.SqlServer/Receiving/MessagePump.cs index afbbab2ff..b7dd4d6ef 100644 --- a/src/NServiceBus.SqlServer/Receiving/MessagePump.cs +++ b/src/NServiceBus.SqlServer/Receiving/MessagePump.cs @@ -6,7 +6,7 @@ using System.Threading; using System.Threading.Tasks; using Logging; - using Transports; + using Transport; class MessagePump : IPushMessages { @@ -21,10 +21,8 @@ public MessagePump(Func receiveStrate this.waitTimeCircuitBreaker = waitTimeCircuitBreaker; } - public async Task Init(Func pipe, CriticalError criticalError, PushSettings settings) + public async Task Init(Func onMessage, Func> onError, CriticalError criticalError, PushSettings settings) { - pipeline = pipe; - receiveStrategy = receiveStrategyFactory(settings.RequiredTransactionMode); peekCircuitBreaker = new RepeatedFailuresOverTimeCircuitBreaker("SqlPeek", waitTimeCircuitBreaker, ex => criticalError.Raise("Failed to peek " + settings.InputQueue, ex)); @@ -33,6 +31,8 @@ public async Task Init(Func pipe, CriticalError criticalError inputQueue = queueFactory(addressParser.Parse(settings.InputQueue)); errorQueue = queueFactory(addressParser.Parse(settings.ErrorQueue)); + receiveStrategy.Init(inputQueue, errorQueue, onMessage, onError, criticalError); + if (settings.PurgeOnStartup) { var purgedRowsCount = await queuePurger.Purge(inputQueue).ConfigureAwait(false); @@ -150,7 +150,7 @@ async Task InnerReceive(CancellationTokenSource loopCancellationTokenSource) // in combination with TransactionScope will apply connection pooling and enlistment synchronous in ctor. await Task.Yield(); - await receiveStrategy.ReceiveMessage(inputQueue, errorQueue, loopCancellationTokenSource, pipeline) + await receiveStrategy.ReceiveMessage(loopCancellationTokenSource) .ConfigureAwait(false); receiveCircuitBreaker.Success(); @@ -186,7 +186,6 @@ async Task PurgeExpiredMessages() TableBasedQueue inputQueue; TableBasedQueue errorQueue; - Func pipeline; Func receiveStrategyFactory; IPurgeQueues queuePurger; Func queueFactory; diff --git a/src/NServiceBus.SqlServer/Receiving/QueueCreator.cs b/src/NServiceBus.SqlServer/Receiving/QueueCreator.cs index 9cc73926b..4a7456e9b 100644 --- a/src/NServiceBus.SqlServer/Receiving/QueueCreator.cs +++ b/src/NServiceBus.SqlServer/Receiving/QueueCreator.cs @@ -3,7 +3,7 @@ namespace NServiceBus.Transport.SQLServer using System.Data; using System.Data.SqlClient; using System.Threading.Tasks; - using Transports; + using Transport; class QueueCreator : ICreateQueues { diff --git a/src/NServiceBus.SqlServer/Receiving/ReceiveStrategy.cs b/src/NServiceBus.SqlServer/Receiving/ReceiveStrategy.cs index e4cc23ef9..138ebf071 100644 --- a/src/NServiceBus.SqlServer/Receiving/ReceiveStrategy.cs +++ b/src/NServiceBus.SqlServer/Receiving/ReceiveStrategy.cs @@ -1,12 +1,74 @@ namespace NServiceBus.Transport.SQLServer { using System; + using System.IO; using System.Threading; using System.Threading.Tasks; - using Transports; + using Extensibility; - interface ReceiveStrategy + abstract class ReceiveStrategy { - Task ReceiveMessage(TableBasedQueue inputQueue, TableBasedQueue errorQueue, CancellationTokenSource receiveCancellationTokenSource, Func onMessage); + protected TableBasedQueue InputQueue { get; private set; } + protected TableBasedQueue ErrorQueue { get; private set; } + + Func onMessage; + Func> onError; + + public void Init(TableBasedQueue inputQueue, TableBasedQueue errorQueue, Func onMessage, Func> onError, CriticalError criticalError) + { + InputQueue = inputQueue; + ErrorQueue = errorQueue; + this.onMessage = onMessage; + this.onError = onError; + this.criticalError = criticalError; + } + + public abstract Task ReceiveMessage(CancellationTokenSource receiveCancellationTokenSource); + + protected async Task TryProcessingMessage(Message message, Stream bodyStream, TransportTransaction transportTransaction) + { + using (var pushCancellationTokenSource = new CancellationTokenSource()) + { + var body = await ReadStream(bodyStream).ConfigureAwait(false); + var messageContext = new MessageContext(message.TransportId, message.Headers, body, transportTransaction, pushCancellationTokenSource, new ContextBag()); + + await onMessage(messageContext).ConfigureAwait(false); + + // Cancellation is requested when message processing is aborted. + // We return the opposite value: + // - true when message processing completed successfully, + // - false when message processing was aborted. + return !pushCancellationTokenSource.Token.IsCancellationRequested; + } + } + + protected async Task HandleError(Exception exception, Message message, TransportTransaction transportTransaction, int processingAttempts) + { + try + { + var body = await ReadStream(message.BodyStream).ConfigureAwait(false); + var errorContext = new ErrorContext(exception, message.Headers, message.TransportId, body, transportTransaction, processingAttempts); + + return await onError(errorContext).ConfigureAwait(false); + } + catch (Exception ex) + { + criticalError.Raise($"Failed to execute reverability actions for message `{message.TransportId}`", ex); + + return ErrorHandleResult.RetryRequired; + } + } + + static async Task ReadStream(Stream bodyStream) + { + var body = new byte[bodyStream.Length]; + + bodyStream.Seek(0, SeekOrigin.Begin); + await bodyStream.ReadAsync(body, 0, body.Length).ConfigureAwait(false); + + return body; + } + + CriticalError criticalError; } } \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/Receiving/ReceiveWithNativeTransaction.cs b/src/NServiceBus.SqlServer/Receiving/ReceiveWithNativeTransaction.cs new file mode 100644 index 000000000..83edb6231 --- /dev/null +++ b/src/NServiceBus.SqlServer/Receiving/ReceiveWithNativeTransaction.cs @@ -0,0 +1,127 @@ +namespace NServiceBus.Transport.SQLServer +{ + using System; + using System.Data.SqlClient; + using System.Threading; + using System.Threading.Tasks; + using System.Transactions; + using IsolationLevel = System.Data.IsolationLevel; + + class ReceiveWithNativeTransaction : ReceiveStrategy + { + public ReceiveWithNativeTransaction(TransactionOptions transactionOptions, SqlConnectionFactory connectionFactory, FailureInfoStorage failureInfoStorage, bool transactionForReceiveOnly = false) + { + this.connectionFactory = connectionFactory; + this.failureInfoStorage = failureInfoStorage; + this.transactionForReceiveOnly = transactionForReceiveOnly; + + isolationLevel = IsolationLevelMapper.Map(transactionOptions.IsolationLevel); + } + + public override async Task ReceiveMessage(CancellationTokenSource receiveCancellationTokenSource) + { + Message message = null; + try + { + using (var connection = await connectionFactory.OpenNewConnection().ConfigureAwait(false)) + using (var transaction = connection.BeginTransaction(isolationLevel)) + { + message = await TryReceive(connection, transaction, receiveCancellationTokenSource).ConfigureAwait(false); + + if (message == null) + { + // The message was received but is not fit for processing (e.g. was DLQd). + // In such a case we still need to commit the transport tx to remove message + // from the queue table. + transaction.Commit(); + return; + } + + if (await TryProcess(message, PrepareTransportTransaction(connection, transaction)).ConfigureAwait(false)) + { + transaction.Commit(); + } + else + { + transaction.Rollback(); + } + } + } + catch (Exception exception) + { + if (message == null) + { + throw; + } + failureInfoStorage.RecordFailureInfoForMessage(message.TransportId, exception); + } + } + + async Task TryReceive(SqlConnection connection, SqlTransaction transaction, CancellationTokenSource receiveCancellationTokenSource) + { + var receiveResult = await InputQueue.TryReceive(connection, transaction).ConfigureAwait(false); + + if (receiveResult.IsPoison) + { + await ErrorQueue.DeadLetter(receiveResult.PoisonMessage, connection, transaction).ConfigureAwait(false); + return null; + } + + if (!receiveResult.Successful) + { + receiveCancellationTokenSource.Cancel(); + return null; + } + + return receiveResult.Message; + } + + TransportTransaction PrepareTransportTransaction(SqlConnection connection, SqlTransaction transaction) + { + var transportTransaction = new TransportTransaction(); + + //those resources are meant to be used by anyone except message dispatcher e.g. persister + transportTransaction.Set(connection); + transportTransaction.Set(transaction); + + if (transactionForReceiveOnly) + { + //this indicates to MessageDispatcher that it should not reuse connection or transaction for sends + transportTransaction.Set(ReceiveOnlyTransactionMode, true); + } + + return transportTransaction; + } + + async Task TryProcess(Message message, TransportTransaction transportTransaction) + { + FailureInfoStorage.ProcessingFailureInfo failure; + if (failureInfoStorage.TryGetFailureInfoForMessage(message.TransportId, out failure)) + { + var errorHandlingResult = await HandleError(failure.Exception, message, transportTransaction, failure.NumberOfProcessingAttempts).ConfigureAwait(false); + + if (errorHandlingResult == ErrorHandleResult.Handled) + { + failureInfoStorage.ClearFailureInfoForMessage(message.TransportId); + return true; + } + } + + using (var bodyStream = message.BodyStream) + { + var messageProcessed = await TryProcessingMessage(message, bodyStream, transportTransaction).ConfigureAwait(false); + if (messageProcessed) + { + failureInfoStorage.ClearFailureInfoForMessage(message.TransportId); + } + return messageProcessed; + } + } + + IsolationLevel isolationLevel; + SqlConnectionFactory connectionFactory; + FailureInfoStorage failureInfoStorage; + bool transactionForReceiveOnly; + internal static string ReceiveOnlyTransactionMode = "SqlTransport.ReceiveOnlyTransactionMode"; + } +} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/Receiving/ReceiveWithNoTransaction.cs b/src/NServiceBus.SqlServer/Receiving/ReceiveWithNoTransaction.cs index 34ef22cea..b3eff54a6 100644 --- a/src/NServiceBus.SqlServer/Receiving/ReceiveWithNoTransaction.cs +++ b/src/NServiceBus.SqlServer/Receiving/ReceiveWithNoTransaction.cs @@ -3,8 +3,6 @@ namespace NServiceBus.Transport.SQLServer using System; using System.Threading; using System.Threading.Tasks; - using Extensibility; - using Transports; class ReceiveWithNoTransaction : ReceiveStrategy { @@ -13,37 +11,41 @@ public ReceiveWithNoTransaction(SqlConnectionFactory connectionFactory) this.connectionFactory = connectionFactory; } - public async Task ReceiveMessage(TableBasedQueue inputQueue, TableBasedQueue errorQueue, CancellationTokenSource receiveCancellationTokenSource, Func onMessage) + public override async Task ReceiveMessage(CancellationTokenSource receiveCancellationTokenSource) { using (var connection = await connectionFactory.OpenNewConnection().ConfigureAwait(false)) { - var readResult = await inputQueue.TryReceive(connection, null).ConfigureAwait(false); + var readResult = await InputQueue.TryReceive(connection, null).ConfigureAwait(false); if (readResult.IsPoison) { - await errorQueue.DeadLetter(readResult.PoisonMessage, connection, null).ConfigureAwait(false); - + await ErrorQueue.DeadLetter(readResult.PoisonMessage, connection, null).ConfigureAwait(false); return; } - if (readResult.Successful) + if (!readResult.Successful) { - var message = readResult.Message; + receiveCancellationTokenSource.Cancel(); + return; + } - using (var pushCancellationTokenSource = new CancellationTokenSource()) - using (var bodyStream = message.BodyStream) - { - var transportTransaction = new TransportTransaction(); - transportTransaction.Set(connection); + var transportTransaction = new TransportTransaction(); + transportTransaction.Set(connection); - var pushContext = new PushContext(message.TransportId, message.Headers, bodyStream, transportTransaction, pushCancellationTokenSource, new ContextBag()); + var message = readResult.Message; - await onMessage(pushContext).ConfigureAwait(false); - } - } - else + using (var bodyStream = message.BodyStream) { - receiveCancellationTokenSource.Cancel(); + try + { + await TryProcessingMessage(message, bodyStream, transportTransaction).ConfigureAwait(false); + } + catch (Exception exception) + { + message.BodyStream.Position = 0; + + await HandleError(exception, message, transportTransaction, 1).ConfigureAwait(false); + } } } } diff --git a/src/NServiceBus.SqlServer/Receiving/ReceiveWithReceiveOnlyTransaction.cs b/src/NServiceBus.SqlServer/Receiving/ReceiveWithReceiveOnlyTransaction.cs deleted file mode 100644 index 503c7ef4c..000000000 --- a/src/NServiceBus.SqlServer/Receiving/ReceiveWithReceiveOnlyTransaction.cs +++ /dev/null @@ -1,81 +0,0 @@ -namespace NServiceBus.Transport.SQLServer -{ - using System; - using System.Threading; - using System.Threading.Tasks; - using System.Transactions; - using Extensibility; - using Transports; - using IsolationLevel = System.Data.IsolationLevel; - - class ReceiveWithReceiveOnlyTransaction : ReceiveStrategy - { - public ReceiveWithReceiveOnlyTransaction(TransactionOptions transactionOptions, SqlConnectionFactory connectionFactory) - { - this.connectionFactory = connectionFactory; - - isolationLevel = IsolationLevelMapper.Map(transactionOptions.IsolationLevel); - } - - public async Task ReceiveMessage(TableBasedQueue inputQueue, TableBasedQueue errorQueue, CancellationTokenSource receiveCancellationTokenSource, Func onMessage) - { - using (var connection = await connectionFactory.OpenNewConnection().ConfigureAwait(false)) - using (var transaction = connection.BeginTransaction(isolationLevel)) - { - try - { - var readResult = await inputQueue.TryReceive(connection, transaction).ConfigureAwait(false); - - if (readResult.IsPoison) - { - await errorQueue.DeadLetter(readResult.PoisonMessage, connection, transaction).ConfigureAwait(false); - transaction.Commit(); - return; - } - if (!readResult.Successful) - { - transaction.Commit(); - receiveCancellationTokenSource.Cancel(); - return; - } - - var message = readResult.Message; - - using (var pushCancellationTokenSource = new CancellationTokenSource()) - using (var bodyStream = message.BodyStream) - { - var transportTransaction = new TransportTransaction(); - - //those resources are meant to be used by anyone except message dispatcher e.g. persister - transportTransaction.Set(connection); - transportTransaction.Set(transaction); - - //this indicates to MessageDispatcher that it should not reuse connection or transaction for sends - transportTransaction.Set(ReceiveOnlyTransactionMode, true); - - var pushContext = new PushContext(message.TransportId, message.Headers, bodyStream, transportTransaction, pushCancellationTokenSource, new ContextBag()); - - await onMessage(pushContext).ConfigureAwait(false); - - if (pushCancellationTokenSource.Token.IsCancellationRequested) - { - transaction.Rollback(); - return; - } - } - - transaction.Commit(); - } - catch (Exception) - { - transaction.Rollback(); - throw; - } - } - } - - IsolationLevel isolationLevel; - SqlConnectionFactory connectionFactory; - internal static string ReceiveOnlyTransactionMode = "SqlTransport.ReceiveOnlyTransactionMode"; - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/Receiving/ReceiveWithSendsAtomicWithReceiveTransaction.cs b/src/NServiceBus.SqlServer/Receiving/ReceiveWithSendsAtomicWithReceiveTransaction.cs deleted file mode 100644 index 643687d60..000000000 --- a/src/NServiceBus.SqlServer/Receiving/ReceiveWithSendsAtomicWithReceiveTransaction.cs +++ /dev/null @@ -1,77 +0,0 @@ -namespace NServiceBus.Transport.SQLServer -{ - using System; - using System.Threading; - using System.Threading.Tasks; - using System.Transactions; - using Extensibility; - using Transports; - using IsolationLevel = System.Data.IsolationLevel; - - class ReceiveWithSendsAtomicWithReceiveTransaction : ReceiveStrategy - { - public ReceiveWithSendsAtomicWithReceiveTransaction(TransactionOptions transactionOptions, SqlConnectionFactory connectionFactory) - { - this.connectionFactory = connectionFactory; - - isolationLevel = IsolationLevelMapper.Map(transactionOptions.IsolationLevel); - } - - public async Task ReceiveMessage(TableBasedQueue inputQueue, TableBasedQueue errorQueue, CancellationTokenSource receiveCancellationTokenSource, Func onMessage) - { - using (var connection = await connectionFactory.OpenNewConnection().ConfigureAwait(false)) - using (var transaction = connection.BeginTransaction(isolationLevel)) - { - try - { - var readResult = await inputQueue.TryReceive(connection, transaction).ConfigureAwait(false); - - if (readResult.IsPoison) - { - await errorQueue.DeadLetter(readResult.PoisonMessage, connection, transaction).ConfigureAwait(false); - transaction.Commit(); - return; - } - - if (!readResult.Successful) - { - transaction.Commit(); - receiveCancellationTokenSource.Cancel(); - return; - } - - var message = readResult.Message; - - using (var pushCancellationTokenSource = new CancellationTokenSource()) - using (var bodyStream = message.BodyStream) - { - var transportTransaction = new TransportTransaction(); - - transportTransaction.Set(connection); - transportTransaction.Set(transaction); - - var pushContext = new PushContext(message.TransportId, message.Headers, bodyStream, transportTransaction, pushCancellationTokenSource, new ContextBag()); - - await onMessage(pushContext).ConfigureAwait(false); - - if (pushCancellationTokenSource.Token.IsCancellationRequested) - { - transaction.Rollback(); - return; - } - } - - transaction.Commit(); - } - catch (Exception) - { - transaction.Rollback(); - throw; - } - } - } - - IsolationLevel isolationLevel; - SqlConnectionFactory connectionFactory; - } -} \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/Receiving/ReceiveWithTransactionScope.cs b/src/NServiceBus.SqlServer/Receiving/ReceiveWithTransactionScope.cs index d0123136c..01b1c820f 100644 --- a/src/NServiceBus.SqlServer/Receiving/ReceiveWithTransactionScope.cs +++ b/src/NServiceBus.SqlServer/Receiving/ReceiveWithTransactionScope.cs @@ -1,68 +1,114 @@ namespace NServiceBus.Transport.SQLServer { using System; + using System.Data.SqlClient; using System.Threading; using System.Threading.Tasks; using System.Transactions; - using Extensibility; - using Transports; class ReceiveWithTransactionScope : ReceiveStrategy { - public ReceiveWithTransactionScope(TransactionOptions transactionOptions, SqlConnectionFactory connectionFactory) + public ReceiveWithTransactionScope(TransactionOptions transactionOptions, SqlConnectionFactory connectionFactory, FailureInfoStorage failureInfoStorage) { this.transactionOptions = transactionOptions; this.connectionFactory = connectionFactory; + this.failureInfoStorage = failureInfoStorage; } - public async Task ReceiveMessage(TableBasedQueue inputQueue, TableBasedQueue errorQueue, CancellationTokenSource receiveCancellationTokenSource, Func onMessage) + public override async Task ReceiveMessage(CancellationTokenSource receiveCancellationTokenSource) { - using (var scope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled)) - using (var connection = await connectionFactory.OpenNewConnection().ConfigureAwait(false)) + Message message = null; + try { - var readResult = await inputQueue.TryReceive(connection, null).ConfigureAwait(false); + using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, transactionOptions, TransactionScopeAsyncFlowOption.Enabled)) + using (var connection = await connectionFactory.OpenNewConnection().ConfigureAwait(false)) + { + message = await TryReceive(connection, receiveCancellationTokenSource).ConfigureAwait(false); + + if (message == null) + { + // The message was received but is not fit for processing (e.g. was DLQd). + // In such a case we still need to commit the transport tx to remove message + // from the queue table. + scope.Complete(); + return; + } - if (readResult.IsPoison) + connection.Close(); + + if (await TryProcess(message, PrepareTransportTransaction()).ConfigureAwait(false)) + { + scope.Complete(); + } + } + } + catch (Exception exception) + { + if (message == null) { - await errorQueue.DeadLetter(readResult.PoisonMessage, connection, null).ConfigureAwait(false); - scope.Complete(); - return; + throw; } + failureInfoStorage.RecordFailureInfoForMessage(message.TransportId, exception); + } + } - if (!readResult.Successful) - { - scope.Complete(); + async Task TryReceive(SqlConnection connection, CancellationTokenSource receiveCancellationTokenSource) + { + var receiveResult = await InputQueue.TryReceive(connection, null).ConfigureAwait(false); - receiveCancellationTokenSource.Cancel(); + if (receiveResult.IsPoison) + { + await ErrorQueue.DeadLetter(receiveResult.PoisonMessage, connection, null).ConfigureAwait(false); + return null; + } - return; - } + if (!receiveResult.Successful) + { + // No result or message expired. + receiveCancellationTokenSource.Cancel(); + return null; + } - var message = readResult.Message; + return receiveResult.Message; + } - using (var pushCancellationTokenSource = new CancellationTokenSource()) - using (var bodyStream = message.BodyStream) - { - connection.Close(); + TransportTransaction PrepareTransportTransaction() + { + var transportTransaction = new TransportTransaction(); - var transportTransaction = new TransportTransaction(); - transportTransaction.Set(Transaction.Current); + //those resources are meant to be used by anyone except message dispatcher e.g. persister + transportTransaction.Set(Transaction.Current); - var pushContext = new PushContext(message.TransportId, message.Headers, bodyStream, transportTransaction, pushCancellationTokenSource, new ContextBag()); + return transportTransaction; + } - await onMessage(pushContext).ConfigureAwait(false); + async Task TryProcess(Message message, TransportTransaction transportTransaction) + { + FailureInfoStorage.ProcessingFailureInfo failure; + if (failureInfoStorage.TryGetFailureInfoForMessage(message.TransportId, out failure)) + { + var errorHandlingResult = await HandleError(failure.Exception, message, transportTransaction, failure.NumberOfProcessingAttempts).ConfigureAwait(false); - if (pushCancellationTokenSource.Token.IsCancellationRequested) - { - return; - } + if (errorHandlingResult == ErrorHandleResult.Handled) + { + failureInfoStorage.ClearFailureInfoForMessage(message.TransportId); + return true; } + } - scope.Complete(); + using (var bodyStream = message.BodyStream) + { + var messageProcessed = await TryProcessingMessage(message, bodyStream, transportTransaction).ConfigureAwait(false); + if (messageProcessed) + { + failureInfoStorage.ClearFailureInfoForMessage(message.TransportId); + } + return messageProcessed; } } TransactionOptions transactionOptions; SqlConnectionFactory connectionFactory; + FailureInfoStorage failureInfoStorage; } } \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/Sending/IQueueDispatcher.cs b/src/NServiceBus.SqlServer/Sending/IQueueDispatcher.cs index 2e9bcb4b0..cc8551281 100644 --- a/src/NServiceBus.SqlServer/Sending/IQueueDispatcher.cs +++ b/src/NServiceBus.SqlServer/Sending/IQueueDispatcher.cs @@ -2,11 +2,10 @@ namespace NServiceBus.Transport.SQLServer { using System.Collections.Generic; using System.Threading.Tasks; - using Extensibility; interface IQueueDispatcher { - Task DispatchAsNonIsolated(HashSet operations, ContextBag context); + Task DispatchAsNonIsolated(HashSet operations, TransportTransaction transportTransaction); Task DispatchAsIsolated(HashSet operations); } diff --git a/src/NServiceBus.SqlServer/Sending/MessageDispatcher.cs b/src/NServiceBus.SqlServer/Sending/MessageDispatcher.cs index 5b6effb6b..745c78b3c 100644 --- a/src/NServiceBus.SqlServer/Sending/MessageDispatcher.cs +++ b/src/NServiceBus.SqlServer/Sending/MessageDispatcher.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Extensibility; - using Transports; + using Transport; class MessageDispatcher : IDispatchMessages { @@ -15,10 +15,10 @@ public MessageDispatcher(IQueueDispatcher dispatcher, QueueAddressParser address } // We need to check if we can support cancellation in here as well? - public async Task Dispatch(TransportOperations operations, ContextBag context) + public async Task Dispatch(TransportOperations operations, TransportTransaction transportTransaction, ContextBag context) { await Dispatch(operations, dispatcher.DispatchAsIsolated, DispatchConsistency.Isolated).ConfigureAwait(false); - await Dispatch(operations, ops => dispatcher.DispatchAsNonIsolated(ops, context), DispatchConsistency.Default).ConfigureAwait(false); + await Dispatch(operations, ops => dispatcher.DispatchAsNonIsolated(ops, transportTransaction), DispatchConsistency.Default).ConfigureAwait(false); } Task Dispatch(TransportOperations operations, Func, Task> dispatchMethod, DispatchConsistency dispatchConsistency) diff --git a/src/NServiceBus.SqlServer/Sending/MessageWithAddress.cs b/src/NServiceBus.SqlServer/Sending/MessageWithAddress.cs index d17a58a2f..8638f2775 100644 --- a/src/NServiceBus.SqlServer/Sending/MessageWithAddress.cs +++ b/src/NServiceBus.SqlServer/Sending/MessageWithAddress.cs @@ -1,6 +1,6 @@ namespace NServiceBus.Transport.SQLServer { - using Transports; + using Transport; class MessageWithAddress { diff --git a/src/NServiceBus.SqlServer/Sending/TableBasedQueueDispatcher.cs b/src/NServiceBus.SqlServer/Sending/TableBasedQueueDispatcher.cs index d74b1826a..2e57c32f3 100644 --- a/src/NServiceBus.SqlServer/Sending/TableBasedQueueDispatcher.cs +++ b/src/NServiceBus.SqlServer/Sending/TableBasedQueueDispatcher.cs @@ -4,8 +4,7 @@ namespace NServiceBus.Transport.SQLServer using System.Data.SqlClient; using System.Threading.Tasks; using System.Transactions; - using Extensibility; - using Transports; + using Transport; class TableBasedQueueDispatcher : IQueueDispatcher { @@ -31,16 +30,14 @@ public async Task DispatchAsIsolated(HashSet operations) } } - public async Task DispatchAsNonIsolated(HashSet operations, ContextBag context) + public async Task DispatchAsNonIsolated(HashSet operations, TransportTransaction transportTransaction) { if (operations.Count == 0) { return; } - TransportTransaction transportTransaction; - var transportTransactionExists = context.TryGet(out transportTransaction); - if (transportTransactionExists == false || InReceiveOnlyTransportTransactionMode(transportTransaction)) + if (InReceiveWithNoTransactionMode(transportTransaction) || InReceiveOnlyTransportTransactionMode(transportTransaction)) { await DispatchOperationsWithNewConnectionAndTransaction(operations).ConfigureAwait(false); return; @@ -100,10 +97,21 @@ static async Task Send(HashSet operations, SqlConnection con } } + static bool InReceiveWithNoTransactionMode(TransportTransaction transportTransaction) + { + SqlTransaction nativeTransaction; + transportTransaction.TryGet(out nativeTransaction); + + Transaction ambientTransaction; + transportTransaction.TryGet(out ambientTransaction); + + return nativeTransaction == null && ambientTransaction == null; + } + static bool InReceiveOnlyTransportTransactionMode(TransportTransaction transportTransaction) { bool inReceiveMode; - return transportTransaction.TryGet(ReceiveWithReceiveOnlyTransaction.ReceiveOnlyTransactionMode, out inReceiveMode); + return transportTransaction.TryGet(ReceiveWithNativeTransaction.ReceiveOnlyTransactionMode, out inReceiveMode); } } } \ No newline at end of file diff --git a/src/NServiceBus.SqlServer/Sending/UsingV2ConfigurationChecker.cs b/src/NServiceBus.SqlServer/Sending/UsingV2ConfigurationChecker.cs index bf76ea5fe..c9bc153a9 100644 --- a/src/NServiceBus.SqlServer/Sending/UsingV2ConfigurationChecker.cs +++ b/src/NServiceBus.SqlServer/Sending/UsingV2ConfigurationChecker.cs @@ -3,7 +3,7 @@ using System.Configuration; using System.Linq; using Logging; - using Transports; + using Transport; class UsingV2ConfigurationChecker { diff --git a/src/NServiceBus.SqlServer/SqlServerTransport.cs b/src/NServiceBus.SqlServer/SqlServerTransport.cs index d25354339..59059676d 100644 --- a/src/NServiceBus.SqlServer/SqlServerTransport.cs +++ b/src/NServiceBus.SqlServer/SqlServerTransport.cs @@ -4,7 +4,7 @@ namespace NServiceBus using System.Data.SqlClient; using System.Threading.Tasks; using Settings; - using Transports; + using Transport; using Transport.SQLServer; /// @@ -43,7 +43,7 @@ bool LegacyMultiInstanceModeTurnedOn(SettingsHolder settings) /// /// /// - protected override TransportInfrastructure Initialize(SettingsHolder settings, string connectionString) + public override TransportInfrastructure Initialize(SettingsHolder settings, string connectionString) { var addressParser = CreateAddressParser(settings); diff --git a/src/NServiceBus.SqlServer/SqlServerTransportInfrastructure.cs b/src/NServiceBus.SqlServer/SqlServerTransportInfrastructure.cs index 9a00683c4..fdcb4a392 100644 --- a/src/NServiceBus.SqlServer/SqlServerTransportInfrastructure.cs +++ b/src/NServiceBus.SqlServer/SqlServerTransportInfrastructure.cs @@ -9,7 +9,7 @@ namespace NServiceBus.Transport.SQLServer using Performance.TimeToBeReceived; using Routing; using Settings; - using Transports; + using Transport; class SqlServerTransportInfrastructure : TransportInfrastructure { @@ -92,17 +92,17 @@ ReceiveStrategy SelectReceiveStrategy(TransportTransactionMode minimumConsistenc { if (minimumConsistencyGuarantee == TransportTransactionMode.TransactionScope) { - return new ReceiveWithTransactionScope(options, connectionFactory); + return new ReceiveWithTransactionScope(options, connectionFactory, new FailureInfoStorage(10000)); } if (minimumConsistencyGuarantee == TransportTransactionMode.SendsAtomicWithReceive) { - return new ReceiveWithSendsAtomicWithReceiveTransaction(options, connectionFactory); + return new ReceiveWithNativeTransaction(options, connectionFactory, new FailureInfoStorage(10000)); } if (minimumConsistencyGuarantee == TransportTransactionMode.ReceiveOnly) { - return new ReceiveWithReceiveOnlyTransaction(options, connectionFactory); + return new ReceiveWithNativeTransaction(options, connectionFactory, new FailureInfoStorage(10000), transactionForReceiveOnly: true); } return new ReceiveWithNoTransaction(connectionFactory); @@ -155,7 +155,7 @@ public override string ToTransportAddress(LogicalAddress logicalAddress) { var nonEmptyParts = new[] { - logicalAddress.EndpointInstance.Endpoint.ToString(), + logicalAddress.EndpointInstance.Endpoint, logicalAddress.Qualifier, logicalAddress.EndpointInstance.Discriminator }.Where(p => !string.IsNullOrEmpty(p)); diff --git a/src/NServiceBus.SqlServer/packages.config b/src/NServiceBus.SqlServer/packages.config index 88c181f58..e05a3fb06 100644 --- a/src/NServiceBus.SqlServer/packages.config +++ b/src/NServiceBus.SqlServer/packages.config @@ -3,7 +3,7 @@ - +