This closes #2579
This commit is contained in:
commit
4bfeaf89c5
|
@ -17,7 +17,7 @@
|
|||
|
||||
# Additional logger names to configure (root logger is always configured)
|
||||
# Root logger option
|
||||
loggers=org.eclipse.jetty,org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms.server,org.apache.activemq.artemis.integration.bootstrap
|
||||
loggers=org.eclipse.jetty,org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms.server,org.apache.activemq.artemis.integration.bootstrap,org.apache.activemq.audit.base,org.apache.activemq.audit.message
|
||||
|
||||
# Root logger level
|
||||
logger.level=INFO
|
||||
|
@ -31,6 +31,15 @@ logger.org.eclipse.jetty.level=WARN
|
|||
# Root logger handlers
|
||||
logger.handlers=FILE,CONSOLE
|
||||
|
||||
# to enable audit change the level to INFO
|
||||
logger.org.apache.activemq.audit.base.level=ERROR
|
||||
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.base.useParentHandlers=false
|
||||
|
||||
logger.org.apache.activemq.audit.message.level=ERROR
|
||||
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.message.useParentHandlers=false
|
||||
|
||||
# Console handler configuration
|
||||
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
|
||||
handler.CONSOLE.properties=autoFlush
|
||||
|
@ -52,3 +61,17 @@ handler.FILE.formatter=PATTERN
|
|||
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
||||
formatter.PATTERN.properties=pattern
|
||||
formatter.PATTERN.pattern=%d %-5p [%c] %s%E%n
|
||||
|
||||
#Audit logger
|
||||
handler.AUDIT_FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
|
||||
handler.AUDIT_FILE.level=INFO
|
||||
handler.AUDIT_FILE.properties=suffix,append,autoFlush,fileName
|
||||
handler.AUDIT_FILE.suffix=.yyyy-MM-dd
|
||||
handler.AUDIT_FILE.append=true
|
||||
handler.AUDIT_FILE.autoFlush=true
|
||||
handler.AUDIT_FILE.fileName=${artemis.instance}/log/audit.log
|
||||
handler.AUDIT_FILE.formatter=AUDIT_PATTERN
|
||||
|
||||
formatter.AUDIT_PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
||||
formatter.AUDIT_PATTERN.properties=pattern
|
||||
formatter.AUDIT_PATTERN.pattern=%d [AUDIT](%t) %s%E%n
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.persistence.StorageManager;
|
|||
import org.apache.activemq.artemis.core.persistence.impl.journal.DummyOperationContext;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ServerSession;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
import org.apache.activemq.artemis.utils.Base64;
|
||||
import org.apache.activemq.artemis.utils.RunnableEx;
|
||||
import org.apache.activemq.artemis.utils.UUIDGenerator;
|
||||
|
@ -106,6 +107,9 @@ public abstract class AbstractControl extends StandardMBean {
|
|||
|
||||
@Override
|
||||
public MBeanInfo getMBeanInfo() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMBeanInfo(this);
|
||||
}
|
||||
MBeanInfo info = super.getMBeanInfo();
|
||||
return new MBeanInfo(info.getClassName(), info.getDescription(), fillMBeanAttributeInfo(), info.getConstructors(), fillMBeanOperationInfo(), info.getNotifications());
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Map;
|
|||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.management.AcceptorControl;
|
||||
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
|
||||
|
||||
public class AcceptorControlImpl extends AbstractControl implements AcceptorControl {
|
||||
|
@ -52,6 +53,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
|
|||
|
||||
@Override
|
||||
public String getFactoryClassName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getFactoryClassName(this.acceptor);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getFactoryClassName();
|
||||
|
@ -62,6 +66,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getName(this.acceptor);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getName();
|
||||
|
@ -72,6 +79,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
|
|||
|
||||
@Override
|
||||
public Map<String, Object> getParameters() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getParameters(this.acceptor);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
Map<String, Object> clone = new HashMap(configuration.getParams());
|
||||
|
@ -88,6 +98,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
|
|||
|
||||
@Override
|
||||
public void reload() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.reload(this.acceptor);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
acceptor.reload();
|
||||
|
@ -98,6 +111,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
|
|||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isStarted(this.acceptor);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return acceptor.isStarted();
|
||||
|
@ -108,6 +124,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
|
|||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.startAcceptor(this.acceptor);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
acceptor.start();
|
||||
|
@ -118,6 +137,9 @@ public class AcceptorControlImpl extends AbstractControl implements AcceptorCont
|
|||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.stopAcceptor(this.acceptor);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
acceptor.stop();
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -43,6 +43,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
|||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.management.ManagementService;
|
||||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
import org.apache.activemq.artemis.utils.JsonLoader;
|
||||
|
||||
public class AddressControlImpl extends AbstractControl implements AddressControl {
|
||||
|
@ -94,6 +95,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public String[] getRoutingTypes() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRoutingTypes(this.addressInfo);
|
||||
}
|
||||
EnumSet<RoutingType> routingTypes = addressInfo.getRoutingTypes();
|
||||
String[] result = new String[routingTypes.size()];
|
||||
int i = 0;
|
||||
|
@ -105,6 +109,10 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public String getRoutingTypesAsJSON() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRoutingTypesAsJSON(this.addressInfo);
|
||||
}
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
JsonArrayBuilder json = JsonLoader.createArrayBuilder();
|
||||
|
@ -121,6 +129,11 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public String[] getQueueNames() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getQueueNames(this.addressInfo);
|
||||
}
|
||||
|
||||
String[] result;
|
||||
clearIO();
|
||||
try {
|
||||
Bindings bindings = server.getPostOffice().lookupBindingsForAddress(addressInfo.getName());
|
||||
|
@ -144,8 +157,12 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public String[] getBindingNames() throws Exception {
|
||||
clearIO();
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getBindingNames(this.addressInfo);
|
||||
}
|
||||
try {
|
||||
clearIO();
|
||||
|
||||
Bindings bindings = server.getPostOffice().lookupBindingsForAddress(addressInfo.getName());
|
||||
if (bindings != null) {
|
||||
String[] bindingNames = new String[bindings.getBindings().size()];
|
||||
|
@ -166,6 +183,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public Object[] getRoles() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRoles(this.addressInfo);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
Set<Role> roles = securityRepository.getMatch(addressInfo.getName().toString());
|
||||
|
@ -184,6 +204,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public String getRolesAsJSON() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRolesAsJSON(this.addressInfo);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
JsonArrayBuilder json = JsonLoader.createArrayBuilder();
|
||||
|
@ -200,6 +223,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public long getNumberOfBytesPerPage() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getNumberOfBytesPerPage(this.addressInfo);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
final PagingStore pagingStore = getPagingStore();
|
||||
|
@ -218,6 +244,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public long getAddressSize() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getAddressSize(this.addressInfo);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
final PagingStore pagingStore = getPagingStore();
|
||||
|
@ -232,6 +261,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public long getNumberOfMessages() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getNumberOfMessages(this.addressInfo);
|
||||
}
|
||||
clearIO();
|
||||
long totalMsgs = 0;
|
||||
try {
|
||||
|
@ -253,6 +285,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public boolean isPaging() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isPaging(this.addressInfo);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
final PagingStore pagingStore = getPagingStore();
|
||||
|
@ -267,6 +302,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public int getNumberOfPages() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getNumberOfPages(this.addressInfo);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
final PagingStore pageStore = getPagingStore();
|
||||
|
@ -283,16 +321,25 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
|
||||
@Override
|
||||
public long getMessageCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessageCount(this.addressInfo);
|
||||
}
|
||||
return getMessageCount(DurabilityType.ALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRoutedMessageCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRoutedMessageCount(this.addressInfo);
|
||||
}
|
||||
return addressInfo.getRoutedMessageCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUnRoutedMessageCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getUnRoutedMessageCount(this.addressInfo);
|
||||
}
|
||||
return addressInfo.getUnRoutedMessageCount();
|
||||
}
|
||||
|
||||
|
@ -304,6 +351,9 @@ public class AddressControlImpl extends AbstractControl implements AddressContro
|
|||
boolean durable,
|
||||
final String user,
|
||||
final String password) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.sendMessage(this, null, headers, type, body, durable, user, "****");
|
||||
}
|
||||
try {
|
||||
return sendMessage(addressInfo.getName(), server, headers, type, body, durable, user, password);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.activemq.artemis.api.core.management.BridgeControl;
|
|||
import org.apache.activemq.artemis.core.config.BridgeConfiguration;
|
||||
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
||||
import org.apache.activemq.artemis.core.server.cluster.Bridge;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
|
||||
public class BridgeControlImpl extends AbstractControl implements BridgeControl {
|
||||
|
||||
|
@ -54,6 +55,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public String[] getStaticConnectors() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getStaticConnectors(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
List<String> staticConnectors = configuration.getStaticConnectors();
|
||||
|
@ -65,6 +69,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public String getForwardingAddress() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getForwardingAddress(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getForwardingAddress();
|
||||
|
@ -75,6 +82,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public String getQueueName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getQueueName(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getQueueName();
|
||||
|
@ -85,6 +95,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public String getDiscoveryGroupName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDiscoveryGroupName(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getDiscoveryGroupName();
|
||||
|
@ -95,6 +108,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public String getFilterString() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getFilterString(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getFilterString();
|
||||
|
@ -105,6 +121,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public int getReconnectAttempts() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getReconnectAttempts(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getReconnectAttempts();
|
||||
|
@ -115,6 +134,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getName(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getName();
|
||||
|
@ -125,6 +147,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public long getRetryInterval() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRetryInterval(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getRetryInterval();
|
||||
|
@ -135,6 +160,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public double getRetryIntervalMultiplier() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRetryIntervalMultiplier(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getRetryIntervalMultiplier();
|
||||
|
@ -145,6 +173,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public String getTransformerClassName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getTransformerClassName(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getClassName();
|
||||
|
@ -155,11 +186,17 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public String getTransformerPropertiesAsJSON() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getTransformerPropertiesAsJSON(this.bridge);
|
||||
}
|
||||
return JsonUtil.toJsonObject(getTransformerProperties()).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTransformerProperties() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getTransformerProperties(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getProperties();
|
||||
|
@ -170,6 +207,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isStartedBridge(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return bridge.isStarted();
|
||||
|
@ -180,6 +220,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public boolean isUseDuplicateDetection() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isUseDuplicateDetection(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.isUseDuplicateDetection();
|
||||
|
@ -190,6 +233,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public boolean isHA() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isHA(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.isHA();
|
||||
|
@ -200,6 +246,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.startBridge(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
bridge.start();
|
||||
|
@ -210,6 +259,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.stopBridge(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
bridge.stop();
|
||||
|
@ -231,6 +283,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public long getMessagesPendingAcknowledgement() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessagesPendingAcknowledgement(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return bridge.getMetrics().getMessagesPendingAcknowledgement();
|
||||
|
@ -241,6 +296,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public long getMessagesAcknowledged() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessagesAcknowledged(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return bridge.getMetrics().getMessagesAcknowledged();
|
||||
|
@ -251,6 +309,9 @@ public class BridgeControlImpl extends AbstractControl implements BridgeControl
|
|||
|
||||
@Override
|
||||
public Map<String, Object> getMetrics() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMetrics(this.bridge);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return bridge.getMetrics().convertToMap();
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory;
|
|||
import org.apache.activemq.artemis.api.core.management.BroadcastGroupControl;
|
||||
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
||||
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
|
||||
public class BroadcastGroupControlImpl extends AbstractControl implements BroadcastGroupControl {
|
||||
|
||||
|
@ -52,6 +53,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getName(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getName();
|
||||
|
@ -62,6 +66,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
|
||||
@Override
|
||||
public long getBroadcastPeriod() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getBroadcastPeriod(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getBroadcastPeriod();
|
||||
|
@ -72,6 +79,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
|
||||
@Override
|
||||
public Object[] getConnectorPairs() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getConnectorPairs(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
Object[] ret = new Object[configuration.getConnectorInfos().size()];
|
||||
|
@ -80,7 +90,6 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
for (String connector : configuration.getConnectorInfos()) {
|
||||
ret[i++] = connector;
|
||||
}
|
||||
|
||||
return ret;
|
||||
} finally {
|
||||
blockOnIO();
|
||||
|
@ -89,6 +98,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
|
||||
@Override
|
||||
public String getConnectorPairsAsJSON() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getConnectorPairsAsJSON(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return JsonUtil.toJsonArray(configuration.getConnectorInfos()).toString();
|
||||
|
@ -100,6 +112,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
//todo ghoward we should deal with this properly
|
||||
@Override
|
||||
public String getGroupAddress() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getGroupAddress(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
if (configuration.getEndpointFactory() instanceof UDPBroadcastEndpointFactory) {
|
||||
|
@ -113,6 +128,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
|
||||
@Override
|
||||
public int getGroupPort() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getGroupPort(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
if (configuration.getEndpointFactory() instanceof UDPBroadcastEndpointFactory) {
|
||||
|
@ -126,6 +144,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
|
||||
@Override
|
||||
public int getLocalBindPort() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getLocalBindPort(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
if (configuration.getEndpointFactory() instanceof UDPBroadcastEndpointFactory) {
|
||||
|
@ -141,6 +162,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isStarted(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return broadcastGroup.isStarted();
|
||||
|
@ -151,6 +175,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.startBroadcastGroup(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
broadcastGroup.start();
|
||||
|
@ -161,6 +188,9 @@ public class BroadcastGroupControlImpl extends AbstractControl implements Broadc
|
|||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.stopBroadcastGroup(this.broadcastGroup);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
broadcastGroup.stop();
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
|
|||
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
||||
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
|
||||
import org.apache.activemq.artemis.core.server.cluster.impl.BridgeMetrics;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
|
||||
public class ClusterConnectionControlImpl extends AbstractControl implements ClusterConnectionControl {
|
||||
|
||||
|
@ -55,6 +56,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getAddress(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getAddress();
|
||||
|
@ -66,6 +70,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public String getDiscoveryGroupName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDiscoveryGroupName(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getDiscoveryGroupName();
|
||||
|
@ -77,6 +84,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public int getMaxHops() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMaxHops(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getMaxHops();
|
||||
|
@ -88,6 +98,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getName(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getName();
|
||||
|
@ -99,6 +112,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public long getRetryInterval() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRetryInterval(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getRetryInterval();
|
||||
|
@ -110,6 +126,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public String getNodeID() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getNodeID(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return clusterConnection.getNodeID();
|
||||
|
@ -120,6 +139,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public String[] getStaticConnectors() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getStaticConnectors(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
List<String> staticConnectors = configuration.getStaticConnectors();
|
||||
|
@ -135,6 +157,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public String getStaticConnectorsAsJSON() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getStaticConnectorsAsJSON(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return JsonUtil.toJsonArray(configuration.getStaticConnectors()).toString();
|
||||
|
@ -145,6 +170,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public boolean isDuplicateDetection() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isDuplicateDetection(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.isDuplicateDetection();
|
||||
|
@ -155,6 +183,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public String getMessageLoadBalancingType() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessageLoadBalancingType(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getMessageLoadBalancingType().getType();
|
||||
|
@ -165,6 +196,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public String getTopology() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getTopology(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return clusterConnection.getTopology().describe();
|
||||
|
@ -175,6 +209,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public Map<String, String> getNodes() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getNodes(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return clusterConnection.getNodes();
|
||||
|
@ -185,6 +222,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public boolean isStarted() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isStarted(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return clusterConnection.isStarted();
|
||||
|
@ -195,6 +235,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.startClusterConnection(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
clusterConnection.start();
|
||||
|
@ -206,6 +249,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.stopClusterConnection(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
clusterConnection.stop();
|
||||
|
@ -227,6 +273,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public long getMessagesPendingAcknowledgement() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessagesPendingAcknowledgement(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return clusterConnection.getMetrics().getMessagesPendingAcknowledgement();
|
||||
|
@ -237,6 +286,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public long getMessagesAcknowledged() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessagesAcknowledged(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return clusterConnection.getMetrics().getMessagesAcknowledged();
|
||||
|
@ -247,6 +299,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public Map<String, Object> getMetrics() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMetrics(this.clusterConnection);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return clusterConnection.getMetrics().convertToMap();
|
||||
|
@ -257,6 +312,9 @@ public class ClusterConnectionControlImpl extends AbstractControl implements Clu
|
|||
|
||||
@Override
|
||||
public Map<String, Object> getBridgeMetrics(String nodeId) {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getBridgeMetrics(this.clusterConnection, nodeId);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
final BridgeMetrics bridgeMetrics = clusterConnection.getBridgeMetrics(nodeId);
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.activemq.artemis.api.core.management.DivertControl;
|
|||
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
||||
import org.apache.activemq.artemis.core.persistence.StorageManager;
|
||||
import org.apache.activemq.artemis.core.server.Divert;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
|
||||
public class DivertControlImpl extends AbstractControl implements DivertControl {
|
||||
|
||||
|
@ -53,6 +54,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
|
|||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getAddress(this.divert);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getAddress();
|
||||
|
@ -63,6 +67,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
|
|||
|
||||
@Override
|
||||
public String getFilter() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getFilter(this.divert);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getFilterString();
|
||||
|
@ -73,6 +80,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
|
|||
|
||||
@Override
|
||||
public String getForwardingAddress() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getForwardingAddress(this.divert);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getForwardingAddress();
|
||||
|
@ -83,6 +93,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
|
|||
|
||||
@Override
|
||||
public String getRoutingName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRoutingName(this.divert);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return divert.getRoutingName().toString();
|
||||
|
@ -93,6 +106,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
|
|||
|
||||
@Override
|
||||
public String getTransformerClassName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getTransformerClassName(this.divert);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getClassName();
|
||||
|
@ -103,11 +119,17 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
|
|||
|
||||
@Override
|
||||
public String getTransformerPropertiesAsJSON() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getTransformerPropertiesAsJSON(this.divert);
|
||||
}
|
||||
return JsonUtil.toJsonObject(getTransformerProperties()).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTransformerProperties() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getTransformerProperties(this.divert);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getTransformerConfiguration() == null ? null : configuration.getTransformerConfiguration().getProperties();
|
||||
|
@ -118,6 +140,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
|
|||
|
||||
@Override
|
||||
public String getRoutingType() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRoutingType(this.divert);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getRoutingType().toString();
|
||||
|
@ -128,6 +153,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
|
|||
|
||||
@Override
|
||||
public String getUniqueName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getUniqueName(this.divert);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return divert.getUniqueName().toString();
|
||||
|
@ -138,6 +166,9 @@ public class DivertControlImpl extends AbstractControl implements DivertControl
|
|||
|
||||
@Override
|
||||
public boolean isExclusive() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isExclusive(this.divert);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return divert.isExclusive();
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.apache.activemq.artemis.core.server.ServerConsumer;
|
|||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.selector.filter.Filterable;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
import org.apache.activemq.artemis.utils.JsonLoader;
|
||||
import org.apache.activemq.artemis.utils.collections.LinkedListIterator;
|
||||
|
||||
|
@ -129,6 +130,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getName(queue);
|
||||
}
|
||||
clearIO();
|
||||
try {
|
||||
return queue.getName().toString();
|
||||
|
@ -139,6 +143,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getAddress(queue);
|
||||
}
|
||||
|
||||
checkStarted();
|
||||
|
||||
return address;
|
||||
|
@ -146,6 +154,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String getFilter() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getFilter(queue);
|
||||
}
|
||||
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -160,6 +172,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean isDurable() {
|
||||
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isDurable(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -172,6 +188,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String getUser() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getUser(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -186,6 +205,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String getRoutingType() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getRoutingType(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -199,6 +221,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isTemporary(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -211,6 +236,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getMessageCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessageCount(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -223,6 +251,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getPersistentSize() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getPersistentSize(queue);
|
||||
}
|
||||
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -235,6 +267,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getDurableMessageCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDurableMessageCount(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -247,6 +282,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getDurablePersistentSize() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDurablePersistSize(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -259,6 +297,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int getConsumerCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getConsumerCount(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -271,6 +312,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int getDeliveringCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDeliveringCount(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -283,6 +327,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getDeliveringSize() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDeliveringSize(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -295,6 +342,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int getDurableDeliveringCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDurableDeliveringCount(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -307,6 +357,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getDurableDeliveringSize() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDurableDeliveringSize(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -319,6 +372,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getMessagesAdded() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessagesAdded(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -331,6 +387,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getMessagesAcknowledged() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessagesAcknowledged(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -343,6 +402,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getMessagesExpired() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessagesExpired(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -355,6 +417,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getMessagesKilled() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMessagesKilled(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -367,6 +432,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getID() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getID(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -379,6 +447,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getScheduledCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getScheduledCount(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -391,6 +462,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getScheduledSize() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getScheduledSize(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -403,6 +477,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getDurableScheduledCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDurableScheduledCount(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -415,6 +492,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long getDurableScheduledSize() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDurableScheduledSize(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -427,6 +507,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String getDeadLetterAddress() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getDeadLetterAddress(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -444,6 +527,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String getExpiryAddress() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getExpiryAddress(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -462,6 +548,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int getMaxConsumers() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getMaxConsumers(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -474,6 +563,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean isPurgeOnNoConsumers() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isPurgeOnNoConsumers(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -486,6 +578,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean isConfigurationManaged() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isConfigurationManaged(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -498,6 +593,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean isExclusive() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isExclusive(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -510,6 +608,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean isLastValue() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isLastValue(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -522,6 +623,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public Map<String, Object>[] listScheduledMessages() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listScheduledMessages(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -535,6 +639,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String listScheduledMessagesAsJSON() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listScheduledMessagesAsJSON(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -561,6 +668,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public Map<String, Map<String, Object>[]> listDeliveringMessages() throws ActiveMQException {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listDeliveringMessages(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -572,15 +682,18 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
for (Map.Entry<String, List<MessageReference>> entry : msgs.entrySet()) {
|
||||
msgRet.put(entry.getKey(), convertMessagesToMaps(entry.getValue()));
|
||||
}
|
||||
|
||||
return msgRet;
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String listDeliveringMessagesAsJSON() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listDeliveringMessagesAsJSON(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -593,6 +706,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public Map<String, Object>[] listMessages(final String filterStr) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listMessages(queue, filterStr);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -623,6 +739,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String listMessagesAsJSON(final String filter) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listMessagesAsJSON(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -634,6 +753,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
}
|
||||
|
||||
protected Map<String, Object>[] getFirstMessage() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getFirstMessage(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -657,11 +779,18 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String getFirstMessageAsJSON() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getFirstMessageAsJSON(queue);
|
||||
}
|
||||
return toJSON(getFirstMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getFirstMessageTimestamp() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getFirstMessageTimestamp(queue);
|
||||
}
|
||||
|
||||
Map<String, Object>[] _message = getFirstMessage();
|
||||
if (_message == null || _message.length == 0 || _message[0] == null) {
|
||||
return null;
|
||||
|
@ -675,6 +804,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public Long getFirstMessageAge() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getFirstMessageAge(queue);
|
||||
}
|
||||
|
||||
Long firstMessageTimestamp = getFirstMessageTimestamp();
|
||||
if (firstMessageTimestamp == null) {
|
||||
return null;
|
||||
|
@ -690,12 +823,20 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long countMessages(final String filterStr) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.countMessages(queue, filterStr);
|
||||
}
|
||||
|
||||
Long value = intenalCountMessages(filterStr, null).get(null);
|
||||
return value == null ? 0 : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String countMessages(final String filterStr, final String groupByProperty) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.countMessages(queue, filterStr, groupByProperty);
|
||||
}
|
||||
|
||||
return JsonUtil.toJsonObject(intenalCountMessages(filterStr, groupByProperty)).toString();
|
||||
}
|
||||
|
||||
|
@ -730,12 +871,20 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public long countDeliveringMessages(final String filterStr) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.countDeliveringMessages(queue, filterStr);
|
||||
}
|
||||
|
||||
Long value = intenalCountDeliveryMessages(filterStr, null).get(null);
|
||||
return value == null ? 0 : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String countDeliveringMessages(final String filterStr, final String groupByProperty) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.countDeliveringMessages(queue, filterStr, groupByProperty);
|
||||
}
|
||||
|
||||
return JsonUtil.toJsonObject(intenalCountDeliveryMessages(filterStr, groupByProperty)).toString();
|
||||
}
|
||||
|
||||
|
@ -778,6 +927,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean removeMessage(final long messageID) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.removeMessage(queue, messageID);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -797,6 +949,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int removeMessages(final int flushLimit, final String filterStr) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.removeMessages(queue, flushLimit, filterStr);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -816,6 +971,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean expireMessage(final long messageID) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.expireMessage(queue, messageID);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -828,6 +986,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int expireMessages(final String filterStr) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.expireMessages(queue, filterStr);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -843,6 +1004,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean retryMessage(final long messageID) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.retryMessage(queue, messageID);
|
||||
}
|
||||
|
||||
checkStarted();
|
||||
clearIO();
|
||||
|
@ -878,6 +1042,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int retryMessages() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.retryMessages(queue);
|
||||
}
|
||||
checkStarted();
|
||||
clearIO();
|
||||
|
||||
|
@ -897,6 +1064,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
public boolean moveMessage(final long messageID,
|
||||
final String otherQueueName,
|
||||
final boolean rejectDuplicates) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.moveMessage(queue, messageID, otherQueueName, rejectDuplicates);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -924,6 +1094,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
final String filterStr,
|
||||
final String otherQueueName,
|
||||
final boolean rejectDuplicates) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.moveMessages(queue, flushLimit, filterStr, otherQueueName, rejectDuplicates);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -937,7 +1110,6 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
}
|
||||
|
||||
int retValue = queue.moveReferences(flushLimit, filter, binding.getAddress(), rejectDuplicates, binding);
|
||||
|
||||
return retValue;
|
||||
} finally {
|
||||
blockOnIO();
|
||||
|
@ -954,6 +1126,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.sendMessagesToDeadLetterAddress(queue, filterStr);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -973,6 +1148,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
boolean durable,
|
||||
final String user,
|
||||
final String password) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.sendMessage(queue, null, headers, type, body, durable, user, "****");
|
||||
}
|
||||
try {
|
||||
return sendMessage(queue.getAddress(), server, headers, type, body, durable, user, password, queue.getID());
|
||||
} catch (Exception e) {
|
||||
|
@ -982,6 +1160,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean sendMessageToDeadLetterAddress(final long messageID) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.sendMessageToDeadLetterAddress(queue, messageID);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -994,6 +1175,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int changeMessagesPriority(final String filterStr, final int newPriority) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.changeMessagesPriority(queue, filterStr, newPriority);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1011,6 +1195,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean changeMessagePriority(final long messageID, final int newPriority) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.changeMessagePriority(queue, messageID, newPriority);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1026,6 +1213,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String listMessageCounter() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listMessageCounter(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1040,6 +1230,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void resetMessageCounter() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.resetMessageCounter(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1052,6 +1245,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String listMessageCounterAsHTML() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listMessageCounterAsHTML(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1064,6 +1260,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String listMessageCounterHistory() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listMessageCounterHistory(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1076,6 +1275,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String listMessageCounterHistoryAsHTML() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listMessageCounterHistoryAsHTML(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1088,6 +1290,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void pause() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.pause(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1101,6 +1306,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void pause(boolean persist) {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.pause(queue, persist);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1112,6 +1320,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
}
|
||||
@Override
|
||||
public void resume() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.resume(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1124,6 +1335,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public boolean isPaused() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.isPaused(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1136,6 +1350,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public CompositeData[] browse(int page, int pageSize) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.browse(queue, page, pageSize);
|
||||
}
|
||||
String filter = null;
|
||||
checkStarted();
|
||||
|
||||
|
@ -1181,6 +1398,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
}
|
||||
@Override
|
||||
public CompositeData[] browse(String filter) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.browse(queue, filter);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1216,6 +1436,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void flushExecutor() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.flushExecutor(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1228,6 +1451,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void resetAllGroups() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.resetAllGroups(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1240,6 +1466,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void resetGroup(String groupID) {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.resetGroup(queue, groupID);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1252,6 +1481,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public int getGroupCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getGroupCount(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1264,6 +1496,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String listGroupsAsJSON() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listGroupsAsJSON(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1292,6 +1527,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public String listConsumersAsJSON() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.listConsumersAsJSON(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1330,6 +1568,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void resetMessagesAdded() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.resetMessagesAdded(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1343,6 +1584,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void resetMessagesAcknowledged() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.resetMessagesAcknowledged(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1356,6 +1600,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void resetMessagesExpired() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.resetMessagesExpired(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -1369,6 +1616,9 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
|
||||
@Override
|
||||
public void resetMessagesKilled() throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.resetMessagesKilled(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.apache.activemq.artemis.core.server.management.Notification;
|
|||
import org.apache.activemq.artemis.core.server.management.NotificationService;
|
||||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
import org.apache.activemq.artemis.core.settings.HierarchicalRepositoryChangeListener;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager2;
|
||||
|
@ -227,11 +228,14 @@ public class SecurityStoreImpl implements SecurityStore, HierarchicalRepositoryC
|
|||
notificationService.sendNotification(notification);
|
||||
}
|
||||
|
||||
Exception ex;
|
||||
if (queue == null) {
|
||||
throw ActiveMQMessageBundle.BUNDLE.userNoPermissions(session.getUsername(), checkType, saddress);
|
||||
ex = ActiveMQMessageBundle.BUNDLE.userNoPermissions(session.getUsername(), checkType, saddress);
|
||||
} else {
|
||||
throw ActiveMQMessageBundle.BUNDLE.userNoPermissionsQueue(session.getUsername(), checkType, queue.toString(), saddress);
|
||||
ex = ActiveMQMessageBundle.BUNDLE.userNoPermissionsQueue(session.getUsername(), checkType, queue.toString(), saddress);
|
||||
}
|
||||
AuditLogger.securityFailure(ex);
|
||||
throw ex;
|
||||
}
|
||||
// if we get here we're granted, add to the cache
|
||||
ConcurrentHashSet<SimpleString> set = new ConcurrentHashSet<>();
|
||||
|
|
|
@ -177,6 +177,7 @@ import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
|
|||
import org.apache.activemq.artemis.core.transaction.ResourceManager;
|
||||
import org.apache.activemq.artemis.core.transaction.impl.ResourceManagerImpl;
|
||||
import org.apache.activemq.artemis.core.version.Version;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.ProtocolManagerFactory;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
|
||||
|
@ -1448,6 +1449,11 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
final boolean autoCreateQueues,
|
||||
final OperationContext context,
|
||||
final Map<SimpleString, RoutingType> prefixes) throws Exception {
|
||||
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.createCoreSession(this, name, username, "****", minLargeMessageSize, connection, autoCommitSends,
|
||||
autoCommitAcks, preAcknowledge, xa, defaultAddress, callback, autoCreateQueues, context, prefixes);
|
||||
}
|
||||
String validatedUser = "";
|
||||
|
||||
if (securityStore != null) {
|
||||
|
|
|
@ -88,6 +88,7 @@ import org.apache.activemq.artemis.core.transaction.Transaction.State;
|
|||
import org.apache.activemq.artemis.core.transaction.TransactionOperationAbstract;
|
||||
import org.apache.activemq.artemis.core.transaction.TransactionPropertyIndexes;
|
||||
import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
|
||||
import org.apache.activemq.artemis.logs.AuditLogger;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
|
||||
import org.apache.activemq.artemis.utils.CompositeAddress;
|
||||
|
@ -486,6 +487,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
final boolean browseOnly,
|
||||
final boolean supportLargeMessage,
|
||||
final Integer credits) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.createCoreConsumer(this, getUsername(), consumerID, queueName, filterString, priority, browseOnly, supportLargeMessage, credits);
|
||||
}
|
||||
final SimpleString unPrefixedQueueName = removePrefix(queueName);
|
||||
|
||||
Binding binding = postOffice.getBinding(unPrefixedQueueName);
|
||||
|
@ -632,6 +636,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
final long autoDeleteDelay,
|
||||
final long autoDeleteMessageCount,
|
||||
final boolean autoCreated) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.createQueue(this, getUsername(), addressInfo, name, filterString, temporary, durable, maxConsumers, purgeOnNoConsumers,
|
||||
exclusive, groupRebalance, groupBuckets, lastValue, lastValueKey, nonDestructive, consumersBeforeDispatch,
|
||||
delayBeforeDispatch, autoDelete, autoDeleteDelay, autoDeleteMessageCount, autoCreated);
|
||||
}
|
||||
final SimpleString unPrefixedName = removePrefix(name);
|
||||
|
||||
AddressInfo art = getAddressAndRoutingType(addressInfo);
|
||||
|
@ -780,6 +789,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
public AddressInfo createAddress(final SimpleString address,
|
||||
EnumSet<RoutingType> routingTypes,
|
||||
final boolean autoCreated) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.serverSessionCreateAddress(this.getName(), getUsername(), address, routingTypes, autoCreated);
|
||||
}
|
||||
|
||||
SimpleString realAddress = CompositeAddress.extractAddressName(address);
|
||||
Pair<SimpleString, EnumSet<RoutingType>> art = getAddressAndRoutingTypes(realAddress, routingTypes);
|
||||
securityCheck(art.getA(), CheckType.CREATE_ADDRESS, this);
|
||||
|
@ -796,6 +809,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
|
||||
@Override
|
||||
public AddressInfo createAddress(AddressInfo addressInfo, boolean autoCreated) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.serverSessionCreateAddress(this.getName(), getUsername(), addressInfo, autoCreated);
|
||||
}
|
||||
|
||||
AddressInfo art = getAddressAndRoutingType(addressInfo);
|
||||
securityCheck(art.getName(), CheckType.CREATE_ADDRESS, this);
|
||||
server.addOrUpdateAddressInfo(art.setAutoCreated(autoCreated));
|
||||
|
@ -834,6 +851,11 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
Boolean autoDelete,
|
||||
Long autoDeleteDelay,
|
||||
Long autoDeleteMessageCount) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.createSharedQueue(this, getUsername(), address, name, routingType, filterString, durable, maxConsumers, purgeOnNoConsumers,
|
||||
exclusive, groupRebalance, groupBuckets, lastValue, lastValueKey, nonDestructive, consumersBeforeDispatch,
|
||||
delayBeforeDispatch, autoDelete, autoDeleteDelay, autoDeleteMessageCount);
|
||||
}
|
||||
address = removePrefix(address);
|
||||
|
||||
securityCheck(address, name, durable ? CheckType.CREATE_DURABLE_QUEUE : CheckType.CREATE_NON_DURABLE_QUEUE, this);
|
||||
|
@ -942,6 +964,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
|
||||
@Override
|
||||
public void deleteQueue(final SimpleString queueToDelete) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.destroyQueue(this, getUsername(), queueToDelete);
|
||||
}
|
||||
final SimpleString unPrefixedQueueName = removePrefix(queueToDelete);
|
||||
|
||||
Binding binding = postOffice.getBinding(unPrefixedQueueName);
|
||||
|
@ -1535,6 +1560,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
final boolean direct,
|
||||
boolean noAutoCreateQueue,
|
||||
RoutingContext routingContext) throws Exception {
|
||||
if (AuditLogger.isMessageEnabled()) {
|
||||
AuditLogger.coreSendMessage(this, getUsername(), tx, messageParameter, direct, noAutoCreateQueue, routingContext);
|
||||
}
|
||||
|
||||
final Message message = LargeServerMessageImpl.checkLargeMessage(messageParameter, storageManager);
|
||||
|
||||
|
@ -1801,6 +1829,9 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
private RoutingStatus handleManagementMessage(final Transaction tx,
|
||||
final Message message,
|
||||
final boolean direct) throws Exception {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.handleManagementMessage(this.getName(), getUsername(), tx, message, direct);
|
||||
}
|
||||
try {
|
||||
securityCheck(removePrefix(message.getAddressSimpleString()), CheckType.MANAGE, this);
|
||||
} catch (ActiveMQException e) {
|
||||
|
@ -1825,7 +1856,6 @@ public class ServerSessionImpl implements ServerSession, FailureListener {
|
|||
|
||||
doSend(tx, reply, null, direct, false, routingContext);
|
||||
}
|
||||
|
||||
return RoutingStatus.OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ configurable via the `logging.properties` file found in the
|
|||
configuration directories. This is configured by Default to log to both
|
||||
the console and to a file.
|
||||
|
||||
There are 6 loggers available which are as follows:
|
||||
There are 8 loggers available which are as follows:
|
||||
|
||||
Logger | Description
|
||||
---|---
|
||||
|
@ -15,6 +15,8 @@ org.apache.activemq.artemis.utils|Logs utility calls
|
|||
org.apache.activemq.artemis.journal|Logs Journal calls
|
||||
org.apache.activemq.artemis.jms|Logs JMS calls
|
||||
org.apache.activemq.artemis.integration.bootstrap|Logs bootstrap calls
|
||||
org.apache.activemq.audit.base|audit log. Disabled by default
|
||||
org.apache.activemq.audit.message|message audit log. Disabled by default
|
||||
|
||||
|
||||
## Logging in a client or with an Embedded server
|
||||
|
@ -85,3 +87,42 @@ formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
|||
formatter.PATTERN.properties=pattern
|
||||
formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n
|
||||
```
|
||||
|
||||
## Configuring Audit Log
|
||||
|
||||
The 2 audit loggers can be enabled to record some important operations like
|
||||
create/delete queues. By default this logger is disabled. The configuration
|
||||
(logging.properties) for audit log is like this by default:
|
||||
|
||||
```$xslt
|
||||
logger.org.apache.activemq.audit.base.level=ERROR
|
||||
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.base.useParentHandlers=false
|
||||
|
||||
logger.org.apache.activemq.audit.message.level=ERROR
|
||||
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.message.useParentHandlers=false
|
||||
...
|
||||
```
|
||||
|
||||
To enable the audit log change the above level to INFO, like this:
|
||||
```$xslt
|
||||
logger.org.apache.activemq.audit.base.level=INFO
|
||||
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.base.useParentHandlers=false
|
||||
|
||||
logger.org.apache.activemq.audit.message.level=INFO
|
||||
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.message.useParentHandlers=false
|
||||
...
|
||||
```
|
||||
|
||||
The 2 audit loggers can be disable/enable separately. The second logger
|
||||
(org.apache.activemq.audit.message) audits messages in 'hot path'
|
||||
(code path that is very sensitive to performance, e.g. sending messages).
|
||||
Turn on this audit logger may affect the performance.
|
||||
|
||||
Once enabled, all audit records are written into a separate log
|
||||
file (by default audit.log).
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
# Additional logger names to configure (root logger is always configured)
|
||||
# Root logger option
|
||||
loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests
|
||||
loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests,org.apache.activemq.audit
|
||||
|
||||
# Root logger level
|
||||
logger.level=INFO
|
||||
|
@ -35,6 +35,11 @@ logger.org.apache.activemq.artemis.jms.tests.level=INFO
|
|||
logger.handlers=CONSOLE,TEST
|
||||
#logger.handlers=CONSOLE,FILE
|
||||
|
||||
# to enable audit change the level to INFO
|
||||
logger.org.apache.activemq.audit.level=ERROR
|
||||
logger.org.apache.activemq.audit.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.useParentHandlers=false
|
||||
|
||||
# Console handler configuration
|
||||
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
|
||||
handler.CONSOLE.properties=autoFlush
|
||||
|
@ -59,3 +64,17 @@ handler.TEST.formatter=PATTERN
|
|||
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
||||
formatter.PATTERN.properties=pattern
|
||||
formatter.PATTERN.pattern=[%t] %d{HH:mm:ss,SSS} %-5p [%c] %s%E%n
|
||||
|
||||
#Audit logger
|
||||
handler.AUDIT_FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
|
||||
handler.AUDIT_FILE.level=INFO
|
||||
handler.AUDIT_FILE.properties=suffix,append,autoFlush,fileName
|
||||
handler.AUDIT_FILE.suffix=.yyyy-MM-dd
|
||||
handler.AUDIT_FILE.append=true
|
||||
handler.AUDIT_FILE.autoFlush=true
|
||||
handler.AUDIT_FILE.fileName=target/audit.log
|
||||
handler.AUDIT_FILE.formatter=AUDIT_PATTERN
|
||||
|
||||
formatter.AUDIT_PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
||||
formatter.AUDIT_PATTERN.properties=pattern
|
||||
formatter.AUDIT_PATTERN.pattern=%d [AUDIT](%t) %s%E%n
|
||||
|
|
|
@ -0,0 +1,213 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.management;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.Message;
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.client.ClientSession;
|
||||
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
|
||||
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
||||
import org.apache.activemq.artemis.api.core.management.AddressControl;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
|
||||
import org.apache.activemq.artemis.core.security.Role;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServers;
|
||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
|
||||
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
|
||||
import org.apache.activemq.artemis.tests.util.Wait;
|
||||
import org.apache.activemq.artemis.utils.Base64;
|
||||
import org.apache.activemq.artemis.utils.RandomUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
public class AuditLoggerTest extends ManagementTestBase {
|
||||
|
||||
private static final File auditLog = new File("target/audit.log");
|
||||
|
||||
private ActiveMQServer server;
|
||||
private Configuration conf;
|
||||
protected ClientSession session;
|
||||
private ServerLocator locator;
|
||||
private ClientSessionFactory sf;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
emptyLogFile();
|
||||
|
||||
TransportConfiguration connectorConfig = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
|
||||
|
||||
conf = createDefaultNettyConfig().setJMXManagementEnabled(true).addConnectorConfiguration(connectorConfig.getName(), connectorConfig);
|
||||
conf.setSecurityEnabled(true);
|
||||
SecurityConfiguration securityConfiguration = new SecurityConfiguration();
|
||||
securityConfiguration.addUser("guest", "guest");
|
||||
securityConfiguration.addUser("myUser", "myPass");
|
||||
securityConfiguration.addRole("guest", "guest");
|
||||
securityConfiguration.addRole("myUser", "guest");
|
||||
securityConfiguration.setDefaultUser("guest");
|
||||
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), securityConfiguration);
|
||||
server = addServer(ActiveMQServers.newActiveMQServer(conf, mbeanServer, securityManager, true));
|
||||
server.start();
|
||||
|
||||
HashSet<Role> role = new HashSet<>();
|
||||
//role guest cannot delete queues
|
||||
role.add(new Role("guest", true, true, true, false, true, false, true, true, true, true));
|
||||
server.getSecurityRepository().addMatch("#", role);
|
||||
|
||||
locator = createInVMNonHALocator().setBlockOnNonDurableSend(true);
|
||||
sf = createSessionFactory(locator);
|
||||
session = sf.createSession("guest", "guest", false, true, false, false, 100);
|
||||
session.start();
|
||||
addClientSession(session);
|
||||
}
|
||||
|
||||
@After
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
private void emptyLogFile() throws Exception {
|
||||
if (auditLog.exists()) {
|
||||
try (PrintWriter writer = new PrintWriter(new FileWriter(auditLog))) {
|
||||
writer.print("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuditLog() throws Exception {
|
||||
reloadLoggingConfig("audit.logging.properties");
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
session.createAddress(address, RoutingType.ANYCAST, false);
|
||||
|
||||
final AddressControl addressControl = ManagementControlHelper.createAddressControl(address, mbeanServer);
|
||||
|
||||
Assert.assertEquals(0, addressControl.getQueueNames().length);
|
||||
session.createQueue(address, RoutingType.ANYCAST, address);
|
||||
Assert.assertEquals(1, addressControl.getQueueNames().length);
|
||||
String uniqueStr = Base64.encodeBytes(UUID.randomUUID().toString().getBytes());
|
||||
addressControl.sendMessage(null, Message.BYTES_TYPE, uniqueStr, false, null, null);
|
||||
|
||||
Wait.waitFor(() -> addressControl.getMessageCount() == 1);
|
||||
Assert.assertEquals(1, addressControl.getMessageCount());
|
||||
|
||||
checkAuditLogRecord(true, "sending a message", uniqueStr);
|
||||
|
||||
//failure log
|
||||
address = RandomUtil.randomSimpleString();
|
||||
session.createAddress(address, RoutingType.ANYCAST, false);
|
||||
|
||||
final AddressControl addressControl2 = ManagementControlHelper.createAddressControl(address, mbeanServer);
|
||||
|
||||
Assert.assertEquals(1, addressControl.getQueueNames().length);
|
||||
|
||||
session.createQueue(address, RoutingType.ANYCAST, address);
|
||||
Wait.waitFor(() -> addressControl2.getQueueNames().length == 1);
|
||||
|
||||
try {
|
||||
session.deleteQueue(address);
|
||||
fail("Deleting queue should get exception");
|
||||
} catch (Exception e) {
|
||||
//ignore
|
||||
}
|
||||
|
||||
checkAuditLogRecord(true, "gets security check failure:", "guest does not have permission='DELETE_NON_DURABLE_QUEUE'");
|
||||
//hot patch not in log
|
||||
checkAuditLogRecord(false, "is sending a core message");
|
||||
}
|
||||
|
||||
private void reloadLoggingConfig(String logFile) {
|
||||
ClassLoader cl = AuditLoggerTest.class.getClassLoader();
|
||||
InputStream inputStream = cl.getResourceAsStream(logFile);
|
||||
LogManager logManager = LogManager.getLogManager();
|
||||
try {
|
||||
logManager.readConfiguration(inputStream);
|
||||
} catch (IOException e) {
|
||||
System.out.println("error loading logging conifg");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuditHotLog() throws Exception {
|
||||
reloadLoggingConfig("audit.logging.hot.properties");
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
session.createAddress(address, RoutingType.ANYCAST, false);
|
||||
|
||||
final AddressControl addressControl = ManagementControlHelper.createAddressControl(address, mbeanServer);
|
||||
|
||||
Assert.assertEquals(0, addressControl.getQueueNames().length);
|
||||
session.createQueue(address, RoutingType.ANYCAST, address);
|
||||
Assert.assertEquals(1, addressControl.getQueueNames().length);
|
||||
String uniqueStr = Base64.encodeBytes(UUID.randomUUID().toString().getBytes());
|
||||
addressControl.sendMessage(null, Message.BYTES_TYPE, uniqueStr, false, null, null);
|
||||
|
||||
Wait.waitFor(() -> addressControl.getMessageCount() == 1);
|
||||
Assert.assertEquals(1, addressControl.getMessageCount());
|
||||
|
||||
checkAuditLogRecord(true, "sending a core message");
|
||||
}
|
||||
|
||||
//check the audit log has a line that contains all the values
|
||||
private void checkAuditLogRecord(boolean exist, String... values) throws Exception {
|
||||
assertTrue(auditLog.exists());
|
||||
boolean hasRecord = false;
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(auditLog))) {
|
||||
String line = reader.readLine();
|
||||
while (line != null) {
|
||||
if (line.contains(values[0])) {
|
||||
boolean hasAll = true;
|
||||
for (int i = 1; i < values.length; i++) {
|
||||
if (!line.contains(values[i])) {
|
||||
hasAll = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasAll) {
|
||||
hasRecord = true;
|
||||
System.out.println("audit has it: " + line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
line = reader.readLine();
|
||||
}
|
||||
if (exist) {
|
||||
assertTrue(hasRecord);
|
||||
} else {
|
||||
assertFalse(hasRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Additional logger names to configure (root logger is always configured)
|
||||
# Root logger option
|
||||
loggers=org.eclipse.jetty,org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms.server,org.apache.activemq.artemis.integration.bootstrap,org.apache.activemq.audit.base,org.apache.activemq.audit.message
|
||||
|
||||
# Root logger level
|
||||
logger.level=INFO
|
||||
# ActiveMQ Artemis logger levels
|
||||
logger.org.apache.activemq.artemis.core.server.level=INFO
|
||||
logger.org.apache.activemq.artemis.journal.level=INFO
|
||||
logger.org.apache.activemq.artemis.utils.level=INFO
|
||||
logger.org.apache.activemq.artemis.jms.level=INFO
|
||||
logger.org.apache.activemq.artemis.integration.bootstrap.level=INFO
|
||||
logger.org.eclipse.jetty.level=WARN
|
||||
# Root logger handlers
|
||||
logger.handlers=FILE,CONSOLE
|
||||
|
||||
logger.org.apache.activemq.audit.base.level=INFO
|
||||
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.base.useParentHandlers=false
|
||||
|
||||
logger.org.apache.activemq.audit.message.level=INFO
|
||||
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.message.useParentHandlers=false
|
||||
|
||||
# Console handler configuration
|
||||
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
|
||||
handler.CONSOLE.properties=autoFlush
|
||||
handler.CONSOLE.level=DEBUG
|
||||
handler.CONSOLE.autoFlush=true
|
||||
handler.CONSOLE.formatter=PATTERN
|
||||
|
||||
# File handler configuration
|
||||
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
|
||||
handler.FILE.level=DEBUG
|
||||
handler.FILE.properties=suffix,append,autoFlush,fileName
|
||||
handler.FILE.suffix=.yyyy-MM-dd
|
||||
handler.FILE.append=true
|
||||
handler.FILE.autoFlush=true
|
||||
handler.FILE.fileName=target/artemis.log
|
||||
handler.FILE.formatter=PATTERN
|
||||
|
||||
# Formatter pattern configuration
|
||||
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
||||
formatter.PATTERN.properties=pattern
|
||||
formatter.PATTERN.pattern=%d %-5p [%c] %s%E%n
|
||||
|
||||
#Audit logger
|
||||
handler.AUDIT_FILE.level=DEBUG
|
||||
handler.AUDIT_FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
|
||||
handler.AUDIT_FILE.properties=suffix,append,autoFlush,fileName
|
||||
handler.AUDIT_FILE.suffix=.yyyy-MM-dd
|
||||
handler.AUDIT_FILE.append=true
|
||||
handler.AUDIT_FILE.autoFlush=true
|
||||
handler.AUDIT_FILE.fileName=target/audit.log
|
||||
handler.AUDIT_FILE.formatter=AUDIT_PATTERN
|
||||
|
||||
formatter.AUDIT_PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
||||
formatter.AUDIT_PATTERN.properties=pattern
|
||||
formatter.AUDIT_PATTERN.pattern=%d [AUDIT](%t) %s%E%n
|
|
@ -0,0 +1,76 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Additional logger names to configure (root logger is always configured)
|
||||
# Root logger option
|
||||
loggers=org.eclipse.jetty,org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms.server,org.apache.activemq.artemis.integration.bootstrap,org.apache.activemq.audit.base,org.apache.activemq.audit.message
|
||||
|
||||
# Root logger level
|
||||
logger.level=INFO
|
||||
# ActiveMQ Artemis logger levels
|
||||
logger.org.apache.activemq.artemis.core.server.level=INFO
|
||||
logger.org.apache.activemq.artemis.journal.level=INFO
|
||||
logger.org.apache.activemq.artemis.utils.level=INFO
|
||||
logger.org.apache.activemq.artemis.jms.level=INFO
|
||||
logger.org.apache.activemq.artemis.integration.bootstrap.level=INFO
|
||||
logger.org.eclipse.jetty.level=WARN
|
||||
# Root logger handlers
|
||||
logger.handlers=FILE,CONSOLE
|
||||
|
||||
logger.org.apache.activemq.audit.base.level=INFO
|
||||
logger.org.apache.activemq.audit.base.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.base.useParentHandlers=false
|
||||
|
||||
logger.org.apache.activemq.audit.message.level=ERROR
|
||||
logger.org.apache.activemq.audit.message.handlers=AUDIT_FILE
|
||||
logger.org.apache.activemq.audit.message.useParentHandlers=false
|
||||
|
||||
# Console handler configuration
|
||||
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
|
||||
handler.CONSOLE.properties=autoFlush
|
||||
handler.CONSOLE.level=DEBUG
|
||||
handler.CONSOLE.autoFlush=true
|
||||
handler.CONSOLE.formatter=PATTERN
|
||||
|
||||
# File handler configuration
|
||||
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
|
||||
handler.FILE.level=DEBUG
|
||||
handler.FILE.properties=suffix,append,autoFlush,fileName
|
||||
handler.FILE.suffix=.yyyy-MM-dd
|
||||
handler.FILE.append=true
|
||||
handler.FILE.autoFlush=true
|
||||
handler.FILE.fileName=target/artemis.log
|
||||
handler.FILE.formatter=PATTERN
|
||||
|
||||
# Formatter pattern configuration
|
||||
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
||||
formatter.PATTERN.properties=pattern
|
||||
formatter.PATTERN.pattern=%d %-5p [%c] %s%E%n
|
||||
|
||||
#Audit logger
|
||||
handler.AUDIT_FILE.level=INFO
|
||||
handler.AUDIT_FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
|
||||
handler.AUDIT_FILE.properties=suffix,append,autoFlush,fileName
|
||||
handler.AUDIT_FILE.suffix=.yyyy-MM-dd
|
||||
handler.AUDIT_FILE.append=true
|
||||
handler.AUDIT_FILE.autoFlush=true
|
||||
handler.AUDIT_FILE.fileName=target/audit.log
|
||||
handler.AUDIT_FILE.formatter=AUDIT_PATTERN
|
||||
|
||||
formatter.AUDIT_PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
||||
formatter.AUDIT_PATTERN.properties=pattern
|
||||
formatter.AUDIT_PATTERN.pattern=%d [AUDIT](%t) %s%E%n
|
Loading…
Reference in New Issue