public static boolean generateEvent(OMElement payload, OMElement topic,
EventBrokerService brokerService, int tenantId)
throws EventBrokerException {
if (payload == null) {
throw new EventBrokerException("Unable to generate event. No payload was given.");
}
CarbonEventingMessageReceiver dummyReceiver = new CarbonEventingMessageReceiver();
if (brokerService != null) {
dummyReceiver.setBrokerService(brokerService);
}
MessageContext mc = createMessageContext(payload, topic, tenantId);
try {
dummyReceiver.processMessage(mc);
} catch (Exception e) {
if (e instanceof EventBrokerException) {
throw (EventBrokerException) e;
}
throw new EventBrokerException("Unable to generate event.", e);
}
return true;
}