Showing posts with label bre. Show all posts
Showing posts with label bre. Show all posts

Thursday, 5 November 2015

Asserting Database Facts Per Environment

I've recently been using database facts in Biztalk Business Rules Engine and this has required an assertion of the connection string into the policy which includes the database server/instance, database name, and table name. The database name and table are likely to be static for the life of the application but the database server needs to change based on which environment we have deployed to. I've been considering where to set the configuration for this. The options are:


  • BTSNTSVC config. A per server configuration is possible in this but I think it's best to avoid using such a file.
  • Business rule policy which determines the local machine name then sets the database server based on this. A bit overkill.
  • Business rule vocabulary with static value we can use. Doesn't work too well for different environments.
  • Fact Retriever which will pull the value from somewhere else.
Considering that the database being used is on the same server/instance as the Biztalk databases, I opted to use the Fact Retriever to pull the database/instance configuration from the windows registry.


using System.Data.SqlClient;
using Microsoft.RuleEngine;
using Microsoft.Win32;
namespace My.BRE
{
    public class AssertSiteConverterDB : IFactRetriever
    {
        public object UpdateFacts(RuleSetInfo ruleSetInfo, RuleEngine engine, object factsHandleIn)
        {
            object factsHandleOut;
            if (factsHandleIn == null)
            {
                object servObj = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\BizTalk Server\\3.0\\Administration", "MgmtDBServer", ".");
                SqlConnection SQLConn = new SqlConnection("Data Source=" + servObj.ToString() + ";Initial Catalog=SIP;Integrated Security=SSPI;");
                DataConnection RulesConn = new DataConnection("my database", "my table", SQLConn);
                factsHandleOut = RulesConn;
                engine.Assert(factsHandleOut);
            }
            else
                factsHandleOut = factsHandleIn;
            return factsHandleOut;
        }
    }
}

Gac this and configure your policy to use this Fact Retreiver and this will ensure that the correct database/instance will be asserted no matter which environnment you deploy to.

Wednesday, 25 February 2015

Biztalk360 BRE Standalone Access to Assemblies

One of the problems with using a standalone server with Biztalk360 is the unavailability of assemblies. When you load the business rules page in Biztalk360, you may find it inaccessible with various errors stating that various assemblies could not be found.

To solve this, grab all dll's for any custom BRE components you use in addition to all the dll's under C:\Program Files (x86)\Microsoft BizTalk ESB Toolkit 2.1\Bin from another system if you use the ESB toolkit. A simple way to gac these assemblies on a server which doesn't have access to Gacutil is to copy these dll's to C:\Windows\assembly. At this point the problem still persists and I've tried restarting the Biztalk360 service. In the end I couldn't figure out how to get Biztalk360 to access these dll's. Wait another 24 hours at which point Biztalk360 will have access to the dll's and will work correctly.

Thursday, 15 January 2015

FTP via BRE and Dynamic Ports

Here's an example of how to set up the properties on a message that is required for the FTP adapter.

If you find that you're outputting 0kb files, ensure that the passive mode property is included.

For a hint of what other properties are available, you can export the bindings from an application that contains an ftp port and examine the <TransportTypeData> for that send port.