2016-06-17 11 views
0

JMSのFioranoのC#サポートを使用して、トピックにメッセージを公開しています。 アプリケーションが終了するまですべてうまく行きます。その後、実際には終了しません。私はフィオラノがフォアグラウンドスレッドを実行していることを想定しています(。しかし、それは私の一部の推測です)C#Fiorano JMSを使用しているアプリケーションが終了時に応答を停止します

ここ は、問題を示し、最小限のが、完全な例です:

using System; 
    using System.Collections; 
    using System.Diagnostics; 
    using System.Linq; 
    using fiorano.csharp.naming; 
     // Note: Reference to 
     // Assembly: fmq-csharp-native 
     // Version: v2.0.50727 
     // Runtime Version: 10.2.0.10533 

    namespace NotificationClientTest 
    { 
     /// <summary> 
     /// Main program 
     /// </summary> 
     public static class Program 
     { 
      /// <summary> 
      /// Main method 
      /// </summary> 
      /// <param name="args">The arguments. If any exist we hang.</param> 
      public static void Main(string[] args) 
      { 
       Report("Enter Main"); 
       TheFioranoHangOnExit(args.Any()); 
       Report("Leave Main"); 
      } 

      /// <summary> 
      /// Trigger the problem. 
      /// </summary> 
      /// <param name="problem"> If true, trigger the problem </param> 
      private static void TheFioranoHangOnExit(bool problem) 
      { 
       // Initialize queue 
       var contextProperties = new Hashtable 
        { 
         { FioranoContext.SECURITY_PRINCIPAL, "user" }, 
         { FioranoContext.SECURITY_CREDENTIALS, "secretPassword" }, 
         { FioranoContext.PROVIDER_URL, "http://192.168.5.1:1956" }, 
         { FioranoContext.BACKUP_URLS, "http://192.168.5.2:1956" }, 
         { FioranoContext.INITIAL_CONTEXT_FACTORY, "fiorano.jms.runtime.naming.FioranoInitialContextFactory" }, 
        }; 

       var namingContext = new FioranoNamingContext(contextProperties); 
       var topicFactory = namingContext.lookupTCF("PRIMARYTCF"); 

       if (problem) 
       { 
        Report("Creating a connection"); 
        var connection = topicFactory.createTopicConnection(); 
        connection.stop(); // I've tried swapping the order of stop and close just in case... 
        connection.close(); 
       } 
       else 
       { 
        Report("No Connection"); 
       } 
       namingContext.close(); 
      } 

      /// <summary> 
      /// Write to console, write to debug window 
      /// </summary> 
      /// <param name="message">What to say</param> 
      private static void Report(string message) 
      { 
       Console.WriteLine(message); 
       Debug.WriteLine(message); 
      } 
     } 
    } 

は、このアプリケーションを実行する

C:\Playground\FioranoHangTest\bin\Debug>NotificationClientTest.exe 
    Enter Main 
    No Connection 
    Leave Main 

    C:\Playground\FioranoHangTest\bin\Debug>NotificationClientTest.exe oops 
    Enter Main 
    Creating a connection 
    Leave Main 
    [At this point the program hangs. 
    ^C or Task Manager can kill it.] 

This questionは、GlassFishのJMSを使用してJavaで発生した同様の問題を示しています。 Fiorano/C#にも同じ問題がありますか?

それ以外のものは何ですか?

答えて

0

私は醜い回避策が見つかりました:

 public static void Main(string[] args) 
     { 
      Report("Enter Main"); 
      TheFioranoHangOnExit(args.Any()); 
      Report("Leave Main"); 
      // Evict Fiorano Foreground threads. 
      Environment.Exit(0); 
     } 

は、恐れ入りますが、私はそのいずれかを入力した後、灰汁石鹸とオフ私の指を洗って行かなければなりません。

私はまだ、より良い答えを期待しています。

関連する問題