从 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}");
                    }
                }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)