gpt4 book ai didi

java - Rabbitmq Java 客户端中的代理

转载 作者:搜寻专家 更新时间:2023-10-31 20:32:50 26 4
gpt4 key购买 nike

有什么方法可以为 RabbitMQ Java 客户端设置代理吗?

package com.rabbitmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.MessageProperties;

public class SendToRabbitMQ {
private final static String QUEUE_NAME = "observation_queue";

public static void sendObservation(String observation) {
try {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("x.x.x.x");
factory.setUsername("test");
factory.setVirtualHost("test_vh");
factory.setPassword("test");
Connection con = factory.newConnection();
Channel channel = con.createChannel();
channel.queueDeclare(QUEUE_NAME, true, false, false, null);
channel.basicPublish( "", QUEUE_NAME,
MessageProperties.PERSISTENT_TEXT_PLAIN,
observation.getBytes());
System.out.println(" Ovservation Sent '" + observation + "'");
channel.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}


}
}

我想为此连接设置代理。

最佳答案

关于java - Rabbitmq Java 客户端中的代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36639696/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com