public static UnicastBus CreateBus() { SettingsHolder.Reset(); Configure.Serialization.Xml(); Configure.Features.Disable <SecondLevelRetries>(); Configure.Features.Disable <Audit>(); Configure.Transactions.Disable(); Configure.Transactions.Advanced(s => s.DisableDistributedTransactions()); IBus bus = Configure.With().DefineEndpointName("nservicestub") .Log4Net() .DefaultBuilder() .UseTransport <Msmq>() .PurgeOnStartup(false) .UnicastBus() .ImpersonateSender(false) .SendOnly(); return(bus as UnicastBus); }
public void SetUp() { HandlerInvocationCache.Clear(); SettingsHolder.Reset(); SettingsHolder.SetDefault("Endpoint.SendOnly", false); Transport = new FakeTransport(); FuncBuilder = new FuncBuilder(); Configure.GetEndpointNameAction = () => "TestEndpoint"; const string localAddress = "endpointA"; MasterNodeAddress = new Address(localAddress, "MasterNode"); subscriptionPredicatesEvaluator = new SubscriptionPredicatesEvaluator(); router = new StaticMessageRouter(KnownMessageTypes()); handlerRegistry = new MessageHandlerRegistry(); MessageMetadataRegistry = new MessageMetadataRegistry { DefaultToNonPersistentMessages = false }; try { Address.InitializeLocalAddress(localAddress); } catch // intentional { } MessageSerializer = new XmlMessageSerializer(MessageMapper); ExtensionMethods.GetStaticOutgoingHeadersAction = () => MessageHeaderManager.staticHeaders; gatewayAddress = MasterNodeAddress.SubScope("gateway"); messageSender = MockRepository.GenerateStub <ISendMessages>(); subscriptionStorage = new FakeSubscriptionStorage(); subscriptionManager = new MessageDrivenSubscriptionManager { Builder = FuncBuilder, MessageSender = messageSender, SubscriptionStorage = subscriptionStorage }; FuncBuilder.Register <IMutateOutgoingTransportMessages>(() => headerManager); FuncBuilder.Register <IMutateIncomingMessages>(() => new FilteringMutator { SubscriptionPredicatesEvaluator = subscriptionPredicatesEvaluator }); FuncBuilder.Register <IMutateOutgoingTransportMessages>(() => new SentTimeMutator()); FuncBuilder.Register <IMutateIncomingTransportMessages>(() => subscriptionManager); FuncBuilder.Register <DefaultDispatcherFactory>(() => new DefaultDispatcherFactory()); FuncBuilder.Register <EstimatedTimeToSLABreachCalculator>(() => SLABreachCalculator); FuncBuilder.Register <ExtractIncomingPrincipal>(() => new WindowsImpersonator()); unicastBus = new UnicastBus { MasterNodeAddress = MasterNodeAddress, MessageSerializer = MessageSerializer, Builder = FuncBuilder, MessageSender = messageSender, Transport = Transport, MessageMapper = MessageMapper, MessagePublisher = new StorageDrivenPublisher { MessageSender = messageSender, SubscriptionStorage = subscriptionStorage }, MessageDeferrer = new TimeoutManagerDeferrer { MessageSender = messageSender, TimeoutManagerAddress = MasterNodeAddress.SubScope("Timeouts") }, SubscriptionManager = subscriptionManager, MessageMetadataRegistry = MessageMetadataRegistry, SubscriptionPredicatesEvaluator = subscriptionPredicatesEvaluator, HandlerRegistry = handlerRegistry, MessageRouter = router }; bus = unicastBus; FuncBuilder.Register <IMutateOutgoingTransportMessages>(() => new CausationMutator { Bus = bus }); FuncBuilder.Register <IBus>(() => bus); ExtensionMethods.SetHeaderAction = headerManager.SetHeader; }
public void Setup() { SettingsHolder.Reset(); }
public void SetUp() { transportDefinition = new Msmq(); HandlerInvocationCache.Clear(); SettingsHolder.Reset(); SettingsHolder.SetDefault("Endpoint.SendOnly", false); Transport = new FakeTransport(); FuncBuilder = new FuncBuilder(); Configure.GetEndpointNameAction = () => "TestEndpoint"; subscriptionPredicatesEvaluator = new SubscriptionPredicatesEvaluator(); router = new StaticMessageRouter(KnownMessageTypes()); handlerRegistry = new MessageHandlerRegistry(); MessageMetadataRegistry = new MessageMetadataRegistry { DefaultToNonPersistentMessages = false }; MessageSerializer = new XmlMessageSerializer(MessageMapper); //ExtensionMethods.GetStaticOutgoingHeadersAction = () => MessageHeaderManager.staticHeaders; gatewayAddress = MasterNodeAddress.SubScope("gateway"); messageSender = MockRepository.GenerateStub <ISendMessages>(); subscriptionStorage = new FakeSubscriptionStorage(); subscriptionManager = new MessageDrivenSubscriptionManager { Builder = FuncBuilder, MessageSender = messageSender, SubscriptionStorage = subscriptionStorage }; var pipelineBuilder = new PipelineBuilder(FuncBuilder); pipelineFactory = new PipelineExecutor(FuncBuilder, pipelineBuilder); FuncBuilder.Register <IMessageSerializer>(() => MessageSerializer); FuncBuilder.Register <ISendMessages>(() => messageSender); FuncBuilder.Register <MessageAuditer>(() => new MessageAuditer()); FuncBuilder.Register <LogicalMessageFactory>(() => new LogicalMessageFactory()); FuncBuilder.Register <IMutateIncomingMessages>(() => new FilteringMutator { SubscriptionPredicatesEvaluator = subscriptionPredicatesEvaluator }); FuncBuilder.Register <IMutateIncomingTransportMessages>(() => subscriptionManager); FuncBuilder.Register <EstimatedTimeToSLABreachCalculator>(() => SLABreachCalculator); FuncBuilder.Register <MessageMetadataRegistry>(() => MessageMetadataRegistry); FuncBuilder.Register <IMessageHandlerRegistry>(() => handlerRegistry); FuncBuilder.Register <ExtractIncomingPrincipal>(() => new WindowsImpersonator()); FuncBuilder.Register <IMessageMapper>(() => MessageMapper); FuncBuilder.Register <ExtractLogicalMessagesBehavior>(() => new ExtractLogicalMessagesBehavior { MessageSerializer = MessageSerializer, MessageMetadataRegistry = MessageMetadataRegistry, }); FuncBuilder.Register <ImpersonateSenderBehavior>(() => new ImpersonateSenderBehavior { ExtractIncomingPrincipal = MockRepository.GenerateStub <ExtractIncomingPrincipal>() }); FuncBuilder.Register <CreatePhysicalMessageBehavior>(() => new CreatePhysicalMessageBehavior()); FuncBuilder.Register <PipelineBuilder>(() => pipelineBuilder); FuncBuilder.Register <PipelineExecutor>(() => pipelineFactory); FuncBuilder.Register <TransportDefinition>(() => transportDefinition); var messagePublisher = new StorageDrivenPublisher { MessageSender = messageSender, SubscriptionStorage = subscriptionStorage }; var deferrer = new TimeoutManagerDeferrer { MessageSender = messageSender, TimeoutManagerAddress = MasterNodeAddress.SubScope("Timeouts") }; FuncBuilder.Register <IDeferMessages>(() => deferrer); FuncBuilder.Register <IPublishMessages>(() => messagePublisher); unicastBus = new UnicastBus { MasterNodeAddress = MasterNodeAddress, Builder = FuncBuilder, MessageSender = messageSender, Transport = Transport, MessageMapper = MessageMapper, SubscriptionManager = subscriptionManager, SubscriptionPredicatesEvaluator = subscriptionPredicatesEvaluator, MessageRouter = router }; bus = unicastBus; FuncBuilder.Register <IMutateOutgoingTransportMessages>(() => new CausationMutator { Bus = bus }); FuncBuilder.Register <IBus>(() => bus); FuncBuilder.Register <UnicastBus>(() => unicastBus); new HeaderBootstrapper { Builder = FuncBuilder }.SetupHeaderActions(); }