Integration Services supports five different custom component types; however, this book only covers how to write custom tasks and data flow components in detail because those are the most commonly required. The other custom components you can write are as follows:
By now, you know that Foreach Enumerators are the components that plug into the ForEach Loop. They iterate over collections of objects and provide an element or collection of elements on each Foreach Loop iteration. Because the stock Foreach Enumerators are very flexible and provide a way to iterate over SQL Server Management Objects (SMO) objects, static text, ADO recordsets, schema rowsets, files, nodelists, or even generic .NET collections, there doesn't seem to be a lot of demand for custom Foreach Enumerators. However, if you want to write one, you can. The stock connection managers give pretty good coverage for database connections, but if you need to access an unsupported protocol, server, or other resource, for example, Lightweight Directory Access Protocol (LDAP), Simple Object Access Protocol (SOAP), or build an enhanced File Transfer Protocol (FTP) Connection Manager, you can write a custom connection manager. Log providers are extensible as well and provide a layer between the package logging infrastructure and the destination logging medium. Here again, the stock log providers provide pretty good coverage, including SQL Server, text, XML, SQL Profiler, and Windows event logging. Only a brief introduction to these custom component types is provided here because they share common setup with custom tasks and data flow components. Books Online provides excellent resources if you want to further pursue writing one of these component types. Requirements for Building Custom ComponentsBefore digging into the nuts and bolts of developing the components, let's talk a little about the requirements. You should be familiar with the following tools and have them installed. If you have Visual Studio installed, they should already be available. Also, if you have never used these tools, you should become familiar with them and understand the basics of how they function. Development PlatformVisual Studio is the preferred platform, but any environment that supports .NET will do, for example Borland Delphi or #develop will also work. It is important that the tools are compatible with .NET Framework 2.0. Debugging EnvironmentWhatever platform you choose, it should have a development environment. For this chapter, the Visual Studio development and debugging environment is assumed. If you're using a different environment, you'll need to extrapolate the instructions to match the environment. Strong Name Utility and GACUtilAll Integration Services custom components must be placed in the Global Assembly Cache (GAC) and so need to be strongly named. It is best if the Strong Name Utility (sn.exe) is on the path so that it can be executed from any directory. The same goes for GACUtil.exe. You'll use this utility for adding and possibly removing assemblies to the GAC. Programming Languages SupportedYou can use any .NET language to write custom components for Integration Services, including VB.NET, COBOL.NET or Delphi.NET. You can even write custom components in C++, although Microsoft does not support it. However, the examples in this chapter are in C# because that is the language used to write the managed stock components. For VB.NET developers, search Books Online for "custom task" to find a wealth of sample code you can reference. Computer NeededAs in previous chapters, you'll not fully understand the code presented here until you actually work through the samples on your machine, step through it in the debugger, and so on. There are numerous aspects to developing components and only a few can be documented here. Working through the samples is the best way to understand this chapter. The Sample TasksThere are four sample tasks in the samples folder. Each is in various stages of development so you can see what is possible. This chapter includes parts of those tasks when needing to explain certain concepts. Studying the code for these sample tasks in detail is a great way to quickly get up to speed on writing your own. The tasks are as follows:
Deciding to "Roll Your Own"Any discussion about writing custom components wouldn't be complete without some mention of the criteria for deciding when you should do so. For example, how do you decide if it is better to invest time in a Script Task or write a custom task instead? The following list offers a few guidelines to follow when deciding to write a custom component:
It's also important to understand when you shouldn't roll your own. The following list enumerates a few reasons why you wouldn't write a custom component:
There are a lot of considerations and trade-offs to make when deciding to write a custom component. The listed guidelines are just a start and should be considered along with the myriad of other considerations that aren't listed, such as scheduling and budgetary constraints, long-term maintenance, area expertise, and future project viability expectations that are specific to a given project. Hopefully, these guidelines will get you started with your decision. |