Web ADF resource manager dialogs
The Web ADF uses the Connection library to create and manage
connections for both ArcGIS Server Local and ArcIMS data
sources. The resource manager controls (MapResourceManager,
GeocodeResourceManager, and GeoprocessingResourceManager) will provide a Data
Source Definition dialog to define the primary server connection for a
resource. For ArcGIS Server Local and ArcGIS dialogs, the option to
configure connection manager capabilities is available in an Advanced
Settings dialog.
ArcIMS data sources

ArcGIS Server Local data sources


When finished configuring connections, a ConnectionManager.xml file is created
in the Web application root folder. There is only one
ConnectionManager.xml per Web application. The file is used to
store the properties defined in the Advanced
Settings dialogs. If the file is available at design-time,
the Web ADF reads the content of the xml file to populate
the Advanced Settings dialogs. The primary connection property
is the unique key for connections defined in an application. At
runtime, the data source uses the xml file to establish which servers are
available for resource requests. An example
ConnectionManager.xml is included below:
<?xml version="1.0"?>
<ESRI.ArcGIS.ADF.Connection>
<ConnectionManager>
<Connection primary="server1@5300" serverType="ArcIMS" mode="RoundRobin" maxAttempts="20" failedCheckInterval="5">
<Alternate>server2@5300</Alternate>
<Alternate>server3@5300</Alternate>
</Connection>
<Connection primary="server1" serverType="ArcGIS" mode="Failover" maxAttempts="20" failedCheckInterval="5">
<Alternate>server2</Alternate>
<Alternate>server3</Alternate>
</Connection>
</ConnectionManager>
</ESRI.ArcGIS.ADF.Connection>
In this example, an ArcIMS TCP and ArcGIS Server Local connection
have been configured to be managed for Web ADF components in the
respective Web application. For all ArcIMS TCP connections that
use server1@5300 as their
primary server, server2@5300 and
server3@5300 will also be accessed using the round-robin
mode. Any resource manager that defines server1@5300
as the primary connection will use this configuration. For
all ArcGIS Server Local connections, the primary connection
to server1 will be used until a failure occurs. If a
failure occurs, the next alternate server, server2, will be used. The
failedCheckInterval parameter defines the number of requests after the
failure the connection manager will wait to check the
primary connection to see if it is available. The
maxAttempts parameter defines the maximum number of attempts
to check if the primary connection becomes available.
Programmatic Use
Managing connections with the ConnectionManager involves working with a set of
classes in the ESRI.ArcGIS.ADF.Connection library. In general,
connections are added and maintained in a ConnectionManager. A
connection is subsequently retrieved from the same ConnectionManager
depending on the connection mode (round-robin, failover, default). Each
connection has the option of maintaining a list of alternate connection
items which simply define an alternate server from which to create a
connection. Alternates are only used when the connection mode is
round-robin or failover. Consider the following classes and
properties when configuring a connection manager:
ConnectionManager
A ConnectionManager's connections and properties can be configured
via an xml file (e.g. see ConnectionManager.xml in the previous section) or
added programmatically. The constructor provides an option for specifying
the path to an xml file as well as a default identity to be used for
managed connections (if they have not specified an identity). Once a
ConnectionManager is configured, connections are retrieved via the
ServerConnection() method. The ServerConnection() method requires two
parameters, the connection name and type. It contains
logic for managing connections via the defined connection
mode. The ServerConnection() method should return an active
ArcGIS Server (ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection) or
ArcIMS
(ESRI.ArcGIS.ADF.Connection.IMS.IMSServerConnection) connection. The
following table lists important ConnectionManager
methods:
| Method Name | Returns | Description |
|---|---|---|
| Add(Connection) | void | Add a new Connection instance. Add ConnectionItems to the Connection instance before adding it to the ConnectionManager. |
| Find(name, type) | Connection | Find a Connection instance using name and server type. |
| ReadXML(XmlDocument) | void | Load an xml document with ConnectionManager configuration information. |
| Remove(Connection) | void | Remove a Connection instance from the ConnectionManager. |
| ServerConnection(name, type) | IServerConnection | Use a Connection instance to create an active connection to ArcGIS Server or ArcIMS. Specify the name of the primary Connection and the server type. If the name does not reference an existing Connection, a new Connection will be created. The new Connection will use the default connection mode and the ConnectionManager identity (if set). |
Connection
The Connection class is used to define the primary connection to a
server. Each Connection is associated with a unique
name used to define the primary server with which it will
connect. See the Name property in the table below for more
information. A Connection instance may also store the identity used
when connecting, the connection mode, and parameters for retrying failed
connections. The following table lists Connection properties:
| Property Name | Type | Description |
|---|---|---|
| ActiveConnectionItemIndex | int | For round-robin connection modes, this provides the current active index of the Connection item (0-number of items). The primary connection returns -1. Other connection modes also return -1. |
| ConnectionMode | ConnectionMode | Three types: RoundRobin, Failover, Default RoundRobin - Each server (name), defined for the primary Connection and any alternate ConnectionItems, will be used to create a connection in sequence. Failover - Only one server (name) will be used at a time. If a connection fails, the next connection (either primary Connection or ConnectionItem) will be used to define a server from which to create a connection. The first attempt will always use the primary Connection. Default - Only the primary Connection will be used to create a connection. |
| FailedCheckInterval | int | After a connection fails, this value defines how many requests can be made
to the application before checking the status of the failed
connection. Valid for round-robin and failover modes only. Default
value is 5.
For example, assume you set the FailedCheckInterval to 3. If two servers are associated with one Connection and the primary server is unavailable, the secondary server will be used exclusively until the third request to the Connection. During the third request , the Connection will attempt to reconnect and failed connections, in this case to the primary server. If unsuccessful, the Connection will wait another three requests to try again until reaching the maximum number of attempts (MaxAttempts). If set to 0, the Connection will attempt to reconnect to any server that has failed during each request. The default maximum number of attempts by a Connection to connect to any server in its list of server names is 20. This will require at least 20 different server names associated with a single Connection instance to become a factor. This value can only be changed via a Connection constructor - no public property is available. In most cases, this value will not need to be changed. |
| Identity | Identity | The identity used by the Connection and subsequent ConnectionItems. Valid for ArcGIS Server and ArcIMS HTTP connections. |
| Items | ConnectionItemCollection | Use to add or remove ConnectionItem instances to a Connection. |
| Name | string | The name of the connection is determined by the server type. For
ArcGIS Server Local connections it is the
machine name on which an ArcGIS Server SOM is
available. For ArcIMS TCP connections it is the machine name
and port on which an ArcIMS Application Server is available. For
ArcIMS HTTP connections it is the url to the ArcIMS Servlet connector. Use the name to uniquely identify a Connection instance when using the ConnectionManager to create a connection. |
| ServerType | string | Two valid values: "ArcGIS" for ArcGIS Server connections, "ArcIMS" for ArcIMS connections. |
ConnectionItem
A Connection can also maintain a list of ConnectionItems, each referencing
an alternative connection name. When the connection mode
is round-robin or failover, each ConnectionItem associated with a
Connection may be used. It is important to note that the services
available on a server referenced by a ConnectionItem should match the
primary Connection. The following table list ConnectionItem
properties:
| Property Name | Type | Description |
|---|---|---|
| Name | string | The same as the Connection.Name property except the ConnectionItem defines an alternative server for a Connection. |
How to use the ConnectionManager
The following steps will provide a quick overview of how
to utilize the ConnectionManager in a custom application. Any
application type can take advantage of connection manager capabilities,
including Web, desktop, and console applications. Assuming you have
already created a Visual Studio project, do the following:
ESRI.ArcGIS.ADF.Connection.ConnectionManager m_ConnectionManager = new ESRI.ArcGIS.ADF.Connection.ConnectionManager(null);
// Define identity to use when connecting to server
ESRI.ArcGIS.ADF.Identity agsIdentity = new ESRI.ArcGIS.ADF.Identity("user",
"password", "domain");
// Create and define primary Connection
ESRI.ArcGIS.ADF.Connection.Connection primaryConnectionArcGIS =
new ESRI.ArcGIS.ADF.Connection.Connection("primaryserver",
ESRI.ArcGIS.ADF.Connection.ConnectionMode.RoundRobin, agsIdentity, 3, 3);
primaryConnectionArcGIS.ServerType = "ArcGIS";
// Add alternative servers to primary Connection
primaryConnectionArcGIS.Items.Add(new
ESRI.ArcGIS.ADF.Connection.ConnectionItem("mirrorserver1"));
primaryConnectionArcGIS.Items.Add(new
ESRI.ArcGIS.ADF.Connection.ConnectionItem("mirrorserver2"));
// Add Connection to ConnectionManager
m_ConnectionManager.Add(primaryConnectionArcGIS);
ESRI.ArcGIS.ADF.Connection.IServerConnection serverConnection = m_ConnectionManager.
ServerConnection("primaryserver", "ArcGIS");
// A connection should be returned alive (connected)
bool isAlive = serverConnection.IsAlive();
// Cast to the appropriate connection type:
// ArcGIS - ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection
// ArcIMS - ESRI.ArcGIS.ADF.Connection.IMS.IMSServerConnection
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsConnection =
(ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection) serverConnection;