I am new to Apache Ignite and trying to use Ignite within IIS websites and WCF services. My test case involves two IIS hosted WCF test services on one PC. I am instantiating Ignite in either of the two IIS applications and then trying to access from the other. So far this has not worked. Once Ignite starts in one IIS app, I get a "Default grid instance has already been started" from the other app, but the other app is not able to get a handle of the existing default grid instance.
I am running the code below from the Global.asax Application_Start of both IIS test applications. Hoping someone can give insight and point me in the right direction:
Random random = new Random();
short startCounter = 0;
Stopwatch sw = new Stopwatch();
sw.Start();
do
{
Thread.Sleep( 1000 * random.Next( 10, 20 ) );
IgniteEngine = Ignition.TryGetIgnite();
startCounter++;
if ( null == IgniteEngine )
{
LogHelper.Write( "{0}: CacheManager.InitializeCache attempt {1} to get a new ignite instance failed.".InvariantFormat( CommonSystemInfo.MachineName, startCounter ), "TraceLogger" );
}
if ( null == IgniteEngine )
{
try
{
IgniteEngine = Ignition.Start( new IgniteConfiguration
{
JvmClasspath = System.IO.Directory.GetFiles( System.Web.HttpContext.Current.Server.MapPath( @"~\bin\libs" ) ).Aggregate( ( x, y ) => x + ";" + y )
} );
if ( null != IgniteEngine )
{
LogHelper.Write( "{0}: CacheManager.InitializeCache success starting ignite after {1} attempts and {2} seconds".InvariantFormat( CommonSystemInfo.MachineName, startCounter, sw.Elapsed.TotalSeconds ), "TraceLogger" );
}
}
catch ( Exception ex2 )
{
LogHelper.Write( "{0}: CacheManager.InitializeCache error while trying to start a new ignite instance. {1}".InvariantFormat( CommonSystemInfo.MachineName, ex2.GetAllMessages() ), "TraceLogger" );
}
}
}
while ( null == IgniteEngine && sw.Elapsed.TotalMinutes <= 2 );
Looks like your services run within one IIS Application Pool, which means one process and different app domains. This means that there is a single JVM within the process, which causes
Default grid instance has already been started
error.Your options are:
IgniteConfiguration.GridName
TryGetIgnite
works and you don't have to start Ignite twice