Ah, now i see!
But i wonder: is there a conflict when using the URI like this, because there might be already another use of the path-part w.r.t to the active-mq configuration. However, it could be argued that this use is restricted to the "tcp" scheme and as long as there is no conflicting using _within_ the "tcp" scheme it'll work out. However, what if the "auto" schema was specified in the original config file, and maybe the "auto" scheme passes the uri-path along to the detected actual scheme, and then two possible actual schemes have surprisingly different interpretations of the uri-path. *) the URI location passed as parameter to the createTransport function: is the location.getScheme() always "tcp"? even if the original configuration is something like "auto://localhost:61616"? *) if the path part of location indeed has no conflicting purpose, i would propose - as a first idea - a patch similar to the diff attached. (Note: i didn't compile yet, let alone test) with regards, Max > [ w.r.t TcpTransport ] > > > OK, try a url like this: > > tcp://localhost:61616/localhost:56565 > > > You'll find it connects to localhost:61616 and binds to localhost:56565 > > I don't see any documentation on the website for this feature though. > > Art >
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java b/activemq-client/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
index ae555fdf1..dd0740008 100644
--- a/activemq-client/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
@@ -125,15 +125,20 @@ public class TcpTransportFactory extends TransportFactory {
protected Transport createTransport(URI location, WireFormat wf) throws UnknownHostException, IOException {
URI localLocation = null;
String path = location.getPath();
- // see if the path is a local URI location
- if (path != null && path.length() > 0) {
+ // see if the path specifies a local bind location
+ // Note: neither hostname nor port are optional if a local bind location
+ // is provided.
+ if (path != null && path.length() > 0 && !path.equals("/")) {
int localPortIndex = path.indexOf(':');
try {
+ // Note: assumes that exception is thrown on empty string, which
+ // is not guaranteed according to java.lang.Integer documentation
+ // but nevertheless true in all known jre implementations.
Integer.parseInt(path.substring(localPortIndex + 1, path.length()));
String localString = location.getScheme() + ":/" + path;
localLocation = new URI(localString);
} catch (Exception e) {
- LOG.warn("path isn't a valid local location for TcpTransport to use", e.getMessage());
+ LOG.warn("path isn't a valid local location for TcpTransport to use: {}", e.getMessage());
if(LOG.isDebugEnabled()) {
LOG.debug("Failure detail", e);
}
signature.asc
Description: OpenPGP digital signature
