From 952d03685680d22168dffea03c69eccf69568eff Mon Sep 17 00:00:00 2001 From: Bosanac Dejan Date: Thu, 15 Apr 2010 13:52:06 +0000 Subject: [PATCH] https://issues.apache.org/activemq/browse/AMQ-2696 - last broker sequence id and durable subscribers git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@934408 13f79535-47bb-0310-9956-ffa450edef68 --- .../store/jdbc/JDBCPersistenceAdapter.java | 9 ++- .../activemq/store/jdbc/Statements.java | 2 +- .../jdbc/adapter/DefaultJDBCAdapter.java | 7 ++- .../network/NetworkBrokerDetachTest.java | 2 +- .../jdbc/JDBCNetworkBrokerDetachTest.java | 19 +++++++ .../DurableSubscriptionTestSupport.java | 55 ++++++++++++------- .../usecases/JDBCDurableSubscriptionTest.java | 16 +++--- 7 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 activemq-core/src/test/java/org/apache/activemq/store/jdbc/JDBCNetworkBrokerDetachTest.java diff --git a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java index 25ea7522b4..191abca581 100755 --- a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/JDBCPersistenceAdapter.java @@ -229,8 +229,13 @@ public class JDBCPersistenceAdapter extends DataSourceSupport implements Persist sequenceGenerator.setLastSequenceId(seq); long brokerSeq = 0; if (seq != 0) { - Message last = (Message)wireFormat.unmarshal(new ByteSequence(getAdapter().doGetMessageById(c, seq))); - brokerSeq = last.getMessageId().getBrokerSequenceId(); + byte[] msg = getAdapter().doGetMessageById(c, seq); + if (msg != null) { + Message last = (Message)wireFormat.unmarshal(new ByteSequence(msg)); + brokerSeq = last.getMessageId().getBrokerSequenceId(); + } else { + LOG.warn("Broker sequence id wasn't recovered properly, possible duplicates!"); + } } return brokerSeq; } catch (SQLException e) { diff --git a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java index cd9ca8d76a..e61139f200 100755 --- a/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/jdbc/Statements.java @@ -309,7 +309,7 @@ public class Statements { public String getDeleteOldMessagesStatement() { if (deleteOldMessagesStatement == null) { deleteOldMessagesStatement = "DELETE FROM " + getFullMessageTableName() - + " WHERE ( EXPIRATION<>0 AND EXPIRATION0 AND EXPIRATION