use of org.apache.synapse.eventing.builders.ResponseMessageBuilder in project wso2-synapse by wso2.
the class SynapseEventSource method receive.
/**
* Override the Message receiver method to accept subscriptions and events
*
* @param mc message context
* @throws AxisFault
*/
public void receive(MessageContext mc) throws AxisFault {
// Create synapse message context from the axis2 message context
SynapseConfiguration synCfg = (SynapseConfiguration) mc.getConfigurationContext().getAxisConfiguration().getParameter(SynapseConstants.SYNAPSE_CONFIG).getValue();
SynapseEnvironment synEnv = (SynapseEnvironment) mc.getConfigurationContext().getAxisConfiguration().getParameter(SynapseConstants.SYNAPSE_ENV).getValue();
org.apache.synapse.MessageContext smc = new Axis2MessageContext(mc, synCfg, synEnv);
// initialize the response message builder using the message context
ResponseMessageBuilder messageBuilder = new ResponseMessageBuilder(mc);
try {
if (EventingConstants.WSE_SUBSCRIBE.equals(mc.getWSAAction())) {
// add new subscription to the SynapseSubscription store through subscription manager
processSubscriptionRequest(mc, messageBuilder);
} else if (EventingConstants.WSE_UNSUBSCRIBE.equals(mc.getWSAAction())) {
// Unsubscribe the matching subscription
processUnSubscribeRequest(mc, messageBuilder);
} else if (EventingConstants.WSE_GET_STATUS.equals(mc.getWSAAction())) {
// Response with the status of the subscription
processGetStatusRequest(mc, messageBuilder);
} else if (EventingConstants.WSE_RENEW.equals(mc.getWSAAction())) {
// Renew subscription
processReNewRequest(mc, messageBuilder);
} else {
// Treat as an Event
if (log.isDebugEnabled()) {
log.debug("Event received");
}
dispatchEvents(smc);
}
} catch (EventException e) {
handleException("Subscription manager processing error", e);
}
}
Aggregations