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

时间:2021-02-02 21:11:56

标签: 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, 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}");
                    }
                }

1 个答案:

答案 0 :(得分:0)

如果您在这里找到了自己的方式,那么您可能浪费了与我研究如何读取 Tibco EMS 队列相同的时间。

不要将 SpringFamework 用于 .Net,因为它已经死了。 而是返回并下载 Tibco 社区版并从供应商提供的示例开始。

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

相关问题