You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by virtualshock <na...@virtualshock.net> on 2009/04/02 18:48:34 UTC

ActiveMQ 5.2.0 - Problem starting a BrokerService programmatically.

I am running ActiveMQ embedded in another application and it seems like it is
running correctly but broker.start() never returns which is hanging the
startup of my program.  In 4.x I didn't have this problem.
Here is a code snippet of how I am starting ActiveMQ :

            broker = new BrokerService();
            broker.setBrokerName(getInternalConnectionName());
            broker.getManagementContext().setCreateConnector(false);
            broker.setPersistent(true);
            broker.addConnector(getExternalConnectionURL());
            broker.start();

Here is the log output :

2009-04-02 11:14:42,884 [WrapperListener_start_runner] DEBUG
com.xxxx.agents.ActiveMQAgent - Starting ActiveMQAgent:tcp://localhost:61616
& vm://embeddedActiveMQBroker
2009-04-02 11:14:42,885 [WrapperListener_start_runner] INFO 
org.apache.activemq.broker.BrokerService - Using Persistence Adapter:
AMQPersistenceAdapter(activemq-data/embeddedActiveMQBroker)
2009-04-02 11:14:42,885 [WrapperListener_start_runner] WARN 
org.apache.activemq.store.amq.AMQPersistenceAdapter - Waiting to Lock the
Store activemq-data/embeddedActiveMQBroker
2009-04-02 11:15:01,837 [Persistence Adaptor Task] DEBUG
org.apache.activemq.store.amq.AMQPersistenceAdapter - Checkpoint started.
2009-04-02 11:15:01,838 [Persistence Adaptor Task] DEBUG
org.apache.activemq.store.amq.AMQPersistenceAdapter - Checkpoint done.
2009-04-02 11:15:11,836 [ActiveMQ Scheduler] DEBUG
org.apache.activemq.store.amq.AMQPersistenceAdapter -
dataFilesInProgress.values: (0) []
2009-04-02 11:15:11,836 [ActiveMQ Scheduler] DEBUG
org.apache.activemq.store.amq.AMQPersistenceAdapter - lastDataFile: 1
2009-04-02 11:15:11,837 [ActiveMQ Scheduler] DEBUG
org.apache.activemq.kaha.impl.async.AsyncDataManager - lastFileId=0,
purgeList: (0) []
2009-04-02 11:15:21,837 [Persistence Adaptor Task] DEBUG
org.apache.activemq.store.amq.AMQPersistenceAdapter - Checkpoint started.
2009-04-02 11:15:21,837 [Persistence Adaptor Task] DEBUG
org.apache.activemq.store.amq.AMQPersistenceAdapter - Checkpoint done.

Does anyone know what the problem is?

Thanks

-- 
View this message in context: http://www.nabble.com/ActiveMQ-5.2.0---Problem-starting-a-BrokerService-programmatically.-tp22851125p22851125.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ 5.2.0 - Problem starting a BrokerService programmatically.

Posted by virtualshock <na...@virtualshock.net>.
Thanks Bruce.  You got me in the right direction.  My connectionFactory had
already locked the data directory causing my custom startup code to hang.  I
used "create=false" in my brokerURL on the connectionFactory and now it is
starting up correctly.


bsnyder wrote:
> 
> On Thu, Apr 2, 2009 at 10:48 AM, virtualshock <na...@virtualshock.net>
> wrote:
>>
>> I am running ActiveMQ embedded in another application and it seems like
>> it is
>> running correctly but broker.start() never returns which is hanging the
>> startup of my program.  In 4.x I didn't have this problem.
>> Here is a code snippet of how I am starting ActiveMQ :
>>
>>            broker = new BrokerService();
>>            broker.setBrokerName(getInternalConnectionName());
>>            broker.getManagementContext().setCreateConnector(false);
>>            broker.setPersistent(true);
>>            broker.addConnector(getExternalConnectionURL());
>>            broker.start();
>>
>> Here is the log output :
>>
>> 2009-04-02 11:14:42,884 [WrapperListener_start_runner] DEBUG
>> com.xxxx.agents.ActiveMQAgent - Starting
>> ActiveMQAgent:tcp://localhost:61616
>> & vm://embeddedActiveMQBroker
>> 2009-04-02 11:14:42,885 [WrapperListener_start_runner] INFO
>> org.apache.activemq.broker.BrokerService - Using Persistence Adapter:
>> AMQPersistenceAdapter(activemq-data/embeddedActiveMQBroker)
>> 2009-04-02 11:14:42,885 [WrapperListener_start_runner] WARN
>> org.apache.activemq.store.amq.AMQPersistenceAdapter - Waiting to Lock the
>> Store activemq-data/embeddedActiveMQBroker
> 
> Looks like the problem is above. There must be a lock on the data
> directory that hasn't been removed. Do you have more than one broker
> pointed at the same data directory? If so, this is correct
> functionality and is known as shared filesystem master/slave:
> 
> http://activemq.apache.org/shared-file-system-master-slave.html
> 
> If you don't have another broker pointed at the same data directory,
> then it sounds like there might be a stale lock on the data directory.
> You can manually locate the lock file and remove it or you can delete
> the data directory completely and ActiveMQ will create a new data
> directory upon restart.
> 
> Make sure that you're shutting down the broker using the
> BrokerService.stop() method?
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.apache.org/
> Apache Camel - http://camel.apache.org/
> Apache ServiceMix - http://servicemix.apache.org/
> 
> Blog: http://bruceblog.org/
> 
> 

