Skip to content

psandler/NServiceBus.SqlServer.Samples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NServiceBus.SqlServer.Samples


This repository contains the Samples for the SqlServer transport. The samples include needed references for SqlServer. The endpoints are configured to use SqlServer as its transport. For example:

  public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, UsingTransport<SqlServer> { }

The app.config provides the necessary connection information needed to communicate to SQL server. For example:

<connectionStrings>
  <add name="NServiceBus/Transport" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=nservicebus;Integrated Security=True" />
</connectionStrings>

##VideoStore.SqlServer

This sample implements the following workflow of a fictional video store. Users can order videos from the website. Once orders are submitted, there is a window of time allocated for handling cancellations due to buyer's remorse. Once the order has been accepted, they are provisioned and made available for download. In implementing the above workflow various aspects are highlighted:

  • The Sales endpoint illustrates the use of the Saga pattern to handle the buyer's remorse scenario.
    The CustomerRelations endpoint illustrates how in-memory events (domain events pattern) can be defined and subscribed to.

  • The request/response pattern is illustrated for the video provisioning between the ContentManagement endpoint and the Operations Endpoint. The ECommerce endpoint is implemented as an ASP.NET MVC4 application which uses SignalR to show feedback to the user.

  • This sample also illustrates the use of Unobtrusive message conventions to let NServiceBus know in order to identify commands, events and messages defined as POCOs which avoids having to add a reference to the NServiceBus libraries in the message definition dlls.

  • The use of message headers and message mutator is also illustrated when the user clicks on the Check box on the ECommerce web page, which conveniently stops at the predefined breakpoints in the message handler code on the endpoints.

  • The use of encryption is illustrated by passing in the Credit Card number and the Expiration date from the ECommerce web site. The Unobtrusive conventions defined in the ECommerce endpoint show how to treat certain properties as encrypted. Both the ECommerce and the Sales endpoint is setup for RijndaelEncryption and the encryption key is provided in the config file. If the messages are inspected in the queue, both the Credit Card number and the Expiration Date will show the encrypted values.

##Sql Bridge (Transport Integration)

This sample shows how to setup a sql subscriber so it can subscribe to events from a Version 3.3 MSMQ publisher. The solution comprises of these 5 projects

Events

MsmqPublisher

MsmqSubscriber Uses the latest version of NServiceBus.Host, uses MsmqTransport and subscribes to the events from the MsmqPublisher

SqlBridge

How does the advanced satellite work?

SqlSubscriber

NOTE

Both the SqlSubscriber and the SqlBridge has asm redirects, so that it can use the latest version of NServiceBus. See: https://github.com/Particular/NServiceBus.SqlServer.Samples/tree/master/SqlBridge/SqlSubscriber/App.config#L26-37 https://github.com/Particular/NServiceBus.SqlServer.Samples/tree/master/SqlBridge/SqlBridge/App.config#L28-39

To summarize:

  1. Creating a new transactional queue that the MSMQ publisher will be sending its events to.

  2. In the original MSMQ Publisher's Subscriptions storage, in addition to its list of all its current subscribers, has an additional entry for the queue that the SqlBridge will be listening to.

  3. The Sql bridge endpoint (setup to read from that input queue) processes that message and publishes the event.

  4. The Sql Subscriber, subscribes to the SqlBridge.

Once this is working, the steps of creating the queue and adding the additional subscription message in the subscriptions queue of the publisher can be automated for deployment.

About

Samples for SqlServer transport

Resources

Stars

Watchers

Forks

Packages

No packages published