Is there any way to set a proxy to a RabbitMQ Java client?
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();
}
}
}
I want to set a proxy for this Connection.
You have to setup a SOCKS Proxy.
see: http://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With