Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy in Rabbitmq Java Client

Tags:

java

rabbitmq

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.

like image 264
Chiranjit.B Avatar asked Nov 09 '22 16:11

Chiranjit.B


1 Answers

You have to setup a SOCKS Proxy.

see: http://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html

like image 83
trunkc Avatar answered Nov 14 '22 23:11

trunkc