RabbitMq應用在傳送簡訊

2021-07-05 22:15:43 字數 2438 閱讀 5705

首先安裝mq在機器上,註冊使用者名稱和密碼

簡訊傳送分為server端和client端:

org.springframework.amqpgroupid>

spring-rabbitartifactid>

1.4.3.releaseversion>

dependency>

rabbitmq.properties的配置

rabbit_server_username=使用者名稱

rabbit_server_password=密碼

rabbit_server_host=ip位址

rabbit_heart_beat=120

client端的呼叫:

id="propertyconfigurer"

class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">

name="location"

value="classpath:rabbitmq.properties" />

bean>

id="connectionfactory"

host="$"

username="$"

password="$"

requested-heartbeat="$" />

connection-factory="connectionfactory"/>

id="queue名字"

durable="true"

auto-delete="false"

exclusive="false"

name="queue名字"/>

name="exchange名字" >

key="queue名字"

queue="queue名字"/>

rabbit:bindings>

rabbit:direct-exchange>

exchange="exchange名字"

id="amqptemplate"

queue="queue名字"

connectionfactory="connectionfactory"

message-converter="傳遞方式messageconvertconfig"/>

然後在自己的方法中呼叫

public

void

send()

}

server端的配置和編寫

在spring中配置mq

id="propertyconfigurer"

class="org.springframework.beans.factory.config.propertyplaceholderconfigurer">

name="location"

value="classpath:rabbitmq.properties" />

bean>

id="connectionfactory"

host="$"

username="$"

password="$"

requested-heartbeat="$" />

connection-factory="connectionfactory"/>

id="queue名字"

durable="true"

auto-delete="false"

exclusive="false"

name="queue名字"/>

name="exchange名字" >

key="queue名字"

queue="queue名字"/>

rabbit:bindings>

rabbit:direct-exchange>

id="實現類id"

class="實現類" />

connection-factory="connectionfactory">

ref="實現類id"

queue-names="queue名字"/>

rabbit:listener-container>

實現類編寫

public

class 實現類 implements

messagelistener

}

實現messagelistener 的介面監聽訊息佇列,當有訊息傳送到佇列中時就會呼叫到服務端的onmessage方法

實現傳送到佇列訊息

rabbitmq安裝教程:

MAC設定應用在127 0 0 1 80

部落格 1.mac設定應用在127.0.0.1 80埠訪問 config index.js目錄下修改host和port 然後sudo執行npm run dev mac的80埠是被自身分享應用占用的,使用的話需要root許可權 sudo npm run dev執行完後,在127.0.0.1 80下能訪...

變數的應用在spool時

spool的sql語句很是複雜,為了減少執行時間提高效能,我考慮了首先根據索引找出符合條件的記錄總數,並根據總數是否大於0,來對要執行的sql新增條件。如 sql variable a2 number sql select count into a2 from table where length ...

QT應用在Windows下部署發布

剛接觸qt,對於其在windows下部署一頭霧水。網上相應的資料很多都是手工程度比較高的,在這裡我們可以使用qt自帶的發布工具 windeployqt.exe。該檔案在qt的安裝目錄下,我windows平台使用的mingw版本 5.8 其路徑為 d qt qt5.8.0 5.8 mingw53 32...