From 3882b00735fcfb1da9f5f34ed7e1e36e0b2a6968 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Mon, 6 Mar 2017 13:22:05 -0500 Subject: [PATCH] ARTEMIS-1009 Fixing exporter/importer --- .../spi/core/protocol/MessagePersister.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessagePersister.java b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessagePersister.java index 14891f5d39..adba2d7297 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessagePersister.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/spi/core/protocol/MessagePersister.java @@ -18,11 +18,14 @@ package org.apache.activemq.artemis.spi.core.protocol; import java.util.Map; +import java.util.ServiceLoader; import java.util.concurrent.ConcurrentHashMap; import org.apache.activemq.artemis.api.core.ActiveMQBuffer; import org.apache.activemq.artemis.api.core.Message; +import org.apache.activemq.artemis.core.message.impl.CoreMessagePersister; import org.apache.activemq.artemis.core.persistence.Persister; +import org.apache.activemq.artemis.core.protocol.core.impl.CoreProtocolManagerFactory; import org.jboss.logging.Logger; public class MessagePersister implements Persister { @@ -34,6 +37,14 @@ public class MessagePersister implements Persister { /** This will be used for reading messages */ private static Map> protocols = new ConcurrentHashMap<>(); + static { + MessagePersister.registerPersister(CoreProtocolManagerFactory.ID, CoreMessagePersister.getInstance()); + + Iterable protocols = ServiceLoader.load(ProtocolManagerFactory.class, MessagePersister.class.getClassLoader()); + for (ProtocolManagerFactory next : protocols) { + MessagePersister.registerPersister(next.getStoreID(), next.getPersister()); + } + } public static void registerProtocol(ProtocolManagerFactory manager) { Persister messagePersister = manager.getPersister(); @@ -49,7 +60,9 @@ public class MessagePersister implements Persister { } public static void registerPersister(byte recordType, Persister persister) { - protocols.put(recordType, persister); + if (persister != null) { + protocols.put(recordType, persister); + } } public static MessagePersister getInstance() {