簡體   English   中英

從 C# 讀取 Tibco EMS 消息隊列需要哪些屬性

[英]What are the attributes needed to read a Tibco EMS message queue from C#

執行 AfterPropertiesSet() 時拋出以下異常:

不允許創建目的地

從 Java 伙計們那里,我得到了這些:

pt-jndi-url:tibjmsnaming://tibjndi-pt.mycompany.com:12420

pt-project1-用戶名:ticketsappsgreeks-ext

pt-project1-密碼:ticket41040

隊列名稱:ALS.QA.tickets.TEST.QUEUE_CONNECTION

pt-project1-jndi-queue-connection-factory-name:ALS.PT.tickets.greeks.QCF.MS

我在 C# 調用中將這些翻譯成以下內容:

URI:tibjndi-pt.mycompany.com:12420

用戶:ticketsappsgreeks-ext

密碼:tickets41040

目標主機名:tibjndi-pt.mycompany.com

目的地:ALS.QA.tickets.TEST.QUEUE_CONNECTION

環境:

  • Windows 10 使用
  • VS 2017
  • TIBCO.EMS.DLL 1.0.851.4
  • Spring.Messaging.Ems 2.0.1

C# 代碼:

private readonly SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
                
                connectionFactory = new Spring.Messaging.Ems.Common.EmsConnectionFactory(Uri);
                if (!string.IsNullOrEmpty(User))
                {
                    connectionFactory.UserName = User;
                    Logger.Info($"User : {User}");
                }

                if (!string.IsNullOrEmpty(Pwd))
                {
                    connectionFactory.UserPassword = Pwd;
                    Logger.Info($"Pwd : {Pwd}");
                }

                if (!string.IsNullOrEmpty(TargetHostName))
                {
                    connectionFactory.TargetHostName = TargetHostName;
                    Logger.Info($"TargetHostName : {TargetHostName}");
                }
                
                connectionFactory.ClientID = "testClient1";
                
                try
                {
                    Logger.Debug($"Destination - {DestinationName}");

                    this.listenerContainer.ConnectionFactory = connectionFactory;
                    this.listenerContainer.DestinationName = DestinationName;
                    this.listenerContainer.ConcurrentConsumers = 1;
                    this.listenerContainer.PubSubDomain = false;
                    this.listenerContainer.MessageListener = new MessageListener(Logger);
                    this.listenerContainer.ExceptionListener = new ExceptionListener(Logger);
                    this.listenerContainer.MaxRecoveryTime = new TimeSpan(MaxRecoveryTimeInDays, 0, 0, 0);
                    this.listenerContainer.RecoveryInterval = new TimeSpan(0, 0, 0, 10, 0); // set to 10 Minutes  
                    this.listenerContainer.AcceptMessagesWhileStopping = false;
                    this.listenerContainer.SessionAcknowledgeMode = AckMode;
                    this.listenerContainer.AfterPropertiesSet();
                    if (this.listenerContainer.IsRunning)
                    {
                        Logger.Debug("Listener IsRunning.");
                    }

                }
                catch (EMSException e)
                {
                    Logger.Error($"EMSException : {e.Message}");

                    if (e.LinkedException != null)
                    {
                        Logger.Error($"EMSException Linked Exception error msg : {e.LinkedException.Message}");
                    }
                }

如果您在這里找到了自己的方式,那么您可能浪費了與我研究如何讀取 Tibco EMS 隊列相同的時間。

不要使用 SpringFamework for.Net,因為它已經死了。 取而代之的是 go 並下載 Tibco 社區版並從供應商提供的示例開始。

發現這個: Spring.NET 項目死了嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM