Last active
November 23, 2017 10:51
-
-
Save djuang1/1957dc0b71b89b983d85026468b9cf83 to your computer and use it in GitHub Desktop.
Java code to create Business Event in Mule Management Console (MMC)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mulesoft.dejim; | |
import java.util.HashMap; | |
import java.util.Map; | |
//import org.apache.commons.logging.Log; | |
//import org.apache.commons.logging.LogFactory; | |
import org.mule.DefaultMuleEvent; | |
import org.mule.MessageExchangePattern; | |
import org.mule.api.MuleEvent; | |
import org.mule.api.MuleEventContext; | |
import org.mule.api.context.notification.ServerNotification; | |
import org.mule.api.lifecycle.Callable; | |
import com.mulesoft.mule.tracking.event.AbstractEventNotificationFiringMessageProcessor; | |
import com.mulesoft.mule.tracking.event.EventNotification; | |
public class CustomBusinessEventComponent extends AbstractEventNotificationFiringMessageProcessor implements Callable{ | |
//private static Log logger = LogFactory.getLog(CustomBusinessEventComponent.class); | |
@Override | |
public Object onCall(MuleEventContext eventContext) throws Exception { | |
DefaultMuleEvent muleEvent = new DefaultMuleEvent(eventContext.getMessage(), MessageExchangePattern.REQUEST_RESPONSE, eventContext.getFlowConstruct()); | |
// Create the ServerNotification to listen for the Business Event | |
final ServerNotification notification = this.createNotification(muleEvent); | |
// Fire off the Business Event for the Server to pick up | |
eventContext.getMuleContext().fireNotification(notification); | |
return eventContext; | |
} | |
@Override | |
protected EventNotification createNotification(final MuleEvent muleEvent) { | |
// Create KPIs (Key, Value) | |
Map<String, String> metaData = new HashMap<String, String>(); | |
metaData.put("Test","Component"); | |
return createNotification(muleEvent, "custom-event", null, metaData); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the following line to your Mule flow to add the component:
<component class="com.mulesoft.dejim.CustomBusinessEventComponent" doc:name="Create Business Event"/>