Apache ActiveMQ - 測試應用程式主題



啟動 ActiveMQ 伺服器

現在我們啟動 ActiveMQ 伺服器。轉到 F:/ → Apache → apache-activemq-5.16.4/bin 資料夾,並鍵入以下命令。

示例

F:\Apache\apache-activemq-5.16.4\bin>activemq start

輸出

您將看到類似的輸出,並且 ActiveMQ 將開始執行。

...
INFO | Apache ActiveMQ 5.16.4 (localhost, ID:DESKTOP-86KD9FC-52669-1645860020983-0:1) started
INFO | For help or more information please see: http://activemq.apache.org
INFO | ActiveMQ WebConsole available at http://127.0.0.1:8161/
INFO | ActiveMQ Jolokia REST API available at http://127.0.0.1:8161/api/jolokia/

啟動釋出者應用程式

在 Eclipse 中,右鍵單擊 Publisher.java 源,然後選擇 Run As → Java Application。釋出者應用程式將開始執行,您將看到如下輸出 −

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Enter message:

啟動訂戶應用程式

在 Eclipse 中,右鍵單擊 Subscriber.java 源,然後選擇 Run As → Java Application。訂戶應用程式將開始執行,您將看到如下輸出 −

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

啟動另一個訂戶應用程式

在 Eclipse 中,再次右鍵單擊 Subscriber.java 源,然後選擇 Run As → Java Application。另一個訂戶應用程式將開始執行,您將看到如下輸出 −

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

傳送訊息

在釋出者控制檯視窗中,鍵入 Hi 並按 Enter 鍵傳送訊息。

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Enter message:
Hi

接收訊息

在訂戶控制檯視窗中驗證,該訊息在每個視窗中都已接收。

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Received = Hi

作為訊息傳送 Quit 以終止所有釋出者和訂戶控制檯視窗會話。

驗證

現在在您的瀏覽器中開啟 http://127.0.0.1:8161/admin/。它將要求提供憑證。使用 admin/admin 作為使用者名稱/密碼,它將載入 ActiveMQ 管理控制檯,您可以在其中檢查主題以檢視狀態。它將顯示排隊和傳遞的多個訊息。

Topics
廣告