public Object onCall(MuleEventContext context) throws Exception { if (getEventCallback() != null) { getEventCallback().eventReceived(context, this); } Map map = (Map) context.getMessage().getPayload(); return map.get("data") + " Received"; }
@Override public Object onCall(MuleEventContext eventContext) throws Exception { String payload = (String) eventContext.getMessage().getPayload(); return String.format("This book [%s] was made by : %s", payload, propertiesApp.get("by")); }
public ExceptionMessage( Object message, Throwable exception, String componentName, EndpointURI endpointUri) { super(message); this.exception = exception; timeStamp = new Date(); this.componentName = componentName; this.endpointUri = endpointUri; MuleEventContext ctx = RequestContext.getEventContext(); if (ctx != null) { MuleMessage msg = ctx.getMessage(); for (Iterator iterator = msg.getPropertyNames().iterator(); iterator.hasNext(); ) { String propertyKey = (String) iterator.next(); setProperty(propertyKey, msg.getProperty(propertyKey)); } } }
public void testOverwriteFlagEnabledByDefault() throws Exception { MessagePropertiesTransformer t = new MessagePropertiesTransformer(); Map add = new HashMap(); add.put("addedProperty", "overwrittenValue"); t.setAddProperties(add); t.setMuleContext(muleContext); MuleMessage msg = new DefaultMuleMessage("message", (Map) null); msg.setProperty("addedProperty", "originalValue"); MuleEventContext ctx = getTestEventContext(msg); // context clones message msg = ctx.getMessage(); DefaultMuleMessage transformed = (DefaultMuleMessage) t.transform(msg, null); assertSame(msg, transformed); assertEquals(msg.getUniqueId(), transformed.getUniqueId()); assertEquals(msg.getPayload(), transformed.getPayload()); // property values will be different assertEquals(msg.getPropertyNames(), transformed.getPropertyNames()); assertEquals("overwrittenValue", transformed.getProperty("addedProperty")); }
@Override public Object onCall(MuleEventContext eventContext) throws Exception { WorkerType worker = ((WorkerType) eventContext.getMessage().getPayload()); if (worker.getWorkerData().getOrganizationData() != null) for (WorkerOrganizationMembershipDataType role : worker.getWorkerData().getOrganizationData().getWorkerOrganizationData()) { if (role.getOrganizationData().getOrganizationName().toLowerCase().contains("sales")) { return true; } } return false; }
@Override public Object onCall(MuleEventContext eventContext) throws Exception { PusherChannel channel = new PusherChannel( "being-seen", "48682", "17eb9ecb711bee47d32d", "7a5a500515001f4c077e", transport); String itemId = (String) eventContext.getMessage().getInvocationProperty("itemId"); String userName = (String) eventContext.getMessage().getInvocationProperty("userName"); String projectId = (String) eventContext.getMessage().getInboundProperty("projectId"); channel.pushEvent( "item-selected", "{\"itemId\": \"" + itemId + "\",\"userName\":\"" + userName + "\",\"projectId\":\"" + projectId + "\"}"); return null; }
/** * andles requests for Mock PII Audit * * @param context * @return Object * @throws Exception */ @Override public Object onCall(MuleEventContext context) throws Exception { String text = (String) context.getMessage().getPayload(); String auditResult = null; if (text.length() > 21) { auditResult = "FOUND PII"; } else { auditResult = "NO PII"; } return auditResult; }
@Override public Object onCall(MuleEventContext eventContext) throws Exception { logger.info("Entering onCall ....."); MuleMessage message = eventContext.getMessage(); List messageList = (List) message.getPayload(); logger.info("message.getPayload() => {}", messageList); MuleClient client = context.getClient(); StringBuilder aggregated = new StringBuilder("AGGREGATED ["); for (int i = 0; i < messageList.size(); i++) { String messageType = (String) messageList.get(i); MuleMessage muleMessage = new DefaultMuleMessage(messageType, context); StringBuilder muleURL = new StringBuilder(); muleMessage.setOutboundProperty("X", messageType); client.dispatch("jms://queue1", muleMessage); MuleMessage muleMessage2 = new DefaultMuleMessage(messageType, context); muleMessage2.setOutboundProperty("X", messageType); MuleMessage result = client.send("jms://queue2", muleMessage2); aggregated.append(result.getPayload()).append(","); } aggregated.append("]"); logger.info("Aggregated response {}", aggregated); return eventContext; }
public Object onCall(MuleEventContext context) throws Exception { return context.getMessage(); }