Skip to content

Custom ActiveMQ - dynamic url#124

Merged
brunovg merged 8 commits intodevelopfrom
feature/issue-123/custom-activemq---dynamic-url
Apr 17, 2023
Merged

Custom ActiveMQ - dynamic url#124
brunovg merged 8 commits intodevelopfrom
feature/issue-123/custom-activemq---dynamic-url

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Apr 5, 2023

Original issue description

change the custom activemq url, to a dynamic one

closes #123

@github-actions github-actions bot added the feature New feature or request label Apr 5, 2023
@brunovg brunovg requested a review from skin27 April 5, 2023 16:33
@brunovg brunovg marked this pull request as ready for review April 5, 2023 16:33
String activemqName = "activemq";
String activemqUrl = "tcp://localhost:61616";
String environment = props.get("environment");
String activemqUrl = String.format("tcp://assimbly-broker-%s:61616", environment);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@brunovg brunovg requested a review from pedrocatalao April 12, 2023 17:10
Component activemqComp = this.context.getComponent(activemqName);
if(activemqComp!=null) {
if (activemqComp instanceof ActiveMQComponent) {
String brokenUrl = ((ActiveMQComponent) activemqComp).getBrokerURL();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brokenUrl 😜

Copy link
Collaborator

@brunovg brunovg Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected 😅

} catch (UnknownError e) {
log.info("Error to build custom environment - hostname:"+InetAddress.getLocalHost().getHostName());
}
return environment;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

@pedrocatalao pedrocatalao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@brunovg brunovg merged commit e4acdaf into develop Apr 17, 2023
@brunovg brunovg deleted the feature/issue-123/custom-activemq---dynamic-url branch April 17, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants