將隊列和交換器綁定的方法如下,可以與前兩節中的方法定義(exchangeDeclare和queueDeclare)進行類比。
1.Queue.BindOk queueBind(String queue, String exchange, String routingKey) throws IOException; 2.Queue.BindOk queueBind(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException; 3.void queueBindNoWait(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException;
方法中涉及的參數詳解。
queue: 隊列名稱
exchange: 交換器的名稱
routingKey: 用來綁定隊列和交換器的路由鍵;
argument: 定義綁定的一些參數。
不僅可以將隊列和交換器綁定起來,也可以將已經被綁定的隊列和交換器進行解綁。具體方法可以參考如下(具體的參數解釋可以參考前面的內容,這里不再贅述):
1.Queue.UnbindOk queueUnbind(String queue, String exchange, String routingKey) throws IOException; 2.Queue.UnbindOk queueUnbind(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException;