Skip to main content

Red Hat OpenShift xPaaS - 在OpenShift上簡單的MQTT Demo, (一), 在Openshift 上建立一個通MQTT 協定的Broker

這個demo 我會把它分成兩個部分,第一部分是在OpenShift上面建立一個有MQTT通訊協定的訊息的Broker。然後在第二部分就是寫一支簡單的小程式去連接雲端上的Broker.

OpenShift 是紅帽提供的一個開放,統一的Platform-as-a-Service (PaaS 平台即服務) 。所以向我們這種完全不想管環境設定,安裝還有網路設定的開發者可以跳過這些(無趣?) 的部分,直接就來開發拉!
好像我之前的文章講的,MQTT是鍋非常"羽量等級"的通訊協定,這個是設計給那種遠端,沒有啥頻寬可以送訊息用的客戶端用。MQTT 沒有很大的負擔,比較小的封包而且不會太耗電。它存在就是為了把訊息送到訊息Broker 為止。Broker 之後在自己想辦法把收到的訊息往外送。

所以,這次的內容就是如何在Openshift 上建立一個通MQTT 協定的Broker。
在開始之前,請先到Openshift (www.openshift.com)上面註冊一的帳號喔!

註冊完請登入,首先,我們要先建立一個Fuse 6.1的應用程式。



在完成建立Fuse 6.1 的應用程式後,你就會看到下面這個資訊業面。乾脆把這頁的東西都備份下來。因為以後忘了還可以查。


到Fuse Console 的頁面,然後登入。(在上一頁 的Console URL.)
在Runtime, MQ 的頁面右方,按下+broker 開始建立一個A-MQ 的 Broker






輸入broker 的名字,(然後我們這次用Standalone 的模式), 這裡請注意,請全部都小寫,不然有的時候Openshift 會有一些怪怪的舉動,相信他們很快就會修好了吧。所以暫時請先全部小寫。最後按下Create Broker.


所以我們現在已經創立了一個A-MQ 的設定檔。在畫面上會有紅色的錯誤,那是因為我們還沒有建立執行這個設定檔的執行容器所導致的。所以請按下下面有三角形的驚嘆號那裡去建立執行容器。

一樣,執行容器也要給個名字,對了這裡也全小寫喔!因為我們這次是建立Standalone模式,所以只要一個執行容器就夠拉!


稍等一會兒後,你會看到執行容器會慢慢地自動啓動。按下右方的箭頭與小門的按鈕,你就可以看到更多容器環境的細節。(會新開一個視窗顯示)
 到ActiveMQ 的選單中,你會看到A-MQ 啓動的時候只有打開 openwire ,並沒有我們需要的MQTT。 







但是我們不是要建MQTT嗎?沒錯,請回到原來Fuse Console那個原來的視窗(MQTT Gear)。 在最上方的Wiki選單下的左邊選單往下選擇 root/fabric/profiles/mq/broker/default.broker, 按下 org.fusesource.mq.fabric.server-broker.properties 修改設定。


把設定檔改成去讀 broker4mqtt.xml, (晚點再建這個設定檔。) 然後儲存。

按下右上方的+Create 

建立一個叫做broker4mqtt.xml 的XML 檔案 (選擇XML Document)

把下面的XML內容貼上.



    
    
        
            
        
        
    

    
        
          
            
          
        
    

    

        
            
              
                
                  
                    
                  
                
                
                
              
            
        

        
            
        

        
            
        

        
            
        

        
            
                
                    
                
                
                    
                
                
                    
                
            
        

        
            
     
        
    

 

注意一下,我們在下面新增了一個1883 的 MQTT 連接埠




儲存, 然後到Runtime->Containers 下面重新啓動執行容器. 選擇  A-MQ 執行容器然後依序停止以及啓動.

重啓之後,回到broker 的畫面(按下右邊箭頭與小門)

然後在第一頁的Log 裡面,你就會看到MQTT連接的Port  $IP:1883.



到ActiveMQ 下,你就會看到Connector 下面有兩種協定, openwire 跟 mqtt.














以上。我們已經完成Broker 在OpenShift 上的設定。下次我們要寫一個簡單的小程式來連接拉!就醬!謝拉!

/////VIDEO COMING SOON////

Comments

Popular posts from this blog

Red Hat JBoss Fuse/A-MQ - Fuse and A-MQ Version 6.3 GA is released!

Fuse and A-MQ 6.3 GA has just went out. Maybe, you would think this is just only a minor version release why should I care? Hold your thoughts on that! Because they have done a lot of improvements and also added many new features into this release.

Besides various bug fixes and making sure Fuse Fabric is much more stable. There are two major change in this version update:

New Tooling in JBoss Developer Studio (JBDS) 9.1 GA. Newer Apache Camel version – Camel v2.17. I was really impressed by the work put in to make developing Camel application much simpler. First is the installation of tooling itself. Now it has a all-in-one installer so you don't need to worry about which plugins you need to check. See the videos below to see the new "Getting Started" of Fuse 6.3.



And If you notice from the above video, the presentation of camel route in JBDS has also updated. It fixed some of the miss representation of logic and making it easier to read.

Old Camel Route
New Camel Route
On …

Fuse Integration Service - Setup JBDS and create first quickstart application

Before we go and start creating our first application, I want to show you how to setup your JBoss Developer Studio, create a small application from the quickstart example and then running it on Fuse Integration Service.

I am using JBoss Developer Studio version 9, you can find it here.
After download the

jboss-devstudio-9.0.0.GA-installer-eap.jar
double-click it, and start installing with default values.

After successful installation, we will need install the plugins for Fuse, on JBoss Central view, select software update, select enable early access.


And select JBoss Fuse Development for the plugin,


Click on install, and we are all set to go!

First thing first, we want to create a Fuse project to deploy on the base of Fuse Integration Service, which is OpenShift. If you have not installed it, please go back to my previous post for instructions. So on your JBDS, right click and start creating the project. Select new, maven project, if you have installed the plugin correctly, you should …

Red Hat JBoss Fuse - Getting Started with Fuse Integration Service 2.0 Tech preview

I just realized that I did not do a getting started for Fuse Integration Service 2.0 Tech preview before I did the pipeline demo, thanks for those of you who reminded me! :)

To get started with FIS 2.0, for people who has just getting to know the technology, here is how I interpret it. Basically, it's divide into two aspect,

1. Integration development, FIS uses Apache Camel as the core technology that creates, orchestrate, compose microservices into a super lightweight thin integration layer, and become the API provider and service orchestrator through exposing RESTful or messaging service endpoints. And you can choose to either package and run it with Spring-Boot or Karaf.


2. Application Deployment and Management, FIS takes advantages of OpenShift platform, and allows you to separately deploy the micro-integration service among distributed environment, at the same time takes care of the failover, high availability, load balancing and service lookup problem for you.


So, now we know …