ARTEMIS-4349: Replace Guava cache with Caffeine

Combination of changes from Alexey Markevich with updates from Robbie Gemmell. See PRs for detail.

This closes #4584.
This closes #4540.
This commit is contained in:
Alexey Markevich 2023-08-29 11:31:49 +01:00 committed by Robbie Gemmell
parent 56c8afe934
commit 50a1824c02
11 changed files with 133 additions and 106 deletions

View File

@ -16,7 +16,8 @@
*/
package org.apache.activemq.artemis.cli.commands.tools.xml;
import com.google.common.base.Preconditions;
import java.util.Objects;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString;
@ -89,7 +90,7 @@ public class XmlDataExporterUtil {
* Base64 encode a ServerMessage body into the proper XML format
*/
public static String encodeMessageBodyBase64(final Message message) throws Exception {
Preconditions.checkNotNull(message, "ServerMessage can not be null");
Objects.requireNonNull(message, "ServerMessage can not be null");
ActiveMQBuffer byteBuffer = message.toCore().getReadOnlyBodyBuffer();
byte[] buffer = new byte[byteBuffer.writerIndex()];

View File

@ -73,8 +73,7 @@
<bundle dependency="true">mvn:org.apache.commons/commons-lang3/${commons.lang.version}</bundle>
<bundle dependency="true">mvn:org.jctools/jctools-core/${jctools.version}</bundle>
<bundle dependency="true">mvn:org.hdrhistogram/HdrHistogram/${hdrhistogram.version}</bundle>
<bundle dependency="true">mvn:com.google.guava/failureaccess/1.0.1</bundle>
<bundle dependency="true">mvn:com.google.guava/guava/${guava.version}</bundle>
<bundle dependency="true">mvn:com.github.ben-manes.caffeine/caffeine/${caffeine.version}</bundle>
<bundle dependency="true">mvn:org.apache.commons/commons-dbcp2/${commons.dbcp2.version}</bundle>
<bundle dependency="true">mvn:org.apache.commons/commons-pool2/${commons.pool2.version}</bundle>
<!-- Micrometer can't be included until it supports OSGi. It is currently an "optional" Maven dependency. -->

View File

@ -20,7 +20,6 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.CaseFormat;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.handler.codec.EncoderException;
@ -49,6 +48,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.config.WildcardConfiguration;
import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.reader.MessageUtil;
import org.apache.commons.text.CaseUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;
@ -382,7 +382,7 @@ public class MQTTUtil {
}
private static String formatCase(String string) {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, string);
return CaseUtils.toCamelCase(string, false, '_');
}
private static String getPayloadForLogging(MqttPublishMessage message, int maxPayloadLogSize) {

View File

@ -43,6 +43,28 @@
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-client</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>listenablefuture</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>

View File

@ -51,17 +51,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>listenablefuture</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</exclusion>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
@ -70,10 +62,6 @@
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View File

@ -22,8 +22,6 @@ import java.security.AccessController;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.apache.activemq.artemis.api.core.Pair;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
@ -54,6 +52,10 @@ import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet;
import org.apache.activemq.artemis.utils.collections.TypedProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.lang.invoke.MethodHandles;
/**
@ -101,18 +103,18 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC
if (authenticationCacheSize == 0) {
authenticationCache = null;
} else {
authenticationCache = CacheBuilder.newBuilder()
.maximumSize(authenticationCacheSize)
.expireAfterWrite(invalidationInterval, TimeUnit.MILLISECONDS)
.build();
authenticationCache = Caffeine.newBuilder()
.maximumSize(authenticationCacheSize)
.expireAfterWrite(invalidationInterval, TimeUnit.MILLISECONDS)
.build();
}
if (authorizationCacheSize == 0) {
authorizationCache = null;
} else {
authorizationCache = CacheBuilder.newBuilder()
.maximumSize(authorizationCacheSize)
.expireAfterWrite(invalidationInterval, TimeUnit.MILLISECONDS)
.build();
authorizationCache = Caffeine.newBuilder()
.maximumSize(authorizationCacheSize)
.expireAfterWrite(invalidationInterval, TimeUnit.MILLISECONDS)
.build();
}
this.securityRepository.registerListener(this);
}
@ -481,7 +483,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC
if (authenticationCache == null) {
return 0;
} else {
return authenticationCache.size();
return authenticationCache.estimatedSize();
}
}
@ -489,7 +491,7 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC
if (authorizationCache == null) {
return 0;
} else {
return authorizationCache.size();
return authorizationCache.estimatedSize();
}
}

View File

@ -16,13 +16,15 @@
*/
package org.apache.activemq.artemis.core.server.routing.caches;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.persistence.config.PersistedKeyValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.RemovalCause;
import com.github.benmanes.caffeine.cache.RemovalListener;
import java.lang.invoke.MethodHandles;
import java.util.Map;
@ -37,7 +39,7 @@ public class LocalCache implements Cache, RemovalListener<String, String> {
private boolean persisted;
private int timeout;
private StorageManager storageManager;
private com.google.common.cache.Cache<String, String> cache;
private com.github.benmanes.caffeine.cache.Cache<String, String> cache;
private Map<String, PersistedKeyValuePair> persistedCacheEntries;
private volatile boolean running;
@ -61,9 +63,9 @@ public class LocalCache implements Cache, RemovalListener<String, String> {
this.storageManager = storageManager;
if (timeout == 0) {
cache = CacheBuilder.newBuilder().build();
cache = Caffeine.newBuilder().executor(Runnable::run).build();
} else {
cache = CacheBuilder.newBuilder().removalListener(this).expireAfterAccess(timeout, TimeUnit.MILLISECONDS).build();
cache = Caffeine.newBuilder().removalListener(this).expireAfterAccess(timeout, TimeUnit.MILLISECONDS).executor(Runnable::run).build();
}
}
@ -123,9 +125,9 @@ public class LocalCache implements Cache, RemovalListener<String, String> {
}
@Override
public void onRemoval(RemovalNotification<String, String> notification) {
public void onRemoval(String key, String value, RemovalCause cause) {
if (running && persisted) {
PersistedKeyValuePair persistedKeyValuePair = persistedCacheEntries.remove(notification.getKey());
PersistedKeyValuePair persistedKeyValuePair = persistedCacheEntries.remove(key);
if (persistedKeyValuePair != null) {
try {

View File

@ -97,6 +97,7 @@
<commons.io.version>2.10.0</commons.io.version>
<commons.codec.version>1.15</commons.codec.version>
<fuse.mqtt.client.version>1.16</fuse.mqtt.client.version>
<caffeine.version>3.1.6</caffeine.version>
<guava.version>32.0.1-jre</guava.version>
<hawtio.version>2.15.0</hawtio.version>
<jsr305.version>3.0.2</jsr305.version>
@ -943,6 +944,12 @@
<version>${guava.version}</version>
<!-- License: Apache 2.0 -->
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>${caffeine.version}</version>
<!-- License: Apache 2.0 -->
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>

View File

@ -19,10 +19,10 @@ package org.apache.activemq.artemis.tests.integration.plugin;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import com.google.common.base.Preconditions;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.RoutingType;
@ -122,13 +122,13 @@ public class MethodCalledVerifier implements ActiveMQServerPlugin {
@Override
public void afterCreateConnection(RemotingConnection connection) {
Preconditions.checkNotNull(connection);
Objects.requireNonNull(connection);
methodCalled(AFTER_CREATE_CONNECTION);
}
@Override
public void afterDestroyConnection(RemotingConnection connection) {
Preconditions.checkNotNull(connection);
Objects.requireNonNull(connection);
methodCalled(AFTER_DESTROY_CONNECTION);
}
@ -137,172 +137,172 @@ public class MethodCalledVerifier implements ActiveMQServerPlugin {
boolean autoCommitSends, boolean autoCommitAcks, boolean preAcknowledge, boolean xa,
String defaultAddress, SessionCallback callback, boolean autoCreateQueues,
OperationContext context, Map<SimpleString, RoutingType> prefixes) {
Preconditions.checkNotNull(connection);
Objects.requireNonNull(connection);
methodCalled(BEFORE_CREATE_SESSION);
}
@Override
public void afterCreateSession(ServerSession session) {
Preconditions.checkNotNull(session);
Objects.requireNonNull(session);
methodCalled(AFTER_CREATE_SESSION);
}
@Override
public void beforeCloseSession(ServerSession session, boolean failed) {
Preconditions.checkNotNull(session);
Objects.requireNonNull(session);
methodCalled(BEFORE_CLOSE_SESSION);
}
@Override
public void afterCloseSession(ServerSession session, boolean failed) {
Preconditions.checkNotNull(session);
Objects.requireNonNull(session);
methodCalled(AFTER_CLOSE_SESSION);
}
@Override
public void beforeSessionMetadataAdded(ServerSession session, String key, String data) {
Preconditions.checkNotNull(key);
Objects.requireNonNull(key);
methodCalled(BEFORE_SESSION_METADATA_ADDED);
}
@Override
public void afterSessionMetadataAdded(ServerSession session, String key, String data) {
Preconditions.checkNotNull(key);
Objects.requireNonNull(key);
methodCalled(AFTER_SESSION_METADATA_ADDED);
}
@Override
public void beforeCreateConsumer(long consumerID, QueueBinding queueBinding, SimpleString filterString,
boolean browseOnly, boolean supportLargeMessage) {
Preconditions.checkNotNull(queueBinding);
Objects.requireNonNull(queueBinding);
methodCalled(BEFORE_CREATE_CONSUMER);
}
@Override
public void afterCreateConsumer(ServerConsumer consumer) {
Preconditions.checkNotNull(consumer);
Objects.requireNonNull(consumer);
methodCalled(AFTER_CREATE_CONSUMER);
}
@Override
public void beforeCloseConsumer(ServerConsumer consumer, boolean failed) {
Preconditions.checkNotNull(consumer);
Objects.requireNonNull(consumer);
methodCalled(BEFORE_CLOSE_CONSUMER);
}
@Override
public void afterCloseConsumer(ServerConsumer consumer, boolean failed) {
Preconditions.checkNotNull(consumer);
Objects.requireNonNull(consumer);
methodCalled(AFTER_CLOSE_CONSUMER);
}
@Override
public void beforeAddAddress(AddressInfo addressInfo, boolean reload) throws ActiveMQException {
Preconditions.checkNotNull(addressInfo);
Objects.requireNonNull(addressInfo);
methodCalled(BEFORE_ADD_ADDRESS);
}
@Override
public void afterAddAddress(AddressInfo addressInfo, boolean reload) throws ActiveMQException {
Preconditions.checkNotNull(addressInfo);
Objects.requireNonNull(addressInfo);
methodCalled(AFTER_ADD_ADDRESS);
}
@Override
public void beforeUpdateAddress(SimpleString address, EnumSet<RoutingType> routingTypes)
throws ActiveMQException {
Preconditions.checkNotNull(address);
Preconditions.checkNotNull(routingTypes);
Objects.requireNonNull(address);
Objects.requireNonNull(routingTypes);
methodCalled(BEFORE_UPDATE_ADDRESS);
}
@Override
public void afterUpdateAddress(AddressInfo addressInfo) throws ActiveMQException {
Preconditions.checkNotNull(addressInfo);
Objects.requireNonNull(addressInfo);
methodCalled(AFTER_UPDATE_ADDRESS);
}
@Override
public void beforeRemoveAddress(SimpleString address) throws ActiveMQException {
Preconditions.checkNotNull(address);
Objects.requireNonNull(address);
methodCalled(BEFORE_REMOVE_ADDRESS);
}
@Override
public void afterRemoveAddress(SimpleString address, AddressInfo addressInfo) throws ActiveMQException {
Preconditions.checkNotNull(address);
Preconditions.checkNotNull(addressInfo);
Objects.requireNonNull(address);
Objects.requireNonNull(addressInfo);
methodCalled(AFTER_REMOVE_ADDRESS);
}
@Override
public void beforeCreateQueue(QueueConfig queueConfig) {
Preconditions.checkNotNull(queueConfig);
Objects.requireNonNull(queueConfig);
methodCalled(BEFORE_CREATE_QUEUE);
}
@Override
public void afterCreateQueue(org.apache.activemq.artemis.core.server.Queue queue) {
Preconditions.checkNotNull(queue);
Objects.requireNonNull(queue);
methodCalled(AFTER_CREATE_QUEUE);
}
@Override
public void beforeDestroyQueue(Queue queue, SecurityAuth session, boolean checkConsumerCount,
boolean removeConsumers, boolean autoDeleteAddress) {
Preconditions.checkNotNull(queue);
Objects.requireNonNull(queue);
methodCalled(BEFORE_DESTROY_QUEUE);
}
@Override
public void afterDestroyQueue(Queue queue, SimpleString address, SecurityAuth session, boolean checkConsumerCount,
boolean removeConsumers, boolean autoDeleteAddress) {
Preconditions.checkNotNull(queue);
Objects.requireNonNull(queue);
methodCalled(AFTER_DESTROY_QUEUE);
}
@Override
public void beforeAddBinding(Binding binding) throws ActiveMQException {
Preconditions.checkNotNull(binding);
Objects.requireNonNull(binding);
methodCalled(BEFORE_ADD_BINDING);
}
@Override
public void afterAddBinding(Binding binding) throws ActiveMQException {
Preconditions.checkNotNull(binding);
Objects.requireNonNull(binding);
methodCalled(AFTER_ADD_BINDING);
}
@Override
public void beforeRemoveBinding(SimpleString uniqueName, Transaction tx, boolean deleteData)
throws ActiveMQException {
Preconditions.checkNotNull(uniqueName);
Objects.requireNonNull(uniqueName);
methodCalled(BEFORE_REMOVE_BINDING);
}
@Override
public void afterRemoveBinding(Binding binding, Transaction tx, boolean deleteData) throws ActiveMQException {
Preconditions.checkNotNull(binding);
Objects.requireNonNull(binding);
methodCalled(AFTER_REMOVE_BINDING);
}
@Override
public void messageExpired(MessageReference message, SimpleString messageExpiryAddress, ServerConsumer consumer) {
Preconditions.checkNotNull(message);
Objects.requireNonNull(message);
methodCalled(MESSAGE_EXPIRED);
}
@Override
public void messageAcknowledged(MessageReference ref, AckReason reason, ServerConsumer consumer) {
Preconditions.checkNotNull(ref);
Preconditions.checkNotNull(reason);
Objects.requireNonNull(ref);
Objects.requireNonNull(reason);
methodCalled(MESSAGE_ACKED);
}
@Override
public void beforeSend(ServerSession session, Transaction tx, Message message, boolean direct,
boolean noAutoCreateQueue) {
Preconditions.checkNotNull(message);
Objects.requireNonNull(message);
methodCalled(BEFORE_SEND);
}
@ -310,148 +310,148 @@ public class MethodCalledVerifier implements ActiveMQServerPlugin {
public void afterSend(ServerSession session, Transaction tx, Message message, boolean direct,
boolean noAutoCreateQueue,
RoutingStatus result) {
Preconditions.checkNotNull(message);
Preconditions.checkNotNull(result);
Objects.requireNonNull(message);
Objects.requireNonNull(result);
methodCalled(AFTER_SEND);
}
@Override
public void onSendException(ServerSession session, Transaction tx, Message message, boolean direct,
boolean noAutoCreateQueue, Exception e) {
Preconditions.checkNotNull(message);
Preconditions.checkNotNull(e);
Objects.requireNonNull(message);
Objects.requireNonNull(e);
methodCalled(ON_SEND_EXCEPTION);
}
@Override
public void beforeMessageRoute(Message message, RoutingContext context, boolean direct, boolean rejectDuplicates) {
Preconditions.checkNotNull(message);
Preconditions.checkNotNull(context);
Objects.requireNonNull(message);
Objects.requireNonNull(context);
methodCalled(BEFORE_MESSAGE_ROUTE);
}
@Override
public void afterMessageRoute(Message message, RoutingContext context, boolean direct, boolean rejectDuplicates,
RoutingStatus result) {
Preconditions.checkNotNull(message);
Preconditions.checkNotNull(context);
Preconditions.checkNotNull(result);
Objects.requireNonNull(message);
Objects.requireNonNull(context);
Objects.requireNonNull(result);
methodCalled(AFTER_MESSAGE_ROUTE);
}
@Override
public void onMessageRouteException(Message message, RoutingContext context, boolean direct, boolean rejectDuplicates,
Exception e) {
Preconditions.checkNotNull(message);
Preconditions.checkNotNull(context);
Preconditions.checkNotNull(e);
Objects.requireNonNull(message);
Objects.requireNonNull(context);
Objects.requireNonNull(e);
methodCalled(ON_MESSAGE_ROUTE_EXCEPTION);
}
@Override
public void beforeDeliver(ServerConsumer consumer, MessageReference reference) {
Preconditions.checkNotNull(reference);
Objects.requireNonNull(reference);
methodCalled(BEFORE_DELIVER);
}
@Override
public void afterDeliver(ServerConsumer consumer, MessageReference reference) {
Preconditions.checkNotNull(reference);
Objects.requireNonNull(reference);
methodCalled(AFTER_DELIVER);
}
@Override
public void beforeDeployBridge(BridgeConfiguration config) {
Preconditions.checkNotNull(config);
Objects.requireNonNull(config);
methodCalled(BEFORE_DEPLOY_BRIDGE);
}
@Override
public void afterDeployBridge(Bridge bridge) {
Preconditions.checkNotNull(bridge);
Objects.requireNonNull(bridge);
methodCalled(AFTER_DEPLOY_BRIDGE);
}
@Override
public void beforeDeliverBridge(Bridge bridge, MessageReference ref) throws ActiveMQException {
Preconditions.checkNotNull(bridge);
Objects.requireNonNull(bridge);
methodCalled(BEFORE_DELIVER_BRIDGE);
}
@Override
public void afterDeliverBridge(Bridge bridge, MessageReference ref, HandleStatus status) throws ActiveMQException {
Preconditions.checkNotNull(bridge);
Objects.requireNonNull(bridge);
methodCalled(AFTER_DELIVER_BRIDGE);
}
@Override
public void afterAcknowledgeBridge(Bridge bridge, MessageReference ref) throws ActiveMQException {
Preconditions.checkNotNull(bridge);
Objects.requireNonNull(bridge);
methodCalled(AFTER_ACKNOWLEDGE_BRIDGE);
}
@Override
public void federationStreamStarted(FederationStream stream) throws ActiveMQException {
Preconditions.checkNotNull(stream);
Objects.requireNonNull(stream);
methodCalled(FEDERATION_STREAM_STARTED);
}
@Override
public void federationStreamStopped(FederationStream stream) throws ActiveMQException {
Preconditions.checkNotNull(stream);
Objects.requireNonNull(stream);
methodCalled(FEDERATION_STREAM_STOPPED);
}
@Override
public void beforeCreateFederatedQueueConsumer(FederatedConsumerKey key) throws ActiveMQException {
Preconditions.checkNotNull(key);
Objects.requireNonNull(key);
methodCalled(BEFORE_CREATE_FEDERATED_QUEUE_CONSUMER);
}
@Override
public void afterCreateFederatedQueueConsumer(FederatedQueueConsumer consumer) throws ActiveMQException {
Preconditions.checkNotNull(consumer);
Objects.requireNonNull(consumer);
methodCalled(AFTER_CREATE_FEDERATED_QUEUE_CONSUMER);
}
@Override
public void beforeCloseFederatedQueueConsumer(FederatedQueueConsumer consumer) throws ActiveMQException {
Preconditions.checkNotNull(consumer);
Objects.requireNonNull(consumer);
methodCalled(BEFORE_CLOSE_FEDERATED_QUEUE_CONSUMER);
}
@Override
public void afterCloseFederatedQueueConsumer(FederatedQueueConsumer consumer) throws ActiveMQException {
Preconditions.checkNotNull(consumer);
Objects.requireNonNull(consumer);
methodCalled(AFTER_CLOSE_FEDERATED_QUEUE_CONSUMER);
}
@Override
public void beforeFederatedQueueConsumerMessageHandled(FederatedQueueConsumer consumer,
Message message) throws ActiveMQException {
Preconditions.checkNotNull(consumer);
Preconditions.checkNotNull(message);
Objects.requireNonNull(consumer);
Objects.requireNonNull(message);
methodCalled(BEFORE_FEDERATED_QUEUE_CONSUMER_MESSAGE_HANDLED);
}
@Override
public void afterFederatedQueueConsumerMessageHandled(FederatedQueueConsumer consumer,
Message message) throws ActiveMQException {
Preconditions.checkNotNull(consumer);
Preconditions.checkNotNull(message);
Objects.requireNonNull(consumer);
Objects.requireNonNull(message);
methodCalled(AFTER_FEDERATED_QUEUE_CONSUMER_MESSAGE_HANDLED);
}
@Override
public boolean federatedAddressConditionalCreateConsumer(Queue queue) throws ActiveMQException {
Preconditions.checkNotNull(queue);
Objects.requireNonNull(queue);
methodCalled(FEDERATED_ADDRESS_CONDITIONAL_CREATE_CONSUMER);
return true;
}
@Override
public boolean federatedQueueConditionalCreateConsumer(ServerConsumer consumer) throws ActiveMQException {
Preconditions.checkNotNull(consumer);
Objects.requireNonNull(consumer);
methodCalled(FEDERATED_QUEUE_CONDITIONAL_CREATE_CONSUMER);
return true;
}

View File

@ -16,6 +16,8 @@
*/
package org.apache.activemq.artemis.tests.smoke.jmx2;
import java.util.Map;
import javax.jms.MessageConsumer;
import javax.jms.Session;
import org.apache.activemq.artemis.json.JsonArray;
@ -26,7 +28,6 @@ import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import com.google.common.collect.ImmutableMap;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.JsonUtil;
import org.apache.activemq.artemis.api.core.QueueConfiguration;
@ -91,7 +92,7 @@ public class JmxServerControlTest extends SmokeTestBase {
MessageConsumer consumer = cf.createConnection().createSession(true, Session.SESSION_TRANSACTED).createConsumer(new ActiveMQQueue(queueName));
try {
String options = JsonUtil.toJsonObject(ImmutableMap.of("field","queue", "operation", "EQUALS", "value", queueName)).toString();
String options = JsonUtil.toJsonObject(Map.of("field","queue", "operation", "EQUALS", "value", queueName)).toString();
String consumersAsJsonString = activeMQServerControl.listConsumers(options, 1, 10);
JsonObject consumersAsJsonObject = JsonUtil.readJsonObject(consumersAsJsonString);

View File

@ -184,6 +184,11 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<!-- The johnzon-core and json-api contents are repackaged in -commons,
However maven can still need them during tests, which run against