|
@@ -9,7 +9,6 @@ import org.bfkj.utils.MapTools;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.concurrent.TimeoutException;
|
|
@@ -28,9 +27,11 @@ public class MyRabbitMQ {
|
|
|
}
|
|
|
|
|
|
Map<String, Object> connectConfigMaps = (Map<String, Object>) MapTools.strToObj(connectConfig);
|
|
|
+ Object arguments = connectConfigMaps.get("arguments");
|
|
|
+// Object prefetchCount = connectConfigMaps.get("prefetchCount");
|
|
|
try (Connection connection = createConnectFactory(connectConfigMaps).newConnection(); Channel currentChannel = connection.createChannel();) {
|
|
|
//创建消息通道
|
|
|
- currentChannel.queueDeclare(sourceObjectName, true, false, false, null);
|
|
|
+ currentChannel.queueDeclare(sourceObjectName, true, false, false, Objects.isNull(arguments)?null: ((Map<String,Object>) arguments));
|
|
|
currentChannel.basicQos(1); //服务端在同一时刻只发送1条数据
|
|
|
GetResponse getResponse = currentChannel.basicGet(sourceObjectName, true);
|
|
|
String repBody = null;
|
|
@@ -65,11 +66,11 @@ public class MyRabbitMQ {
|
|
|
*
|
|
|
* @return 发送结果信息
|
|
|
*/
|
|
|
- public Map<String,Object > sendMethod(String sourceObjectName, String routingKey, String data, String connectConfig, String exchangeName) {
|
|
|
+ public Map<String, Object> sendMethod(String sourceObjectName, String routingKey, String data, String connectConfig, String exchangeName) {
|
|
|
if (Objects.isNull(sourceObjectName) || Objects.isNull(data)) {
|
|
|
return MapTools.processFail(Objects.isNull(sourceObjectName) ? ("队列为空 " + data) : ("数据内容为空 " + data));
|
|
|
}
|
|
|
- Map<String, Object> connectConfigMaps = (Map<String, Object>) MapTools.strToObj(connectConfig);
|
|
|
+ Map<String, Object> connectConfigMaps = (Map<String, Object>) MapTools.strToObj(connectConfig);
|
|
|
ConnectionFactory connectFactory = createConnectFactory(connectConfigMaps);
|
|
|
try (Connection connection = connectFactory.newConnection()) {
|
|
|
try (Channel channel = connection.createChannel()) {
|