Skip to main content

Red Hat JBoss A-MQ - A-MQ 在物聯網上的應用,生物感應器Sensor 透過AMQP通訊協定傳送資料


最近越來越多人在談物聯網(Internet of Things,簡寫 IoT ),如果你已經知道物聯網,那請直接跳過,直接往Demo 奔去吧。什麼是物聯網?根據我幫大家Google 過後的定義如下,

"物聯網(The Internet of Things)的概念是在1999年提出的,它的定義:把所有物品通過射頻識別等信息感測設備與互聯網連接起來,實現智能化識別和管理。"

簡單來說,在古早的年代,會聯結上網路的,通常都是一台電腦,可是因為科技的日新月異,網路越來越發達,手持裝置(手機,智慧型眼鏡,血壓計),家電設備(冰箱,電視,烤箱),行車器材(GPS, 行車記錄器)等等,都可以透過不同的雲端技術連接上網。而這些裝置會將大量的資料傳送上網(或者你也可以說,雲端)。不過你想想,當這些龐大的資料同時傳送,而且每一項設備裝置都可能使用不同的通訊協定以及方式,那我們要用什麼樣的東西去接收,才能確保資料穩定接收的成功呢?

這時,一項"古老"的技術,又被人們想起來了。也就是訊息平台 Messaging Platform. 因為它可以大量接受訊息然後同時傳送,或是可以佇列式的讓訊息排隊等待處理的天性。而最近又因應不同的裝置,而發展了屬於不同狀況可以使用的通訊協定。

STOMP (Streaming Text Oriented Messaging Protocol)
=========================================
完全是純文字的通訊協定,所以不管是什麼語言,或是哪家的訊息Broker 都可以支援。
也因為它是純文字,在效能上可能就不及其他的通訊協定。


MQTT (MQ Telemetry Transport)
======================================
這算是所有通訊協定裡面最"輕量"的,因為他是專門設計給再遠端的連接方,沒有太好的網路頻寬。因此它擁有 "small code footprint" 。它只能很簡單的把訊息送達Broker, Broker 接收訊息後,如果有需要,會再把訊息導到需要這個訊息的地方。

AMQP (Advanced Message Queuing Protocol)
======================================
通訊協定的標準,是功能上比較完整的標準通訊協定。所以大部份的Broker 都會支援它。在程式撰寫部分,也可以透過JMS 與 Apache QPid 這個專案輔助即可。


我們這次的Demo 就是假設人體現在身上帶著不少的Sensor(感應器), 感應器會隨時回傳資料到雲端方便監控。請到Github 去下載程式。

https://github.com/weimeilin79/amqp-demo-web-biomedical

下面的影片有安裝教學,或者是你也可以發摟 Github上面的ReadMe 即可。

PS. 有誰有弄來幫我寫個Windows 的bat 安裝檔?我不想在我電腦上裝Windows, 連VM 我都嫌浪費空間喇~有誰可以幫忙弄一下?


生物感應器Sensor 透過AMQP通訊協定傳送資料 from christina on Vimeo.



Comments

