-
1. Re: How to access JBoss port offset in my application?
nickarls Dec 19, 2012 1:37 PM (in response to clempinch)1 of 1 people found this helpfulIf you connect with jboss-cli -c and do a
[standalone@localhost:9999 /] /socket-binding-group=standard-sockets:read-attribute(name="port-offset")
you get a
{
"outcome" => "success",
"result" => expression "${jboss.socket.binding.port-offset:0}"
}
which leads me to (without testing) believe that absolute values can be read in the same way. And that same attribute could also be read from within the application with a ModelControllerClient...
-
2. Re: How to access JBoss port offset in my application?
clempinch Dec 20, 2012 11:57 AM (in response to nickarls)Thank you for your reply.
It works! Here is the code using ModelControllerClient:
public int getOffset() {
ModelControllerClient client = null;
try {
ModelNode op = new ModelNode();
op.get(ClientConstants.OP).set("read-attribute");
op.get("name").set("port-offset");
op.get(ClientConstants.OP_ADDR).add("socket-binding-group", "standard-sockets");
client = ModelControllerClient.Factory.create("localhost", 9999);
ModelNode response = client.execute(new OperationBuilder(op).build());
return Integer.parseInt(response.get(ClientConstants.RESULT).toString());
} catch (UnknownHostException e) {
// handle the exception
return 0;
} catch (IOException e) {
// handle the exception
return 0;
} finally {
if (client != null) {
try {
client.close();
} catch (IOException e) {
// handle the exception
}
}
}
}
My concerns now are: how to avoid the remote calls to localhost:9999 and how to integrate this to my application as a system property...
I think I will try what is proposed there: http://management-platform.blogspot.fr/2012/07/co-located-management-client-for.html
But this is another debate.
-
3. Re: How to access JBoss port offset in my application?
nickarls Dec 21, 2012 2:00 AM (in response to clempinch)The direct service lookup has the advantage that you don't need to know the management port in advance.