This closes #4089
This commit is contained in:
commit
38ee7bad33
|
@ -2960,4 +2960,20 @@ public interface AuditLogger extends BasicLogger {
|
||||||
@LogMessage(level = Logger.Level.INFO)
|
@LogMessage(level = Logger.Level.INFO)
|
||||||
@Message(id = 601761, value = "User {0} rolled back transaction {1} involving {2}", format = Message.Format.MESSAGE_FORMAT)
|
@Message(id = 601761, value = "User {0} rolled back transaction {1} involving {2}", format = Message.Format.MESSAGE_FORMAT)
|
||||||
void rolledBackTransaction(String user, String tx, String resource);
|
void rolledBackTransaction(String user, String tx, String resource);
|
||||||
|
|
||||||
|
static void addConnector(Object source, Object... args) {
|
||||||
|
BASE_LOGGER.addConnector(getCaller(), source, arrayToString(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
@LogMessage(level = Logger.Level.INFO)
|
||||||
|
@Message(id = 601762, value = "User {0} is adding a connector on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
|
||||||
|
void addConnector(String user, Object source, Object... args);
|
||||||
|
|
||||||
|
static void removeConnector(Object source, Object... args) {
|
||||||
|
BASE_LOGGER.addConnector(getCaller(), source, arrayToString(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
@LogMessage(level = Logger.Level.INFO)
|
||||||
|
@Message(id = 601763, value = "User {0} is remove a connector on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
|
||||||
|
void removeConnector(String user, Object source, Object... args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1823,6 +1823,13 @@ public interface ActiveMQServerControl {
|
||||||
@Operation(desc = "Destroy a bridge", impact = MBeanOperationInfo.ACTION)
|
@Operation(desc = "Destroy a bridge", impact = MBeanOperationInfo.ACTION)
|
||||||
void destroyBridge(@Parameter(name = "name", desc = "Name of the bridge") String name) throws Exception;
|
void destroyBridge(@Parameter(name = "name", desc = "Name of the bridge") String name) throws Exception;
|
||||||
|
|
||||||
|
@Operation(desc = "Add a connector", impact = MBeanOperationInfo.ACTION)
|
||||||
|
void addConnector(@Parameter(name = "name", desc = "the unique name of the connector to add; may be referenced from other components (e.g. bridges)") String name,
|
||||||
|
@Parameter(name = "url", desc = "the URL of the connector") String url) throws Exception;
|
||||||
|
|
||||||
|
@Operation(desc = "Remove a connector", impact = MBeanOperationInfo.ACTION)
|
||||||
|
void removeConnector(@Parameter(name = "name", desc = "the name of the connector to remove") String name) throws Exception;
|
||||||
|
|
||||||
@Operation(desc = "List the existing broker connections", impact = MBeanOperationInfo.INFO)
|
@Operation(desc = "List the existing broker connections", impact = MBeanOperationInfo.INFO)
|
||||||
String listBrokerConnections();
|
String listBrokerConnections();
|
||||||
|
|
||||||
|
|
|
@ -3911,6 +3911,38 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addConnector(String name, String url) throws Exception {
|
||||||
|
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||||
|
AuditLogger.addConnector(this.server, name, url);
|
||||||
|
}
|
||||||
|
checkStarted();
|
||||||
|
|
||||||
|
clearIO();
|
||||||
|
|
||||||
|
try {
|
||||||
|
server.getConfiguration().addConnectorConfiguration(name, url);
|
||||||
|
} finally {
|
||||||
|
blockOnIO();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeConnector(String name) throws Exception {
|
||||||
|
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||||
|
AuditLogger.removeConnector(this.server, name);
|
||||||
|
}
|
||||||
|
checkStarted();
|
||||||
|
|
||||||
|
clearIO();
|
||||||
|
|
||||||
|
try {
|
||||||
|
server.getConfiguration().getConnectorConfigurations().remove(name);
|
||||||
|
} finally {
|
||||||
|
blockOnIO();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String listBrokerConnections() {
|
public String listBrokerConnections() {
|
||||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||||
|
|
|
@ -1984,6 +1984,15 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateAndDestroyBridgeFromJson() throws Exception {
|
public void testCreateAndDestroyBridgeFromJson() throws Exception {
|
||||||
|
internalTestCreateAndDestroyBridgeFromJson(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateAndDestroyBridgeFromJsonDynamicConnector() throws Exception {
|
||||||
|
internalTestCreateAndDestroyBridgeFromJson(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalTestCreateAndDestroyBridgeFromJson(boolean dynamicConnector) throws Exception {
|
||||||
String name = RandomUtil.randomString();
|
String name = RandomUtil.randomString();
|
||||||
String sourceAddress = RandomUtil.randomString();
|
String sourceAddress = RandomUtil.randomString();
|
||||||
String sourceQueue = RandomUtil.randomString();
|
String sourceQueue = RandomUtil.randomString();
|
||||||
|
@ -2007,13 +2016,19 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
||||||
session.createQueue(new QueueConfiguration(targetQueue).setAddress(targetAddress).setRoutingType(RoutingType.ANYCAST).setDurable(false));
|
session.createQueue(new QueueConfiguration(targetQueue).setAddress(targetAddress).setRoutingType(RoutingType.ANYCAST).setDurable(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String connectorName = connectorConfig.getName();
|
||||||
|
if (dynamicConnector) {
|
||||||
|
connectorName = RandomUtil.randomString();
|
||||||
|
serverControl.addConnector(connectorName, "vm://0");
|
||||||
|
}
|
||||||
|
|
||||||
BridgeConfiguration bridgeConfiguration = new BridgeConfiguration(name)
|
BridgeConfiguration bridgeConfiguration = new BridgeConfiguration(name)
|
||||||
.setQueueName(sourceQueue)
|
.setQueueName(sourceQueue)
|
||||||
.setForwardingAddress(targetAddress)
|
.setForwardingAddress(targetAddress)
|
||||||
.setUseDuplicateDetection(false)
|
.setUseDuplicateDetection(false)
|
||||||
.setConfirmationWindowSize(1)
|
.setConfirmationWindowSize(1)
|
||||||
.setProducerWindowSize(-1)
|
.setProducerWindowSize(-1)
|
||||||
.setStaticConnectors(Collections.singletonList(connectorConfig.getName()))
|
.setStaticConnectors(Collections.singletonList(connectorName))
|
||||||
.setHA(false)
|
.setHA(false)
|
||||||
.setUser(null)
|
.setUser(null)
|
||||||
.setPassword(null);
|
.setPassword(null);
|
||||||
|
@ -2072,6 +2087,16 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
||||||
locator.close();
|
locator.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddAndRemoveConnector() throws Exception {
|
||||||
|
ActiveMQServerControl serverControl = createManagementControl();
|
||||||
|
String connectorName = RandomUtil.randomString();
|
||||||
|
serverControl.addConnector(connectorName, "vm://0");
|
||||||
|
assertEquals(connectorName, server.getConfiguration().getConnectorConfigurations().get(connectorName).getName());
|
||||||
|
serverControl.removeConnector(connectorName);
|
||||||
|
assertNull(server.getConfiguration().getConnectorConfigurations().get(connectorName));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListPreparedTransactionDetails() throws Exception {
|
public void testListPreparedTransactionDetails() throws Exception {
|
||||||
SimpleString atestq = new SimpleString("BasicXaTestq");
|
SimpleString atestq = new SimpleString("BasicXaTestq");
|
||||||
|
|
|
@ -1587,6 +1587,16 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
||||||
proxy.invokeOperation("createBridge", bridgeConfiguration);
|
proxy.invokeOperation("createBridge", bridgeConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addConnector(String name, String url) throws Exception {
|
||||||
|
proxy.invokeOperation("addConnector", name, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeConnector(String name) throws Exception {
|
||||||
|
proxy.invokeOperation("removeConnector", name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String listProducersInfoAsJSON() throws Exception {
|
public String listProducersInfoAsJSON() throws Exception {
|
||||||
return (String) proxy.invokeOperation("listProducersInfoAsJSON");
|
return (String) proxy.invokeOperation("listProducersInfoAsJSON");
|
||||||
|
|
Loading…
Reference in New Issue