You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/03/01 10:25:00 UTC

[jira] [Work logged] (ARTEMIS-3699) EmbeddedActiveMQ port configuration

     [ https://issues.apache.org/jira/browse/ARTEMIS-3699?focusedWorklogId=734481&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-734481 ]

ASF GitHub Bot logged work on ARTEMIS-3699:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/Mar/22 10:24
            Start Date: 01/Mar/22 10:24
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on a change in pull request #3969:
URL: https://github.com/apache/activemq-artemis/pull/3969#discussion_r816627195



##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
##########
@@ -715,6 +717,9 @@ private void startServerChannels() {
          Channel serverChannel = null;
          try {
             serverChannel = bootstrap.bind(address).syncUninterruptibly().channel();
+            if (port == 0 && serverChannel.localAddress() instanceof InetSocketAddress) {
+               ephemeralPort = ((InetSocketAddress)serverChannel.localAddress()).getPort();
+            }

Review comment:
       I'd suggest going with 'actualPort' and setting it in each case (port== 0 or not), thus having the getter always return the port value, whether it is a specified non-0 port or a port-0 selected-on-bind value.
   
   That way the method is always useful, even in case of a configured port to get the value (as opposed to trying the config retrieval sequence from the JIRA), and it wont require you to essentially already know in advance of calling whether the acceptor had one configured or selected on bind.

##########
File path: artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
##########
@@ -241,6 +241,8 @@
 
    private volatile Object providerAgnosticSslContext;
 
+   private int ephemeralPort = 0;

Review comment:
       This should probably be volatile for safety since it seems it will have to be accessed by a different thread in actual use (most likely straight after setting), so unless there is an explicit barrier between them somewhere it would be unreliable otherwise.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 734481)
    Time Spent: 20m  (was: 10m)

> EmbeddedActiveMQ port configuration
> -----------------------------------
>
>                 Key: ARTEMIS-3699
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3699
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>            Reporter: Robin
>            Assignee: Justin Bertram
>            Priority: Minor
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> When creating an instance of EmbeddedActiveMQ the port that the broker binds to is taken from the acceptor uri supplied to the configuration. Afterwards there is no easy way to get the port out of the broker instance. In addition, it would have been nice if one could provide 0 for port to have it start up on a random available port. Could this be implemented?
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)