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 Fuse - Announcing Fuse 7 Tech preview 3 release.

Red Hat Fuse 7.0 technical preview three is out today! On the pathway to become one of the best cloud-native integration platform, Fuse gives developer freedom to choose how they want to develop the integration solution, where they want to deploy it and capabilities to address new integration personas that do not have development experience.
By supporting the three major runtime, developer is free to work on the runtime of their choice.By supporting standalone and cloud deployment, it simplifies the complexity to distinguish between these environments, allowing application to deploy freely among the environment of your choice. All levels of developers are welcome, you can either dive deep into creating customize complex integration logic, or using the new low code platform to quickly build a simple integration. In this Tech Preview release you get it all.
Fuse StandaloneSpring-boot for microserviceKaraf 4 for OSGi loverJBoss EAP for JavaEE developersFuse on OpenShiftPlugins for easy co…

The rise of Agile Integration, Integration is not DEAD nor LAME!

I wanted to blog about this for a very long time, but because of work and being too lazy to turn on my laptop on the weekends, now I finally have a couple of hours to sit down and start blogging.

"Integration is DEAD."
"No, no, let's talk about microservice!!"
"What is that again? Integration, you mean SOA? It's lame... ".

These makes the majority of the percentage when I talk about Integration. In fact, if you happen to be in any the software conference, you see the rooms full when it's about "container" and "microservice." I understand the nature of a developer, always seeking for the latest and greatest technology out there. BUT!! In my opinion, I don't think Integration is going AWAY if you containerize your application. Neither does it will DISAPPEAR in a microservice architecture. In fact, Integration just gets more complicated and tricky when you try to break an application into smaller pieces and have them runni…