BlazeDs 之 MessagerService

昨天看blazeds 官方文章,發現越看自己要改的思想越多,原來blazeds主要提供了兩個服務。

1,就是我們常說的RPC服務,這其中又包括http 和web service 還有就是remoting service(發現在前幾天做的只是個remoting service的東西)

2,messaging service,這個還可以connect jms.

 

MessagerService

        現在單挑messagerService 來看官方資料怎麼說的,我是先自己翻譯出來的,儘量中心思想是對的。

 

       Messaging Service 擴展了消息框架的核心,增加了對服務器和多flex clent 之間發佈訂閱的支持。flex app 用自身客戶端的API把消息發給,和從那裏收,一個定義在server 上的destination。所有messages 被server endpoint 處理,通過channel 傳遞。Messaging Service通過使用JMSAdapter也可以橋接到JMS上。Messaging讓flex app 連接到SERVER上的destination,向server 發消息,從不同的messaging clients接收消息。發送到server 的messages 被server發送到訂閱了相同destination的flex app. sever 也能自己把消息push 給clients.這樣它會先初始一個消息,然後把它廣播給一個地址, 這樣所用訂閱了這個地址的所有flex app 就都會收的此消息。一個很有名的例子就是一個客戶端發佈一條信息,經過服務器轉發給所有訂閱了此消息的client.

       client app 發送消息者我們叫它爲message producers 在flex 中用Producer component 去定義它,對應的在client app 接收消息的我們叫它message consumers, 在flex 中用Consumer component去定義它。producer 發送消息到服務器上的指定 destination,然後consumers 訂閱服務端的destination,在通常情況下,producer和consumers是互相不知道對方的。

      一般一個flex app 應用都至少包括一對,producer和consumers這樣它就即能向server 上destination發信息,也能接收別的producer發送到destination的消息。

 

再說Channels

      flex app 可以通過多個channel去獲得messages,flex app 會try 用不同的channel 按照你在配置文件中定義的順序,直到找到一個可用的,或者找完所有,結果都不可用,然後報個錯。


Adapters

 

      有ActionScriptAdapter 和JMSAdapter兩種,

  • The ActionScriptAdapter is the server-side code that facilitates messaging when your application uses ActionScript objects only or interacts with another system. The ActionScriptAdapter lets you use messaging with Flex clients as the sole producers and consumers of the messages.
  • The JMSAdapter lets you bridge destinations to JMS destinations, topics, or queues on a JMS server so that Flex clients can send messages to and receive messages from the JMS server

Messaging Service  的配置

 

   你可以在services-config.xml配置所有的東西不過老外說,As a best practice ,你還是再分出來一個messaging-config.xml 文件吧,放adapters 和destinations。


From:

http://blog.csdn.net/wannshan/article/details/4396431

發佈了37 篇原創文章 · 獲贊 1 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章