Asp.net 如何从两个或多个IIS应用程序中使用ApacheIgnite

Asp.net 如何从两个或多个IIS应用程序中使用ApacheIgnite,asp.net,caching,iis,ignite,Asp.net,Caching,Iis,Ignite,我不熟悉ApacheIgnite,并尝试在IIS网站和WCF服务中使用Ignite。我的测试用例涉及一台PC上的两个IIS托管WCF测试服务。我正在两个IIS应用程序中的任何一个中实例化Ignite,然后尝试从另一个进行访问。到目前为止,这还没有奏效。在一个IIS应用程序中启动Ignite后,我从另一个应用程序获得“默认网格实例已启动”,但另一个应用程序无法获得现有默认网格实例的句柄 我正在从两个IIS测试应用程序的Global.asax应用程序开始运行下面的代码。希望有人能给我一些启示,为我指

我不熟悉ApacheIgnite,并尝试在IIS网站和WCF服务中使用Ignite。我的测试用例涉及一台PC上的两个IIS托管WCF测试服务。我正在两个IIS应用程序中的任何一个中实例化Ignite,然后尝试从另一个进行访问。到目前为止,这还没有奏效。在一个IIS应用程序中启动Ignite后,我从另一个应用程序获得“默认网格实例已启动”,但另一个应用程序无法获得现有默认网格实例的句柄

我正在从两个IIS测试应用程序的Global.asax应用程序开始运行下面的代码。希望有人能给我一些启示,为我指明正确的方向:

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 );
Random Random=new Random();
短启动计数器=0;
秒表sw=新秒表();
sw.Start();
做
{
睡眠(1000*random.Next(10,20));
IgniteEngine=Ignition.TryGetIgnite();
startCounter++;
如果(空==点火引擎)
{
LogHelper.Write(“{0}:CacheManager.InitializeCache尝试{1}获取新ignite实例失败。”.InvariantFormat(CommonSystemInfo.MachineName,startCounter),“TraceLogger”);
}
如果(空==点火引擎)
{
尝试
{
点火发动机=点火。启动(新点火配置
{
JvmClasspath=System.IO.Directory.GetFiles(System.Web.HttpContext.Current.Server.MapPath(@“~\bin\libs”)).Aggregate((x,y)=>x+”;“+y)
} );
如果(空!=点火引擎)
{
LogHelper.Write(“{0}:CacheManager.InitializeCache在{1}次尝试和{2}秒后启动ignite成功”。不变量格式(CommonSystemInfo.MachineName、startCounter、sw.Appeased.TotalSeconds)、“TraceLogger”);
}
}
捕获(异常ex2)
{
LogHelper.Write(“{0}:CacheManager.InitializeCache在尝试启动新ignite实例时出错。{1}”).InvariantFormat(CommonSystemInfo.MachineName,ex2.GetAllMessages(),“TraceLogger”);
}
}
}

而(null==IgniteEngine&&sw.Appeased.TotalMinutes看起来您的服务在一个IIS应用程序池中运行,这意味着一个进程和不同的应用程序域。这意味着进程中只有一个JVM,这会导致
默认网格实例已启动
错误

你的选择是:

  • 使用不同的
    IgniteConfiguration.GridName
  • 将不同的IIS应用程序池分配给其中一个服务
  • 在一个应用程序中运行这两个服务,这样
    TryGetIgnite
    就可以工作,而不必启动Ignite两次

Pavel,感谢您的指导。我接受了上面的前两点,但只有在一个丑陋的发现之后,它才起作用。我在上使用asp.net部署的构建后步骤。这将jar文件放入bin。问题是在将nuget从1.7更新到1.8后开始的。*.1.7 jar文件已复制到我的bin文件夹中,并在更新.Subs后保留equent publishing将1.7和1.8文件复制到部署文件夹中。1.7和1.8 jar的混合产生了问题。生成后需要预生成以删除以前的文件。可能的预生成步骤为:cd$(TargetDir)Libs del*.jar