if (topicValue == null) {
handleException("Topic for the event cannot be found", synCtx);
} else {
org.apache.axis2.context.MessageContext mc =
((Axis2MessageContext)synCtx).getAxis2MessageContext();
EventBroker broker = (EventBroker) mc.getConfigurationContext().
getProperty("mediation.event.broker");
if (broker == null) {
handleException("EventBroker cannot be found", synCtx);
} else {
Message message = new Message();
if (expression == null) {
message.setMessage(synCtx.getEnvelope().getBody().getFirstElement());
} else {
try {
Object o = expression.selectSingleNode(synCtx);
if (o instanceof OMElement) {
message.setMessage((OMElement)o);
} else {
handleException("The result of the expression:" +
expression + " should be an OMElement", synCtx);
}
} catch (JaxenException e) {
handleException("Error evaluating the expression: " +
expression, synCtx);
}
}
int tenantID = SuperTenantCarbonContext.getCurrentContext(
mc.getConfigurationContext()).getTenantId();
try {
SuperTenantCarbonContext.startTenantFlow();
SuperTenantCarbonContext.getCurrentContext().setTenantId(tenantID);
SuperTenantCarbonContext.getCurrentContext().getTenantDomain(true);
broker.publish(message, topicValue);
} catch (EventBrokerException e) {
handleException("Error publishing the event to the broker", e, synCtx);
} catch (Exception e) {
log.error("Error in setting tenant information", e);
} finally {