NServiceBus Modeling Tools for Visual Studio from NServiceBus Ltd. on Vimeo.
Monday, October 31, 2011
NServiceBus Modeling Tools Video
I just gave this a look and the tools really lower the barrier to entry to "getting on the bus". I'm going to take some time this week and give it a full evaluation and I'll post that back here. For now, enjoy the video.
Thursday, July 21, 2011
The Great Worker Pile Up Problem: Solved!
In our configuration of the Distributor pattern, we have the Distributor clustered across multiple VMs. We also run Workers on separate nodes in the same cluster. We are doing this so that we can deploy the same image to all nodes. With this configuration any Distributor/Worker can move from one node to the other in case of a failure. With all this sliding of nodes around we ran into one main issue.
Everything worked great up until we had the big pile up. What would happen is we would intentionally drop all the nodes in succession until we got down to one node. Usually this node would have the Distributor already there and Worker1 would slide over. No problems. When Worker2 slid over to that node all of a sudden one of the Workers would take itself out of business, all the work would move to the other Worker and then we'd have a couple messages disappear. Disappear temporarily that is. Eventually they would come back and be processed.
We initially thought this was due to MSDTC since we saw messages that weren't get ack'd hanging out. After chasing this awhile we then figured it must be some networking issue. Like just about any clustered VM we have 2 NICs configured on the VM, one for the SAN and one for everything else. Come to find out when the last Worker slid over, it was picking up the NIC for the SAN and not the general network. Therefore the messages weren't getting ack'd, but eventually they'd find their way back.
We tried setting the priority of the NICs and so on to no avail. After speaking with MS, we ended up pinning the IPs of the local machines in the registry to the correct network interface. We also had to do this on the clustered services as well. Now when the nodes slide about the local IPs don't change and we have a script that the services depend on that updates the clustered IPs if necessary(like when you change data centers).
I'd like to that our team for being persistent and finally tracking this one down. Now we can deploy the same image to all nodes and have them move about freely. Everything works as designed with full load balancing.
Friday, May 6, 2011
Introducing NServiceBus Visual Studio Templates
I really got tired of creating the same projects over and over so I decided to create some templates. I packaged them up and put them on the Visual Studio Gallery: http://visualstudiogallery.msdn.microsoft.com/9546d382-7ffa-4fb8-8c0f-b7825d5fd085
Right now it only includes a few project templates and a few items. If you are using the project templates there is a custom wizard that will prompt you for a path to the NSB binaries. This will auto adjust the HintPath in the project file to point to that directory.
I'm planning on adding more endpoints and some complete solutions in the near future. Let me know what you are looking for via the gallery so I can keep track of it there.
Right now it only includes a few project templates and a few items. If you are using the project templates there is a custom wizard that will prompt you for a path to the NSB binaries. This will auto adjust the HintPath in the project file to point to that directory.
I'm planning on adding more endpoints and some complete solutions in the near future. Let me know what you are looking for via the gallery so I can keep track of it there.
Wednesday, April 27, 2011
More Reasons Working with NServiceBus is Just Easier than WCF over MSMQ
We have some teams that went down the route of using WCF over MSMQ. Using a durable transport was the right thing to do for their process(accepting orders). We ran into a few issues along the way and had we used NSB to start with, we would have just avoided them.
IIS/WAS Hosting
We *thought* this would be a no brainer, but it really wasn't. Come to find out, if something goes wrong or your app pool recycles(every 24 hours or so guaranteed), you need to "warm-up" the service before it accepts messages. So Microsoft's answer to this is a warm-up extension to IIS or to host the service as a Windows Service. I think hosting in a Windows Service is a much better idea anyway as we weren't really using any of the IIS features anyway on the MSMQ transport. The thing is, had we used NSB out of the box we'd never have encountered such an issue.
Windows Service Hosting
Hosting this way gets you out of the warm-up jam. Unfortunately there is another problem if your shop uses SCOM like we do for monitoring. We haven't been able to get SCOM to monitor on the poison sub queues that WCF creates to put bad messages. We have some choices, which are call on MS to get this to work, build our own monitor, or just switch to NSB. I prefer the latter as we already have plenty of endpoints that we monitor just fine.
Summary
If you are thinking of using WCF over MSMQ make sure you host in a windows service and have a plan for when bad things happen. To us it makes sense to just retrofit those endpoints to NSB and avoid all the issues completely.
IIS/WAS Hosting
We *thought* this would be a no brainer, but it really wasn't. Come to find out, if something goes wrong or your app pool recycles(every 24 hours or so guaranteed), you need to "warm-up" the service before it accepts messages. So Microsoft's answer to this is a warm-up extension to IIS or to host the service as a Windows Service. I think hosting in a Windows Service is a much better idea anyway as we weren't really using any of the IIS features anyway on the MSMQ transport. The thing is, had we used NSB out of the box we'd never have encountered such an issue.
Windows Service Hosting
Hosting this way gets you out of the warm-up jam. Unfortunately there is another problem if your shop uses SCOM like we do for monitoring. We haven't been able to get SCOM to monitor on the poison sub queues that WCF creates to put bad messages. We have some choices, which are call on MS to get this to work, build our own monitor, or just switch to NSB. I prefer the latter as we already have plenty of endpoints that we monitor just fine.
Summary
If you are thinking of using WCF over MSMQ make sure you host in a windows service and have a plan for when bad things happen. To us it makes sense to just retrofit those endpoints to NSB and avoid all the issues completely.
Wednesday, April 6, 2011
NServiceBus Customization Part 2: IWantToRunAtStartup
When NSB starts up it will look for all implementors of the interface IWantToRunAtStartup and call their Run() methods. When NSB spins down it will also call the Stop() method of the same interface. This gives us a good place to run expensive one time initialization code or to tweak out the bus prior to getting going. A common usage of this interface is for the manual subscription to specific message types:
public IBus Bus { get; set; }
#region IWantToRunAtStartup Members
public void Run()
{
this.Bus.Subscribe<IProductUpdatedEvent>();
this.Bus.Subscribe<IProductCreatedEvent>();
}
public void Stop()
{
this.Bus.Unsubscribe<IProductUpdatedEvent>();
this.Bus.Unsubscribe<IProductCreatedEvent>();
}
#endregion
One thing that I would caution against doing in the Run() method is not exiting the method. I've seen cases where someone will go into an infinite loop and never exit Run(). Typically this is done to perform a task on a given interval. There are much better ways to do this, mostly commonly you can put a Timer into the container and wire into its events. If you never leave the Run() method, the Bus doesn't ever really startup and you will get some odd results.
Friday, April 1, 2011
NServiceBus 3.0 Details
The following content is paraphrased from the Yahoo Group:
Second, there's the Data Bus feature that Andreas Öhlund (http://andreasohlund.net/) has been working on. As many of you know, most queuing transports have a limit on the size of message they can deliver - with MSMQ this is 4MB, with Azure it's 8KB. The Data Bus will allow you to transmit messages of an almost arbitrary size as it transmits the "data" portion on a separate infrastructure than the actual message. This is currently implemented using the file system but will be done using a database (RavenDB) as well - more on that in just a minute. The thing is that between remote sites, there often isn't the ability to have a shared file system or database, as the sites may not always be connected to each other. In order to resolve this issue, Andreas is also working on the Gateway to make it Data Bus aware - that and also able to support transports other than HTTP, like TCP and FTP. Third, there's the Azure integration that Yves Goeleven has been driving for some time now. For all those of you who've been looking for a simpler developer experience on Azure, Yves has really done it, abstracting away almost all of the underlying complexity behind your standard NServiceBus interfaces. You can find out more about this through his series of blog posts here:http://cloudshaper.wordpress.com/
The integration of RavenDB will enable us to stop merging NHibernate, but we'll still integrate with it out of the box. This will make it much easier for you to plug in your own version of NH instead of ours. Fifth is the Timeout Manager - one of the areas of NServiceBus that hasn't been as strong as the others. Jonathan Oliver (http://blog.jonathanoliver.com/ who has been ramping up his involvement over the past while) will be using our new RavenDB persistence to replace the use the input queue, which will dramatically increase the performance and robustness of the Timeout Manager.
Finally, the 3.0 release schedule looks something like this - Alpha by the end of April (primarily focusing on APIs), Beta in July, and a Release (or at least release candidate you can go live with) in September.
First of all, I'd like to talk about the thing that will influence you the most. We're making every effort to make the use of NServiceBus (particularly it's auxiliary processes like the Timeout Manager, Distributor, and Gateway) much, much easier. What this means is removing much of complexity of using these capabilities by hosting them within the same host as your own process, but don't worry, we'll make it easy for you to turn them on and off using profiles. This will enable us to configure all the routing to these processes for you, but if you want, you can always go back to the manual approach in version 2.x. This is where I'll be investing most of my time.
Fourth is RavenDB integration. I'm happy to say that a licensing agreement has been reached that will allow users of NServiceBus Standard Edition to use RavenDB for things like Subscription Storage and Saga Persistence at no additional cost. This will save you from having to haggle with your DBAs anytime you want production-ready storage for NServiceBus - it'll give you a much more cohesive deployment without worrying about overloading your existing relational databases. I'm happy to welcome one of our newest committers, Jonathan Matheus (http://www.linkedin.com/in/jonathanmatheus), who is making this happen.
We're also looking at stronger Visual Studio integration, possibly to the level of providing model-driven code/config generation. We'll see if it's feasible to get that done within the 3.0 timeframe, or whether that will be delivered as a separate download afterwards.
Sunday, March 27, 2011
NServiceBus Customization Part 1: IWantCustomInitialization
In this first part we're going to explore how to take control of NServiceBus during the initialization phase. By implementing the IWantCustomInitialization interface, you take full control away from NSB Roles. What is a Role? A Role tells an Endpoint how to participate on the bus. Typical Roles are the Server, Client, and Publisher Roles. These are defined by a class in your project, typically named EndpointConfig. A Role will define certain aspects of behavior, like whether or not it can receive messages(AsA_Client).
Most of the time you don't end up ever overriding the default behavior of the Roles. When you do, you'll implement the IWantCustomInitialization interface and have full control over NServiceBus. You will use the static NServiceBus.Configure class to get things going. Let's take a look at all the options(as of 2.5, 3.0 follows):
Most of the time you don't end up ever overriding the default behavior of the Roles. When you do, you'll implement the IWantCustomInitialization interface and have full control over NServiceBus. You will use the static NServiceBus.Configure class to get things going. Let's take a look at all the options(as of 2.5, 3.0 follows):
- .With()/.WithWeb() - these first methods give you the ability to control assembly scanning. When NSB fires up, it will scan the bin directory by default. This gives you control over what gets scanned. You can provide a list of Assemblies, a list of Types, or a path. You'll want to use the WithWeb() version if you are using NSB with ASP.NET.
- NServiceBus.AllAssemblies - This class allows you to provide a list of assemblies not to load. An example of this would be "AllAssemblies.Except( "Assembly1" ).And("Assembly2")".
- .Synchronization() - tells NSB that message processing with occur in a synchronization domain. This is useful for rich client applications where you need to marshal from a background thread back to the UI.
- .DefaultBuilder() or .MyContainerOfChoiceBuilder() - this next set of methods controls the container. You can take the default container(AutoFac as of 2.5) or specify your own. You'll need to include the builder implementation for your container as well as specify an instance of your container.
- .UnicastBus() - use unicast messaging
- DoNotAutoSubscribe() - do not auto subscribe to a Publisher's messages
- ForwardReceivedMessagesTo( String ) - forward all messages to another endpoint. This is helpful if you want to do some auditing.
- LoadMessageHandlers() - tells the bus to scan and load message handlers. There are a couple interesting variants on this method:
- LoadMessageHandlers<TFirst> - tells the bus to load the handlers but load the assembly where TFirst resides before the rest
- LoadMessageHandlers<T>( First<T> ) - load the handlers and specifies that the handlers in the given order should go first. To use the First class to specify ordering, it has 2 methods, "Then" and "AndThen". A typical usages would be "First<IHandler1>.Then<IHandler2>().AndThen<IHandler3>()"
- PropagateReturnAddressOnSend( Boolean ) - receivers of the messages sent by this endpoint will see the address of the incoming messages
- .XmlSerializer() or .BinarySerializer() - specify the serialization technique you'd like to use.
- .CustomConfigurationSource( IConfigurationSource source ) - if you would rather not use the standard app.config file or its sections for Administrative configuration, you are welcome to use your own. Simply implement the IConfigurationSource interface and you are on your way.
- .MsmqTransport() - tells NSB to use MSMQ as the underlying communication mechanism. This may be swapped out in favor of other transports. Along with this setting, you can configure a few things underneath it:
- .DoNotCreateQueues() - don't try to create queues if they don't exist
- .IsolationLevel( IsolationLevel ) - the isolation level of the transaction that MSMQ uses. You may consider tweaking this for performance reasons or otherwise.
- .IsTransactional( Boolean ) - for web scenarios, you may not want to use a transaction when pushing a message to the queue
- .PurgeOnStartup( Boolean ) - determine whether or not to purge queues when NSB starts up.
- .TransactionTimeout( Timespan ) - the time to wait for a transaction
- .MsmqSubscriptionStorage() or DBSubscriptionStorage() - tells NSB where to persist subscriptions. If you are using Profiles, this is set in the Profile of choice(Lite, Integration, or Production). If using MSMQ, the queue to use is in the config file. If using NHibernate, you can default to the config file for NH properties or supply an IDictionary to the overload.
- .DBSubscriptionStorageWithSQLLiteAndAutomaticSchemaGeneration() - pretty sure we all have this one down.
- .Sagas() - tells NSB to look for Sagas in the assemblies provided to NSB in the beginning of the process.
- .NHibernateSagaPersister() - this will use NH for Saga persistence. Unless supplied to the overload, NSB will use the config file for the NH properties. You can give this method an IDictionary of properties as this point.
- NHibernateSagaPersisterWithSQLLiteAndAutomaticSchemaGeneration() - pretty self explanatory I think.
- .RijdaelEncryptionService() - if you are encrypting messages, this will load the keys from the config.
- .Log4Net() - there are a few overloads here for you to tweak Log4Net. You have access to the Appender, AppenderSkeleton, and you and specify your own configuration.
- .RunCustomAction( Action ) - this is a place where you can run anything you want really. Typically I've seen this used to tweak the container very early in the boot strapping process.
New 3.0 Options
Some of the options have moved around to new classes, but the semantics remain the same. Below are some of the new options available to address new features.
- .MessageForwardingInCaseOfFault() - tells the bus to forward messages when there is a fault
- .FtpTransport() - FTP transport options
- .ImpersonateSender(Boolean) - whether we should impersonate the sender or not
- .InMemoryFaultManagement() - sets up the in memory fault manager. Faults are lost when the process shuts down.
- .NHibernateFaultManager() - sets up the NH fault manager. Faults are saved to a database with the exception that caused them.
- .NHibernateUnitOfWork() - sets the UOW manager to use the internal NSB NH manager. You can supply your own if you are also using NH in your code.
As we've found out, you have full control over how NSB is configured right from the start. Next time we'll a close look at the Roles we talked about earlier in the article.
Subscribe to:
Posts (Atom)
