static void TestProcessEvent() { SubscriptionClient subscriptionClient = SubscriptionClient.CreateFromConnectionString( serviceBusConnectionString, orderEventTopicPath, orderEventSubscription ); SubscriptionReceiver receiver = new SubscriptionReceiver( subscriptionClient ); ITextSerializer serializer = new JsonTextSerializer(); EventProcessor eventProcessor = new EventProcessor( receiver, serializer ); eventProcessor.Register( new OrderEventHandler() ); eventProcessor.Start(); }
static void TestProcessCommand() { SubscriptionClient subscriptionClient = SubscriptionClient.CreateFromConnectionString( serviceBusConnectionString, commandTopicPath, commandHandlerSubscription ); SubscriptionReceiver receiver = new SubscriptionReceiver( subscriptionClient ); ITextSerializer serializer = new JsonTextSerializer(); CommandProcessor orderCommandProcessor = new CommandProcessor( receiver, serializer ); orderCommandProcessor.Register( new OrderCommandHandler() ); orderCommandProcessor.Start(); }
static void TestSendEvent() { TopicClient eventClient = TopicClient.CreateFromConnectionString( serviceBusConnectionString, orderEventTopicPath ); TopicSender sender = new TopicSender( eventClient ); ITextSerializer serializer = new JsonTextSerializer(); EventBus eventBus = new EventBus( sender, serializer ); eventBus.Publish( new Envelope<IEvent>( new OrderPlaced() { ProductId = 1, Quantity = 2, SourceId = Guid.NewGuid() } ) ); }
static void TestSendCommand() { TopicClient commandClient = TopicClient.CreateFromConnectionString( serviceBusConnectionString, commandTopicPath ); TopicSender sender = new TopicSender( commandClient ); //sender.Send( () => { return new BrokeredMessage( "Hello CQRS" ); } ); ITextSerializer serializer = new JsonTextSerializer(); CommandBus bus = new CommandBus( sender, serializer ); bus.Send( new Envelope<ICommand>( new PlaceOrder() { ProductId = 1, Quantity = 10 } ) ); }