How to create connection to AMQP queue over SSL using SOCKS proxy or any other proxy in java

a 夏天 提交于 2021-01-29 08:49:24

问题


Using using SOCKS proxy or any other Proxy, is there any way to connect to amqp queue over SSL using org.apache.qpid.jms.JmsConnectionFactory for environments where direct internet access is not available or amqps connection port is blocked by firewall.

I have tried connecting to amqp queue over SSL using org.apache.qpid.jms.JmsConnectionFactory on environments where internet is available.It is working fine!!!


回答1:


Using the latest release of the Qpid JMS client (0.47.0 as of this answer) you can create your own Netty ProxyHandler instance that controls how the client connects through a proxy and configure it on the Connection Extensions as documented in the code here: the Factory exposes this via the setter for connection extensions. The test case for this feature shows some usages.

Supplier<ProxyHandler> proxyHandlerSupplier = () -> {
    return new Socks5ProxyHandler(new InetSocketAddress("localhost", getPort()));
};

JmsConnectionFactory factory = new JmsConnectionFactory(remoteURI);
    factory.setExtension(JmsConnectionExtensions.PROXY_HANDLER_SUPPLIER.toString(), (connection, remote) -> {
        return proxyHandlerSupplier;
    });


来源:https://stackoverflow.com/questions/58803510/how-to-create-connection-to-amqp-queue-over-ssl-using-socks-proxy-or-any-other-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!