从 C# 读取 Tibco EMS 消息队列需要哪些属性

问题描述

我收到以下异常抛出 执行 AfterPropertiesSet() 时:

不允许创建目的地

Java 人员给了我这些:

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

pt-project1-username: ticketappsgreeks-ext

pt-project1-password: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

用户:ticketappsgreeks-ext

密码:ticket41040

目标主机名: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);
                    this.listenerContainer.RecoveryInterval = new TimeSpan(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 用于 .Net,因为它已经死了。 而是返回并下载 Tibco 社区版并从供应商提供的示例开始。

发现这个: Is Spring.NET project dead?