StrataFrame Forum

ES Server and RemoteDatasourceKey Questions

http://forum.strataframe.net/Topic25498.aspx

By Richard Keller - 1/7/2010

Hi guys,

Let me know if this would work.  I have a single application that wants to switch databases on the ES Server side.  If I have Multiplae DataSourceConnections like the sample below, should I just be able to change the RemoteDataSourceKey in the call without any other modifactions?   Second if I'm adding ConnectionStrings does this read in real time or is it populated on the start of the server.  Basically I would need to know if the Server is caching this configure or I could add Databases on the fly.

I ask the first question because I get an error if I use the DEV2 sample otherwise the MultiShip works fine.  The second would be for administration and deployment.

Thanks,

Rich

Sample:

<?xml version="1.0" encoding="utf-8" ?>

<DataSources>
 <DataSource DataSourceKey="MultiShip">
  <ConnectionString>server=localhost;Integrated Security=SSPI;Database=RZMultiShip;</ConnectionString>
  <TypeFullName>MicroFour.StrataFrame.Data.SqlDataSourceItem</TypeFullName>
  <TypeAssemblyName>MicroFour StrataFrame Base</TypeAssemblyName>
  <TypeAssemblyVersion>1.7.0.0</TypeAssemblyVersion>
  <TypeAssemblyCulture>neutral</TypeAssemblyCulture>
  <TypeAssemblyPublicToken>99fe9917f71608a7</TypeAssemblyPublicToken>
  <IsEncrypted>True</IsEncrypted>
  <IsCompressed>True</IsCompressed>
  <EncryptionKey>151, 123, 237, 154, 69, 13, 132, 130, 233, 174, 208, 232, 85, 162, 40, 169, 161, 0, 140, 40, 47, 163, 98, 73</EncryptionKey>
  <EncryptionVector>133, 78, 229, 207, 101, 227, 102, 225</EncryptionVector>
  <TransactionTimeout>3600</TransactionTimeout>
 </DataSource>
 <DataSource DataSourceKey="">
  <ConnectionString>server=localhost;Integrated Security=SSPI;Database=RZMultiShip3;</ConnectionString>
  <TypeFullName>MicroFour.StrataFrame.Data.SqlDataSourceItem</TypeFullName>
  <TypeAssemblyName>MicroFour StrataFrame Base</TypeAssemblyName>
  <TypeAssemblyVersion>1.7.0.0</TypeAssemblyVersion>
  <TypeAssemblyCulture>neutral</TypeAssemblyCulture>
  <TypeAssemblyPublicToken>99fe9917f71608a7</TypeAssemblyPublicToken>
  <IsEncrypted>True</IsEncrypted>
  <IsCompressed>True</IsCompressed>
  <EncryptionKey>151, 123, 237, 154, 69, 13, 132, 130, 233, 174, 208, 232, 85, 162, 40, 169, 161, 0, 140, 40, 47, 163, 98, 73</EncryptionKey>
  <EncryptionVector>133, 78, 229, 207, 101, 227, 102, 225</EncryptionVector>
  <TransactionTimeout>3600</TransactionTimeout>
 </DataSource>
 <DataSource DataSourceKey="Dev2">
  <ConnectionString>server=localhost;Integrated Security=SSPI;Database=RZMultiShip2;</ConnectionString>
  <TypeFullName>MicroFour.StrataFrame.Data.SqlDataSourceItem</TypeFullName>
  <TypeAssemblyName>MicroFour StrataFrame Base</TypeAssemblyName>
  <TypeAssemblyVersion>1.7.0.0</TypeAssemblyVersion>
  <TypeAssemblyCulture>neutral</TypeAssemblyCulture>
  <TypeAssemblyPublicToken>99fe9917f71608a7</TypeAssemblyPublicToken>
  <IsEncrypted>True</IsEncrypted>
  <IsCompressed>True</IsCompressed>
  <EncryptionKey>151, 123, 237, 154, 69, 13, 132, 130, 233, 174, 208, 232, 85, 162, 40, 169, 161, 0, 140, 40, 47, 163, 98, 73</EncryptionKey>
  <EncryptionVector>133, 78, 229, 207, 101, 227, 102, 225</EncryptionVector>
  <TransactionTimeout>3600</TransactionTimeout>
 </DataSource>
</DataSources>

By Richard Keller - 1/7/2010

Ok.  I think that the DataSourceKeys at the AppServer are Cached and maybe updated in some sort of Interval or when the IIS Application Pool resets.  Can you confirm?

I think I found a bug.  If an Invalid RemoteDataSourceKey is set then I get a Key not found in Dictionary error but the application halts even if it is in a Try Catch Block.

Rich

By Trent L. Taylor - 1/8/2010

Ok. I think that the DataSourceKeys at the AppServer are Cached and maybe updated in some sort of Interval or when the IIS Application Pool resets. Can you confirm?




This is correct on the server side.



I think I found a bug. If an Invalid RemoteDataSourceKey is set then I get a Key not found in Dictionary error but the application halts even if it is in a Try Catch Block.




Actually what you are trying to do is not how the ES data sources are designed. Instead of changing the RemoteDataSourceKey, you are better off defining all of the data sources within your application as they are setup. Then on your BaseBO (which all of your BOs would inherit) you could set a preference in your application that would change the DataSoureKey of the BO which would then redirect where the connections are made. This way you do not have to worry with caching etc. as this connection is created when the BO creates the DataLayer (instantiation or when the CreateDataLayer method is called). This would be a more controllable and safer approach in my opinion.
By Richard Keller - 1/8/2010

The problem with that approach is that I was going to use this as a SAAS gateway to my servers and the Access Key would determine which Database a Customer Uses.  So the DataSourceKey would change upon the setup and install at the server and be agnostic to the Datasource Key at the client as it would always be the same.   My root BaseBusinessObject has the connection logic and adjusts the Connection String as necessary.

Is there a way to control the Server Caching of DatasourceKeys or know the specific time interval?

Thanks,

Rich

P.S.  Everything is working except the status page on the ES Server although the IP has been set.

By Trent L. Taylor - 1/8/2010

First, let me mention this. We do this in our medical application and every instance has a unique GUID and instance name. So we create a new database for each customer on a designated SQL Server. We then use that instance name (let's use "JonesFamilyPractice" as an example) as part of the database name (i.e. JonesFamilyPractice_PracticeStudio would be the database name in this example). You can also use this instance, key, or whatever you want to call it as part or all of your data source key name as well for the BO. On the application side, it would just use this algorithm to create the data source key connections. Then all you need to do is create a matching data source key on the ES side, and you are done. That should be all that is required (I think :heheSmile.



Is there a way to control the Server Caching of DatasourceKeys or know the specific time interval?




Flushing the application pool will force the connections to reset...don't recommend doing this though as connected users could be closed down. If you use my approach from above you should not need to do this.



P.S. Everything is working except the status page on the ES Server although the IP has been set.




This is usually the easiest step. Are you still getting an Access Denied page? Do you have your local IP entered as well as a possible range of IPs that can connect? Remember that you can provide the subnet mask so that all IPs within a certain subnet can be granted access as well. Here is an example:



add key="StatusIpAddresses" value="127.0.0.1;10.20.0.70;10.10.0.0/255.255.255.0"




In the above sample, the machine on which the ES is running (127.0.0.1), as well as the machine with the IP address of 10.20.0.70, and all IPs on the 10.10.0.X subnet will be granted access to the status page.
By Richard Keller - 1/8/2010

But what I don't understand is how the ES Datasource Key is not flushed.  Unless you are saying create a "fixed" number of DatasourceKeys regardless of the database existing or not and put them in the config file that way they are preloaded before the database is created.

The entire subnet has been added with no luck, rebooted, changed authentication to none and added every user to the IIS Web Permissions Sad  It's gotta be IIS I'll try more to track down.

Rich

By Trent L. Taylor - 1/8/2010

If you are trying to create dynamic connections on the ES side, this will not work. You must create "fixed" connections. Now you can create as many as you want, but they must exist when the client side makes a request. As for the caching, this is actually all IIS managed. Also, a specific connection will not be created unless it is requested. So if you have 100 connections in there, and only one is requested for use by the client, then there would only be one connection created and cached until the app pool cycles. One other thing of note, connections are not actually left open. They are only opened during use then closed.
By Richard Keller - 1/8/2010

Darn.  Can't the Magic of Microfour have a listener on the Data.Config File and Refresh the DataSources BO or even better allow the Connection Strings to be stored in a Database and you can set the polling interval.  I'm suprised that this isn't a more common operation.

I'll put in the Enhancement Requests.

1. DataSources.config works like Web.Config and forces refresh or BO.  It's just a connection String read anyways.

2. Datasources.Config can be moved to a Database

Richard