Chisoon Chang said…
I found this demo and great demo on youtube. while I tried to conduct the demo on my RHEL 6 with JBoss DS 8.1 installed box. I followed your steps on the page, however, I could not run the ./amq and it return many errors using karaf, felix, commons, fabric....etc by "Unresolved constraint in bundle...". executing 'mvn jetty:run' return "build successfully". I have run some other apache/camel exemples, so I have ./m2/depository.. on my machine. Is anything I missed on my local depository?
Chisoon Chang said…
After googling on line, I found that my java 1.8 was not compatible with jboss-am-q-6.1. I needed to install the jboss-am-q-6.2. Started Ok with 6.2. However, when I started this web project - mvn jetty:run, I got a lot of errors on "ConnectionException... by connection refused" on jmx when I started the monitoring on the web page. What should I correct on the web project on my local station or I missed sth? I am newbie on using such project. Pls advice. Tnx.
Chisoon Chang said…
track further about the source of error, then I found out that with the am-q, there many error logs about "Cannot find class [org.fusesource.mq.fabric.ConfigurationProperties] for bean with name 'org.fusesource.mq.fabric.ConfigurationProperties#0' defined in URL [file:etc/activemq.xml]: Cannot create inner bean 'org.fusesource.mq.fabric.ConfigurationProperties#32db643c' of type [org.fusesource.mq.fabric.ConfigurationProperties] while setting bean property 'properties'; " therefore the connection was refused. How do I trace such error?
Chisoon Chang said…
Rolled back to default activemq.xml from Jboss-a-mq-6.2 pkg, with io.fabric8.mq.., the demo program could run, however, it only generated one message of each monitor (by the terminal console), so sth went run with the org.fusesource.mq.. in class. Strangely, the 6.2 document on Redhat site, states that the broker config file uses while the package itself uses the "io.fabric8.mq..." what exact it should be?
Chisoon Chang said…
Comparing the etc/ of both jboss-a-mq 6.1 vs that 6.2, the org.fusesource.mq.fabric.server-default.cfg (both org.fusesource...cfg files) of 6.1 has been replaced by io.fabric8.mq.fabric.server-broker.cfg in 6.2. None the less, the content of both files have little change, except the io.fabric8 one has additional mq.fabric.server.pid and mq.fabric.server.ts and using io.fabric8.mq.fabric.server server. Is that the cause of error? still with error of "Cannot find class [org.fusesource.mq.fabric.ConfigurationProperties] for bean with name 'org.fusesource.mq.fabric.ConfigurationProperties" (even copied both org.fusesource.mq..cfg to /etc/ of 6.2)

Popular posts from this blog

JBoss EAP 6 - 效能調校 (一) DataSource 的 Connection Pool

效能沒有什麼Best Practice, 反正能調整的就那些。 通常,一個程式的效能大概有70-80% 都跟程式怎麼寫的其實比較有關係。

最近我最疼愛的小貓Puji 因為膀胱結石開刀的時候過世了,心情很差請原諒我的口氣沒有很好,也沒有心情寫部落格。

Puji R.I.P.

=======================正文=======================

這個題目很多人叫我寫,可是這題目好大,這分明就是整死我咩~
所以我會分幾段慢慢寫。

JBoss 的 SubsystemDatasource WebWeb Service EJB Hibernate JMSJCAJVM 調校OS (作業系統)

先來看一下 DataSource Subsystem, DataSource 的部分主要是針對Connection Pool 做調校。

通常,程式都會需要跟資料庫界接,電腦在本機,尤其是在記憶體的運算很快,但是一旦要外部的資源連接,就是會非常的耗資源。所以現在的應用程式伺服器都會有個Pool 放一些先連接好的 資料庫connection,當程式有需要的時候就可以馬上提供,而不用花那些多餘的資源去連接資料庫。

這就是為什麼要針對Connection Pool 去做調校。

以下會討論到的參數,都是跟效能比較有關係,Datasource 還有很多參數,像是檢核connection 是否正確的,我都不會提到。如果你追求的是非常快速的效能,那我建議你一個檢核都不要加。當然,這樣就會為伺服器上面執行的程式帶來風險。這就是你要在效能與正確,安全性上面的取捨了。 (套句我朋友說的話,不可能又要馬兒好,又要馬兒不吃草的..)

最重要的調校參數就是 Connection 的 Pool 數量。(也就是那個Pool 裡面要放幾條的connection.) 這個參數是每一個應用程式都不一樣的。

min-pool-size 

Connection Pool 最少會存留的connection 數量

max-pool-size 

Connection Pool 最多可以開啓的 connection 數量

prefill

事先將connection pool 裡面建立好min-pool-size 的connection.

我的建議是觀察一下平常程式要用到的量設定為 min-pool-size 。
加上…

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 …

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 …