Conversation
…ps://github.com/assimbly/runtime into feature/issue-123/custom-activemq---dynamic-url
| String activemqName = "activemq"; | ||
| String activemqUrl = "tcp://localhost:61616"; | ||
| String environment = props.get("environment"); | ||
| String activemqUrl = String.format("tcp://assimbly-broker-%s:61616", environment); |
There was a problem hiding this comment.
Does this work locally? Maybe better create two properties host and port. In this case you can also use localhost as host and assimbly-broker-test. Another option is that when environment is empty fall back to localhost.
There was a problem hiding this comment.
Ok. If environment is not specified it will use localhost.
In my local environment, the environment property is not set. There's another way to get this info?
| Component activemqComp = this.context.getComponent(activemqName); | ||
| if(activemqComp!=null) { | ||
| if (activemqComp instanceof ActiveMQComponent) { | ||
| String brokenUrl = ((ActiveMQComponent) activemqComp).getBrokerURL(); |
| } catch (UnknownError e) { | ||
| log.info("Error to build custom environment - hostname:"+InetAddress.getLocalHost().getHostName()); | ||
| } | ||
| return environment; |
There was a problem hiding this comment.
You could also return an optional and then outside use ifPresent, this also makes the code simpler since you don't have to pass the previously set environment string to the method
|
|
||
| private String buildCustomEnvironment(String environment) throws UnknownHostException { | ||
| try { | ||
| String hostname = InetAddress.getLocalHost().getHostName(); |
There was a problem hiding this comment.
for the karaf backend's there is an environment variable set DOVETAIL_ENV=test maybe it's a more reliable way to do it because I also found that for instance when you get into the flux-test backend container in acceptance, the hostname returns acceptance-test 🤔
I'm also not sure how often this is called but take into consideration that this might be a bit slow so if it's called many times, might be a good idea to extract this (and others) value at "boot" time only once, instead of going to the OS level during normal runtime
Original issue description
change the custom activemq url, to a dynamic one
closes #123