-- 
View this message in context: http://www.nabble.com/ActiveMQ-5.2.0---Problem-starting-a-BrokerService-programmatically.-tp22851125p22854695.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ 5.2.0 - Problem starting a BrokerService programmatically.

Posted by mdeguzman <mi...@yahoo.com>.

bsnyder wrote:
> 
> Looks like the problem is above. There must be a lock on the data
> directory that hasn't been removed. Do you have more than one broker
> pointed at the same data directory? If so, this is correct
> functionality and is known as shared filesystem master/slave:
> 
> http://activemq.apache.org/shared-file-system-master-slave.html
> 
> If you don't have another broker pointed at the same data directory,
> then it sounds like there might be a stale lock on the data directory.
> You can manually locate the lock file and remove it or you can delete
> the data directory completely and ActiveMQ will create a new data
> directory upon restart.
> 
> Make sure that you're shutting down the broker using the
> BrokerService.stop() method?
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.apache.org/
> Apache Camel - http://camel.apache.org/
> Apache ServiceMix - http://servicemix.apache.org/
> 
> Blog: http://bruceblog.org/
> 
> 

We're having a similar problem to this. We only have one broker. It seems
that there's a stale lock in our data directory. Deleting the activemq-data
and restarting the server resolves the problem. But this means a manual
delete and delay in processing.

Is there a way to determine programatically if there is a stale lock in the
data directory and force release the lock? 

Thanks!
-- 
View this message in context: http://old.nabble.com/ActiveMQ-5.2.0---Problem-starting-a-BrokerService-programmatically.-tp22851125p27790645.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: ActiveMQ 5.2.0 - Problem starting a BrokerService programmatically.

Posted by Bruce Snyder <br...@gmail.com>.
On Thu, Apr 2, 2009 at 10:48 AM, virtualshock <na...@virtualshock.net> wrote:
>
> I am running ActiveMQ embedded in another application and it seems like it is
> running correctly but broker.start() never returns which is hanging the
> startup of my program.  In 4.x I didn't have this problem.
> Here is a code snippet of how I am starting ActiveMQ :
>
>            broker = new BrokerService();
>            broker.setBrokerName(getInternalConnectionName());
>            broker.getManagementContext().setCreateConnector(false);
>            broker.setPersistent(true);
>            broker.addConnector(getExternalConnectionURL());
>            broker.start();
>
> Here is the log output :
>
> 2009-04-02 11:14:42,884 [WrapperListener_start_runner] DEBUG
> com.xxxx.agents.ActiveMQAgent - Starting ActiveMQAgent:tcp://localhost:61616
> & vm://embeddedActiveMQBroker
> 2009-04-02 11:14:42,885 [WrapperListener_start_runner] INFO
> org.apache.activemq.broker.BrokerService - Using Persistence Adapter:
> AMQPersistenceAdapter(activemq-data/embeddedActiveMQBroker)
> 2009-04-02 11:14:42,885 [WrapperListener_start_runner] WARN
> org.apache.activemq.store.amq.AMQPersistenceAdapter - Waiting to Lock the
> Store activemq-data/embeddedActiveMQBroker

Looks like the problem is above. There must be a lock on the data
directory that hasn't been removed. Do you have more than one broker
pointed at the same data directory? If so, this is correct
functionality and is known as shared filesystem master/slave:

http://activemq.apache.org/shared-file-system-master-slave.html

If you don't have another broker pointed at the same data directory,
then it sounds like there might be a stale lock on the data directory.
You can manually locate the lock file and remove it or you can delete
the data directory completely and ActiveMQ will create a new data
directory upon restart.

Make sure that you're shutting down the broker using the
BrokerService.stop() method?

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.apache.org/
Apache Camel - http://camel.apache.org/
Apache ServiceMix - http://servicemix.apache.org/

Blog: http://bruceblog.org/