[ 
https://issues.apache.org/jira/browse/ARTEMIS-2950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17214611#comment-17214611
 ] 

Dimos Raptis commented on ARTEMIS-2950:
---------------------------------------

Having a quick look at the documentation, I could not find a clear piece on 
whether this is supposed to happen synchronously or asynchronously. However, 
the documentation that covers programmatic startup of a broker (e.g. 
[this|https://activemq.apache.org/components/artemis/documentation/1.1.0/embedding-activemq.html])
 makes it appear as if it is a synchronous startup without the need to use any 
callbacks. Also, if I understand correctly what you're saying, trying to start 
a broker from the command line will fail silently under the hood without the 
user being able to notice the port is already taken. I think this is suboptimal 
and should be fixed, if so.

 

Going back to the issue, I can confirm that I can work around the issue by 
converting the following code (Kotlin):
{code:java}
activeMQServer.start() {code}
into the following:
{code:java}
val startupFuture = CompletableFuture<Unit>()
activeMQServer.registerActivateCallback(object: ActivateCallback {
    override fun activationComplete() {
        startupFuture.complete(Unit)
    }
})
activeMQServer.registerActivationFailureListener {
    startupFuture.completeExceptionally(it)
}

activeMQServer.start()

startupFuture.getOrThrow() {code}
I have the following questions/comments:
 * Could you confirm these are the right callbacks to hook on both for success 
& failure? I couldn't find a definitive answer on the documentation.
 * If I understand correctly the Netty pieces, the acceptors are also started 
synchronously. So, the whole infrastructure under the hood is synchronous and 
forcing _all_ clients to use an asynchronous, callback-based method also seems 
suboptimal. Is there an issue with surfacing the error as before and letting 
clients choose what they want to use?

> Failure of a broker to bind to an address is not propagated
> -----------------------------------------------------------
>
>                 Key: ARTEMIS-2950
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-2950
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.15.0
>            Reporter: Dimos Raptis
>            Priority: Major
>
> While working on an upgrade of our dependency on {{artemis-server}} from 
> version 2.6.2 to 2.15.0, we noticed that while a failure to bind on an 
> address was propagating to the client before, in the newer version it does 
> not propagate anymore.
>  
> More specifically, we are making use of the API 
> {{ActiveMQServerImpl.start()}} that was previously throwing a netty 
> {{NativeIoException}}, but now it is swallowing it and only logging an error 
> instead. We are making use of this exception to react to the failure to bind 
> and we have some automated tests around it that started failing during the 
> upgrade. Our tests are working in the following way:
>  * We first bind a socket to a specific port.
>  * Then, we attempt to start a broker on the same port.
>  * The expectation of the test is that the start() operation will fail with 
> an exception.
> To provide some more context, I managed to track down the ticket that 
> introduced this change in behaviour, which is this one: 
> https://issues.apache.org/jira/browse/ARTEMIS-2106



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to