陳耀明
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- disqus: tecyt --- **RabbitMQ** === ![](https://s3-ap-northeast-1.amazonaws.com/tecyt-hackmd/uploads/upload_e263d88593e794712d0fef084a77af09.png) **安裝** === 1. 安裝 RabbitMQ 服務 http://www.rabbitmq.com/download.html 2. 安裝 Web 管理介面外掛 1. 執行 RabbitMQ Command Prompt 2. 輸入【rabbitmq-plugins enable rabbitmq_management】 3. 重啟 RabbitMQ 服務 3. 開啟網頁 http://localhost:15672 | 帳號 | 密碼  | | ----- | ---- | | guest | guest | **AMQP 基本概念** === ![](https://s3-ap-northeast-1.amazonaws.com/tecyt-hackmd/uploads/upload_394498202fd500cc52317235f9e5a532.png) * **Producer** 發送訊息 * **Connection** Producer / Consumer 和 RabbitMQ 之間的 TCP 連線。 * **Channel** AMQP 不推薦一個應用程式發起多個對 broker 的連線, 因為這樣會消耗系統資源並且也不利於防火牆的配置。AMQP 引入了 Channel 的概念。 一個與 broker 的連線是被多個 Channel 複用的, 因此我們可以將 channel 理解為: 一個共享同一個 TCP 連線的輕量級的連線。 * **Broker** 實作 AMQP 協定的應用。如:RabbitMQ * **Virtual Host** 同一個 broker 中實現不同的相互隔離的環境。 (例當多個不同的用戶使用同一個RabbitMQ Server提供的服務時,可以劃分出多個 Virtual Host,每個用戶在自己的 Virtual Host 創建exchange/queue等)。 ![](https://s3-ap-northeast-1.amazonaws.com/tecyt-hackmd/uploads/upload_a15b1cdbdee7426848212fc5adfefef5.jpg) * **Exchange** 接收 Producer 發佈的訊息,並依照 Exchange Type 和 Binding 的規則發送。 * **Binding** 在 Exchange 中設定。Exchange 和 Queue / Exchange 之間的繫結 * **Routing Key** 在 Binding 中設定。用於 Exchange 決定發送至哪個繫結的 Queue / Exchange。 * **Queue** 存儲訊息 **運作流程** === ![](https://s3-ap-northeast-1.amazonaws.com/tecyt-hackmd/uploads/upload_e4499595b0d5f60d0078d32b9517182f.png =400x400) 模擬運作 http://tryrabbitmq.com/ 1. Producer 發出一筆訊息至 Exchange 2. Exchange 接收到訊息,依 Binding 處理 3. 符合 Binding的設定,將訊息送至 Queue or Exchange 4. 儲存至 Queue 中,等待 Consumer 處理 5. Consumer 處理訊息 **Exchange** === ## 參數介紹 * **Name** 名稱 * **Type** [類型](#Type) ([Direct](#Direct)、[Fanout](#Fanout)、[Topic](#Topic)、[Header](#Header)) * **Durable** 持久性。True:RabbitMQ 重啟後 Exchange 依舊會存在。 * **AutoDelete** 刪除 Exchange 最後一個 Binding 時,自動刪除此 Exchange。 :::info 至少先一個 Binding 的 Queue 或 Exchange 才會觸發。 ::: * **Internal** True:客戶端無法對此 Exchange 操作,只能用於 Binding 使用。 * **Arguments** 啟用 RabbitMQ 擴展功能與設定。 :::info Key Value pairs (Key:擴展功能名稱;value:擴展功能設定值) ::: ## RabbitMQ 擴展功能 ### Alternate Exchange * **功能** Exchange 無法處理 Routing Key 的訊息,轉送指定的 Exchange。 | Exchange Type | 觸發 Alternate Exchange 條件 | | -------- | -------- | | Direct | 無對應的 Routing key | | Topic | 無對應的 Routing key | | Fanout | 無 binding 任何的 Queue / Exchange | | Headers | 無對應的 header pairs (key,value) | ## Type ### **Direct** 發佈訊息方式: 依訊息設定的 Routing Key,找出所有與 Binding 設定的 Routing Key 一樣的 Exchange / Queue 發送。 :::info 【以下圖為範例】 發佈訊息 RoutingKey 【pdf_create】,Queue A 會收到訊息。 ::: ![](https://s3-ap-northeast-1.amazonaws.com/tecyt-hackmd/uploads/upload_bc155696071cf0b7b93a380d7dbb75ee.png) ### **Topic** 發佈訊息方式: 依訊息設定的 RoutingKey,找出所有符合 Binding 設定的 RoutingKey 的 Exchange / Queue 發送。 :::info _Topic 的 Routing Key 可使用符號:_ . ~ 分層 * ~ 代表任意一層 # ~ 代表任意多層 ::: :::info 【以下圖為範例】 發佈訊息 Routing Key 【agreeements.eu.berin】,Queue A、Queue B 會收到訊息。 發佈訊息 Routing Key 【agreeements.eu.headstore】,Queue B、Queue C 會收到訊息。 ::: ![](https://s3-ap-northeast-1.amazonaws.com/tecyt-hackmd/uploads/upload_f7d90d3e7b79ee07cc3461e4cb18a622.png) ### **Fanout** 發佈訊息方式: 發送至所有 Binding 的 Exchange / Queue ![](https://s3-ap-northeast-1.amazonaws.com/tecyt-hackmd/uploads/upload_dfbad53d0552aa84138221eebcf0aef2.png) ### **Header** 發佈訊息方式: 依照訊息設定的 header pairs (key,value),向所有符合 Binding 設定的 x-match 和 header pairs (key,value) 發送 :::info _x-match 可設定參數:_ all(預設值) ~ 符合全部 header pairs any ~ 符合其中一個 header pairs ::: :::info 【以下圖為範例】 發佈訊息 Headers 【format:pdf、type:report】,Queue A、Queue B 會收到訊息。 發佈訊息 Headers 【format:pdf】,Queue B 會收到訊息。 發佈訊息 Headers 【format:zip、type:report】,Queue c 會收到訊息。 ::: :::danger 下方圖 x-match 設定的位置位置是錯誤的,應該設定在 Binding 中。 ::: ![](https://s3-ap-northeast-1.amazonaws.com/tecyt-hackmd/uploads/upload_36e2427c7fe44353fa29d6cedbc7ecee.png) ## 【特殊】 Default Exchange * **功能** 當建立一個 Queue 時,系統自動會與 Default Exchange Binding。 :::info 1. 此 Exchange 為 [Direct](#Direct) 類型 2. Routing Key 為 Queue 的名稱 ::: Queue === ## 設定參數介紹 * **Queue** 名稱 * **Durable** 持久性。True:RabbitMQ 重啟後 Queue 依舊會存在。 :::warning 不包含 Queue 中的訊息持久性 ::: * **Exclusive** 只有建立 Queue 的 Connection 能使用,Connection 關閉後刪除 Queue。 * **AutoDelete** Queue 中的最後一筆訊息在被 Consumer 處理後並 Channel 關閉後删除 Queue * **Arguments** 啟用 RabbitMQ 擴展功能與設定。 Key Value pairs (Key:擴展功能名稱;value:擴展功能設定的值) ## RabbitMQ 擴展功能 ### Max Length (Queue 最大訊息筆數) * **功能** 限制 Queue 保存幾筆訊息 :::info 超過設定值會依照【[Queue Overflow Behaviour 溢出行為](#Overflow-Behaviour-溢出行為)】設定動作 ::: * **Value** :::warning 需設定 >=0 的整數 ::: ### Max Length bytes (Queue 最大 bytes) * **功能** 限制 Queue 的最大 bytes :::info 超過設定值會依照【[Queue Overflow Behaviour 溢出行為](#Overflow-Behaviour-溢出行為)】設定動作 ::: * **Value** | 單位 | | -------- | | bytes | :::warning 需設定 >=0 的整數 ::: ### Auto Expire (Queue 保存時間) * **功能** Queue 未使用時間超過設定的值,刪除 Queue :::info 未使用時間條件包含: 1.時間內 Queue 都無 Consumer 2.時間內無重新 redeclared Queue ::: * **Value** | 單位 | | -------- | | ms | ms :::warning 需設定 >0 的整數 ::: ### Message TTL (Queue 的訊息保存時間) * **功能** 限制 Queue 訊息保存時間 :::info 發佈訊息時也可以設定訊息保存時間,依最低的為準。 ::: * **Value** | 單位 | | -------- | | ms | :::warning 需設定 >=0 的整數 ::: ### Overflow Behaviour (溢出行為) * **功能** 設定因 [Max Length](#Max-Length-Queue-最大訊息筆數)、 [Max Length bytes](#Max-Length-Queue-最大-bytes) 所刪除的訊息的行為。 * **Value** * 可設定的行為 | 參數 | 功能說明 | | -------- | -------- | | drop-head <font color="red">(預設值)</font> | 刪除 Queue 第一個的訊息 | | reject-publish|拒絕目前發佈訊息| ### Dead Letter Exchange (死信 Exchange) * **功能** 訊息因以下情況被刪除,訊息會轉送至指定的 Exchange 1. *訊息被拒絕(basic.reject or basic.nack),且 requeue=false* **(此條件未測試過)** 2. 超過 [Message TTL](#Message-TTL-Queue-的訊息保存時間) 3. 超過 [Max Length](#Max-Length-Queue-最大訊息筆數) 4. 超過 [Max Length bytes](#Max-Length-Queue-最大-bytes) * **Value** Exchange 名稱 ### Dead Letter Routing Key * **功能** 設定觸發 [Dead Letter Exchange](#Dead-Letter-Exchange-死信-Exchange) 時,轉送訊息至 Exchange 時,需要用的 Routing Key。 ::: warning 需要先設定 [Dead Letter Exchange](#Dead-Letter-Exchange-死信-Exchange) ::: * **Value** Routing Key ### Maximum Priority * **功能** 啟用優先權功能,並設定發布訊息時可設定的最大的優先權。優先權越大越先發送給 Consumer :::info 當訊息的優先權超過最大值時,等於最大優先權。 e.g. 最大值為 10,訊息1 設定 11,訊息2 設定為 10。此兩筆訊息的優先權是一樣的。 ::: :::warning 當 Consumer 一直在等待訊息時,優先權就無功用。 ::: * **Value** 最大值: 255 ( RabbitMQ 建議最大值為 10 ) 最小值: 0 :::info RabbitMQ 建議 max 設定 10。 we recommend using between 1 and 10. Currently using more priorities will consume more resources (Erlang processes) ::: :::warning 優先權最大值設定越大,會有效能影響。 ::: ### Lazy Mode * **功能** 未設定時 Queue 中的訊息會放在 Memory;設定此功能後 Queue 中的訊息會放在 Disk 中,Consumer 要使用時才放入 Memory。 * **Value** | 參數 | 功能說明 | | -------- | -------- | | default <font color="red">(預設值)</font> | Queue 中的訊息會放在 Memory | | lazy|Queue 中的訊息會放在 disk 中,要使用時才放在 memory 中| ### Master Locator * **功能** 設定在高可用的 Master 選擇方式 * **Value** | 參數 | 功能說明 | | -------- | -------- | | min-masters|| | client-local|| | random|| Producer === ## 設定參數介紹 * **Exchange** 發送到哪個 Exchange * **Routing Key** * **Delivery Mode** * **Headers** * **Properties** | 參數 | 說明 | | -------- | -------- | | Content Type|| | Content Encoding|| | Priority|| | Correlation ID|| | Reply To|| | Expiration|| | Message ID|| | Timestamp|| | Type|| | User ID|| | App ID|| | Reserved|| :::info 只列出 RabbitMQ 會有功能的參數,如果其他參數有功能通知我。 > [name=Yumin] ::: * Expiration * 保存時間 * Persistent、DeliveryMode * 訊息持久化,擇一設定即可 * **Payload** 訊息內容 Consumer === * **Queue** 要從哪個 Queue 取得訊息 * **AutoAck** AutoAck 為 False,接收到訊息後需回傳 BasicAck ,Queue 才會刪除,如果此 channel 關閉,Queue 才會將未回傳 BasicAck 的訊息轉至其他 Consumer 處理。 Policy === 康敏順 . . . Plugins === 康敏順 . . . 權限 === 康敏順 . . . HA (整理中) === ## 類型 * 普通 * 只複製設定,不含資料 * 鏡像 * 複製設定與資料 * 操作 Tag === ###### tags: `Queue`,`AMQP`,`RabbitMQ`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully