mirror of https://github.com/apache/activemq.git
support defining local address and port for a socket - e.g:
ssl://localhost:5666/localhost:60606 where the path (localhost:60606) - defines the local address and local port For jira issue: AMQ-529 git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@375922 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f367df5b28
commit
c195dd3052
|
@ -61,7 +61,26 @@ public class SocketStreamChannelFactory implements StreamChannelFactory {
|
||||||
*/
|
*/
|
||||||
public StreamChannel openStreamChannel(URI location) throws IOException {
|
public StreamChannel openStreamChannel(URI location) throws IOException {
|
||||||
Socket socket=null;
|
Socket socket=null;
|
||||||
socket = socketFactory.createSocket(location.getHost(), location.getPort());
|
String path=location.getPath();
|
||||||
|
// see if the path is a local URI location
|
||||||
|
if(path!=null&&path.length()>0){
|
||||||
|
if (path.indexOf('/')==0){
|
||||||
|
//strip leading slash
|
||||||
|
path = path.substring(1,path.length());
|
||||||
|
}
|
||||||
|
int localPortIndex=path.indexOf(':');
|
||||||
|
try{
|
||||||
|
int localPort = Integer.parseInt(path.substring((localPortIndex+1),path.length()));
|
||||||
|
InetAddress localAddress = InetAddress.getByName(path);
|
||||||
|
socket = socketFactory.createSocket(location.getHost(), location.getPort(),localAddress,localPort);
|
||||||
|
}catch(Exception e){
|
||||||
|
System.err.println("Could not define local address and port from path: " + path);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (socket==null){
|
||||||
|
socket = socketFactory.createSocket(location.getHost(), location.getPort());
|
||||||
|
}
|
||||||
return createStreamChannel(socket);
|
return createStreamChannel(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue