How do I use Apache Ignite from two or more IIS applications

人走茶凉 提交于 2019-12-24 05:21:20

问题


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 );

回答1:


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:

  • Use different IgniteConfiguration.GridName
  • Assign different IIS Application Pool to one of the services
  • Run both services within one application so that TryGetIgnite works and you don't have to start Ignite twice


来源:https://stackoverflow.com/questions/41363060/how-do-i-use-apache-ignite-from-two-or-more-iis-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!