Loading BAM Interceptors Using the BAM API
This topic provides information about loading the WF and WCF interceptors from your code rather than through a configuration file.
Loading the WF Interceptor from Code
To load the WF interceptor runtime from your code, you must create a new instance of WorkflowRuntime and call the AddService method with a new instance of BamTrackingService. This is demonstrated below.
string connectionString = "Integrated Security=SSPI;Data Source=.;Initial Catalog=BAMPrimaryImport";
int PollingIntervalSec = 300;
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
workflowRuntime.AddService(new BamTrackingService(connectionString, interceptorConfigurationPollingInterval));
Loading the WCF Interceptor from Code
To load the WCF interceptor, you must create a derived class that opens the service and is accessible to your implementation. This is demonstrated below.
// Your project must have a reference to Microsoft.BizTalk.BAM.Interceptors.dll.
// Create a derived class accessible to the implementation that opens the service.
internal class MyBamBehaviorExtension : BamBehaviorExtension
{
internal MyBamBehaviorExtension(string connectionString, int pollingInterval)
: base()
{
this.ConnectionString = connectionString;
this.PollingIntervalSec = pollingInterval.ToString();
}
internal IEndpointBehavior Create()
{
return (IEndpointBehavior) this.CreateBehavior();
}
}
// Add the endpoint behavior just before the service is opened.
// In this example the connection string and polling intervals are being read from appSettings in App.config.
MyBamBehaviorExtension bamBehaviorExtension = new MyBamBehaviorExtension(ConfigurationManager.AppSettings["ConnectionString"], int.Parse(ConfigurationManager.AppSettings["PollingIntervalSec"]));
IEndpointBehavior bamBehavior = bamBehaviorExtension.Create();
foreach (System.ServiceModel.Description.ServiceEndpoint endpoint in myServiceHost.Description.Endpoints)
{
if (endpoint.Behaviors.Find<MyBamBehaviorExtension>() == null)
endpoint.Behaviors.Add(bamBehavior);
}
See Also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for