You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by de...@apache.org on 2008/12/23 15:23:39 UTC
svn commit: r728964 -
/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java
Author: dejanb
Date: Tue Dec 23 06:23:38 2008
New Revision: 728964
URL: http://svn.apache.org/viewvc?rev=728964&view=rev
Log:
fix for https://issues.apache.org/activemq/browse/AMQ-2038
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java?rev=728964&r1=728963&r2=728964&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java Tue Dec 23 06:23:38 2008
@@ -83,6 +83,8 @@
*/
public class JournalPersistenceAdapter implements PersistenceAdapter, JournalEventListener, UsageListener, BrokerServiceAware {
+ private BrokerService brokerService;
+
protected static final Scheduler scheduler = Scheduler.getInstance();
private static final Log LOG = LogFactory.getLog(JournalPersistenceAdapter.class);
@@ -599,7 +601,13 @@
*/
public RecordLocation writeCommand(DataStructure command, boolean sync) throws IOException {
if (started.get()) {
- return journal.write(toPacket(wireFormat.marshal(command)), sync);
+ try {
+ return journal.write(toPacket(wireFormat.marshal(command)), sync);
+ } catch (IOException ioe) {
+ LOG.error("Cannot write to the journal", ioe);
+ stopBroker();
+ throw ioe;
+ }
}
throw new IOException("closed");
}
@@ -693,10 +701,23 @@
}
public void setBrokerService(BrokerService brokerService) {
+ this.brokerService = brokerService;
PersistenceAdapter pa = getLongTermPersistence();
if( pa instanceof BrokerServiceAware ) {
((BrokerServiceAware)pa).setBrokerService(brokerService);
}
}
+
+ protected void stopBroker() {
+ new Thread() {
+ public void run() {
+ try {
+ brokerService.stop();
+ } catch (Exception e) {
+ LOG.warn("Failure occured while stopping broker");
+ }
+ }
+ }.start();
+ }
}