2017-04-03 79 views
0

我想要聽的EMS服務器,如下所示:TIBCO EMS - 傾聽EMS例外「不允許創建目的地」

Topic clientTopic = _subscriberSession.CreateTopic(topicName); 
TopicSubscriber clientTopicSubscriber = _subscriberSession.CreateSubscriber(clientTopic, selector, true); 
clientTopicSubscriber.MessageHandler += new EMSMessageHandler(test_MessageHandler); 

然而,當我做到這一點,則拋出異常:
TIBCO.EMS.InvalidDestinationException:'不允許創建目標'

我知道EMS已配置爲禁用隊列和主題創建。不過,我只是想聽聽這個話題。我也嘗試過「CreateConsumer」。我不明白髮生了什麼問題。我只是試圖傾聽,而不是創建一個隊列或主題。你們知道什麼是錯的嗎?

此外,我試圖傾聽的主題存在並已通過驗證。

回答

1
 var context = new LookupContext(environment); 
     var factory = context.Lookup(config.ConnectionFactory) as ConnectionFactory; 
     try 
     { 
      connectionCorp = factory.CreateConnection(); 
     } 
     catch { 
      var connectionFactory = new ConnectionFactory(factory.Url, "Receiver", environment); 
      connectionCorp = connectionFactory.CreateConnection(); 
     } 
     connectionCorp.Start(); 
     sessionCorp = connectionCorp.CreateSession(false, SessionMode.ClientAcknowledge); 
     var queue = context.Lookup(config.Name) as Destination; 
     if(queue is TIBCO.EMS.Topic) 
     { 
      var selector = string.Format("To='{0}' and From='{1}'", config.ToAddress, config.FromAddress); 
      msgConsumer = sessionCorp.CreateConsumer(queue, selector,false); 
      msgConsumer.MessageHandler += (sender, args) => { 
       action(args); 
      }; 
     } 
     else 
     { 
      msgConsumer = sessionCorp.CreateConsumer(queue); 
      msgConsumer.MessageHandler += (sender, args) => { 
       action(args); 
      }; 
     } 
0

即使您只是在監聽某個主題,但默認情況下您需要權限才能看到任何通信。也只是訂閱一個主題需要'訂閱'權限。

你的情況,你可以添加

TOPIC = foo的USER = USER1 PERM(與你的實際客戶端主題,USER1與您的用戶名代替富)=認購

或者,如果你不想只是將'>'通配符添加到單行的topics.conf和queue.conf中,然後重新啓動tibemsd:

>