}
}
private void testBrokerConfiguration(String brokerName)
throws BrokerManagerAdminServiceException {
BrokerHolder brokerHolder = BrokerHolder.getInstance();
BrokerManagerHolder brokerManager = BrokerManagerHolder.getInstance();
int tenantId = CarbonContext.getCurrentContext().getTenantId();
BrokerConfiguration brokerConfiguration =
brokerManager.getBrokerManagerService().getBrokerConfiguration(brokerName, tenantId);
org.wso2.carbon.broker.core.BrokerConfiguration configuration =
new org.wso2.carbon.broker.core.BrokerConfiguration();
configuration.setName(brokerConfiguration.getName());
configuration.setType(brokerConfiguration.getType());
configuration.setProperties(brokerConfiguration.getProperties());
XMLStreamReader reader1 = null;
String testMessage = " <brokerConfigurationTest>\n" +
" <message>This is a test message.</message>\n" +
" </brokerConfigurationTest>";
try {
reader1 = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(testMessage.getBytes()));
StAXOMBuilder builder1 = new StAXOMBuilder(reader1);
brokerHolder.getBrokerService().publish(configuration, "test", builder1.getDocumentElement());
} catch (XMLStreamException e) {
removeBrokerConfiguration(brokerName);
throw new BrokerManagerAdminServiceException("Failed to prepare test message to " +
"publish to broker:" + brokerName, e);
} catch (BrokerEventProcessingException e) {