Following is the full tracktrace output
Exception in thread "main" java.io.IOException: Failed to bind to
server socket: tcp://localhost:61617 due to: java.net.BindException:
Address already in use
at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:33)
at
org.apache.activemq.transport.tcp.TcpTransportServer.bind(TcpTransportServer.java:139)
at
org.apache.activemq.transport.tcp.TcpTransportFactory.doBind(TcpTransportFactory.java:56)
at
org.apache.activemq.transport.TransportFactorySupport.bind(TransportFactorySupport.java:40)
at
org.apache.activemq.broker.BrokerService.createTransportConnector(BrokerService.java:2386)
at
org.apache.activemq.broker.BrokerService.addConnector(BrokerService.java:318)
at
org.apache.activemq.broker.BrokerService.addConnector(BrokerService.java:308)
at StopTest.main(StopTest.java:11)
Caused by: java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at
javax.net.DefaultServerSocketFactory.createServerSocket(ServerSocketFactory.java:231)
at
org.apache.activemq.transport.tcp.TcpTransportServer.bind(TcpTransportServer.java:136)
... 6 more
I added the line connector.stop(); to the code as shown below
broker.start();
broker.waitUntilStarted();
connector.stop();
broker.stop();
broker.waitUntilStopped();
and the exception does not occur. Maybe that's what was missing?
On Fri, Jun 19, 2015 at 4:50 PM, Christopher Shannon
<[email protected]> wrote:
> There should be a nested exception that displays what the real error is.
> The BrokerStoppedException is the result of another error and it is hard to
> tell what is going on without the real exception causing the issues. Is
> there any more to the stack trace?
>
> On Fri, Jun 19, 2015 at 6:36 AM, pubudu gunawardena <[email protected]>
> wrote:
>
>> Hi All,
>>
>> I am using ActiveMQ version 5.11.1. Following is a simple code snippet
>> which reproduces the problem I am getting. (what I am trying to
>> implement is a restart, but the exceptions are thrown when stopping).
>>
>>
>> import org.apache.activemq.ActiveMQConnection;
>> import org.apache.activemq.ActiveMQConnectionFactory;
>> import org.apache.activemq.broker.BrokerService;
>> import org.apache.activemq.network.jms.JmsQueueConnector;
>> import org.apache.activemq.network.jms.OutboundQueueBridge;
>>
>> public class StopTest {
>> public static void main(String[] args) throws Exception {
>> BrokerService broker = new BrokerService();
>> broker.addConnector("tcp://localhost:61617");
>>
>> JmsQueueConnector connector = new JmsQueueConnector();
>> connector.setOutboundQueueConnectionFactory(new
>> ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL));
>> OutboundQueueBridge outboundQueueBridge = new
>> OutboundQueueBridge("queue");
>> connector.setOutboundQueueBridges(new OutboundQueueBridge[] {
>> outboundQueueBridge });
>> broker.setJmsBridgeConnectors(new JmsQueueConnector[] { connector
>> });
>>
>> broker.start();
>> broker.waitUntilStarted();
>> broker.stop();
>> broker.waitUntilStopped();
>> }
>> }
>>
>>
>> I get the following exception
>>
>> Exception in thread "ActiveMQ VMTransport: vm://localhost#1-1"
>> org.apache.activemq.broker.BrokerStoppedException: Broker
>> BrokerService[localhost] is being stopped
>> at
>> org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:193)
>> at
>> org.apache.activemq.transport.ResponseCorrelator.onCommand(ResponseCorrelator.java:116)
>> at
>> org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50)
>> at
>> org.apache.activemq.transport.vm.VMTransport.iterate(VMTransport.java:248)
>> at
>> org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:133)
>> at
>> org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:48)
>> at
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>> at java.lang.Thread.run(Thread.java:745)
>>
>> Can someone point out to me what I am not doing correctly?
>>
>> --
>> Thanks,
>> Pubudu
>>
--
Thanks,
Pubudu