如何使用SOCKS代理或Java中的任何其他代理通过SSL创建与AMQP队列的连接 [英] How to create connection to AMQP queue over SSL using SOCKS proxy or any other proxy in java

查看:76
本文介绍了如何使用SOCKS代理或Java中的任何其他代理通过SSL创建与AMQP队列的连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用SOCKS代理或任何其他代理,对于无法直接访问Internet或防火墙禁止amqps连接端口的环境,有什么方法可以使用org.apache.qpid.jms.JmsConnectionFactory通过SSL连接到amqp队列.

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.

我已经尝试在可以使用Internet的环境中使用org.apache.qpid.jms.JmsConnectionFactory通过SSL连接到amqp队列.它工作正常!!!

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!!!

推荐答案

使用Qpid JMS客户端的最新版本(截至本回答为0.47.0),您可以创建自己的Netty ProxyHandler实例,该实例控制客户端如何通过该实例进行连接代理,并按照代码测试用例显示了一些用法.

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;
    });

这篇关于如何使用SOCKS代理或Java中的任何其他代理通过SSL创建与AMQP队列的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