@Override public int compare(MuleMessage message1, MuleMessage message2) { int val1 = message1.getInvocationProperty(MULE_ARRIVAL_ORDER_PROPERTY, -1); int val2 = message2.getInvocationProperty(MULE_ARRIVAL_ORDER_PROPERTY, -1); return val1 - val2; } }
@Override public Object getValue() { return message.getInvocationProperty(name); }
protected String getBodyParameterName(MuleMessage message) { String bodyParameter = message.getOutboundProperty(HttpConnector.HTTP_POST_BODY_PARAM_PROPERTY); if (bodyParameter == null) { bodyParameter = message.getInvocationProperty(HttpConnector.HTTP_POST_BODY_PARAM_PROPERTY); } return bodyParameter; }
private void checkForContentType(MuleMessage msg, EntityEnclosingMethod method) { // if a content type was specified on the endpoint, use it String outgoingContentType = msg.getInvocationProperty(HttpConstants.HEADER_CONTENT_TYPE); if (outgoingContentType != null) { method.setRequestHeader(HttpConstants.HEADER_CONTENT_TYPE, outgoingContentType); } }
@Override public int compare(MuleEvent event1, MuleEvent event2) { int val1 = event1.getMessage().getInvocationProperty(MULE_ARRIVAL_ORDER_PROPERTY, -1); int val2 = event2.getMessage().getInvocationProperty(MULE_ARRIVAL_ORDER_PROPERTY, -1); return val1 - val2; } }
protected String detectHttpMethod(MuleMessage msg) { String method = msg.getOutboundProperty(HttpConnector.HTTP_METHOD_PROPERTY, null); if (method == null) { method = msg.getInvocationProperty(HttpConnector.HTTP_METHOD_PROPERTY, HttpConstants.METHOD_POST); } return method; }
/** * Message aware transformer that retrieves logical address from message. */ @Override public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { String logicalAddress = message.getInvocationProperty("logical-address"); log.debug("Add logical-address to the payload as an object-array, {}", logicalAddress); return new Object[] {logicalAddress, message.getPayload()}; } }
public boolean accept(MuleMessage msg) { Object accept = msg.getInvocationProperty(toString()); if (accept == null && SxcFilteringOutboundRouter.getCurrentMessage() == null) { return false; } else if (accept == null) { throw new UndefinedMatchException(); } return (Boolean) accept; }
private Serializable storeEvent(final MuleEvent event) throws ObjectStoreException { final MuleMessage message = event.getMessage(); final Integer deliveryAttemptCount = message.getInvocationProperty( PROCESS_ATTEMPT_COUNT_PROPERTY_NAME, DEFAULT_PROCESS_ATTEMPT_COUNT_PROPERTY_VALUE); return storeEvent(event, deliveryAttemptCount); }
public MuleMessage request(long timeout, MuleEvent event) throws Exception { EndpointURI uri = getEndpointURIForMessage(event); if (endpoint instanceof NullInboundEndpoint) { builder.setURIBuilder(new URIBuilder(uri)); endpoint = builder.buildInboundEndpoint(); } InboundEndpoint inboundEndpoint = new DynamicURIInboundEndpoint(endpoint, uri); if (event.getMessage().getInvocationProperty(MuleProperties.MULE_CREDENTIALS_PROPERTY) != null) { inboundEndpoint.getProperties().put(MuleProperties.MULE_CREDENTIALS_PROPERTY, event.getMessage().getInvocationProperty(MuleProperties.MULE_CREDENTIALS_PROPERTY)); } return super.request(timeout); }
public void handleMessage(Message message) throws Fault { MuleEvent event = (MuleEvent) message.getExchange().get(CxfConstants.MULE_EVENT); if (event == null || event instanceof NonBlockingVoidMuleEvent) { return; } Collection<Attachment> a = event.getMessage().getInvocationProperty(CxfConstants.ATTACHMENTS); if (a != null) { message.setAttachments(a); } } }
/** * Takes the set of CXF attachments from the CxfConstants.ATTACHMENTS invocation properties and sets them as inbound * attachments in the Mule Message. */ private void copyAttachmentsResponse(MuleEvent event) throws MessagingException { MuleMessage message = event.getMessage(); if (message.getInvocationProperty(CxfConstants.ATTACHMENTS) != null) { Collection<Attachment> attachments = message.getInvocationProperty(CxfConstants.ATTACHMENTS); for (Attachment attachment : attachments) { try { ((DefaultMuleMessage) message).addInboundAttachment(attachment.getId(), attachment.getDataHandler()); } catch (Exception e) { throw new MessagingException(CoreMessages.createStaticMessage("Could not set inbound attachment %s", attachment.getId()), event, e, this); } } } }
/** * Message aware transformer that ... */ @Override public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { // Perform any message aware processing here, otherwise delegate as much as possible to pojoTransform() for easier unit testing QueryObject queryObject = (QueryObject)message.getInvocationProperty("queryObject"); //return pojoTransform(queryObject, message.getPayload(), outputEncoding); PojoTransformResult ptr = pojoTransform(queryObject, message.getPayload(), outputEncoding); // set ProcessingStatus result as properties for log tracking message.setInvocationProperty(AgpLoggingProperties.PROCESSINGSTATUS_COUNT_TOTAL, String.valueOf(ptr.procStatusLogFormat.getProcStatusCountTot())); message.setInvocationProperty(AgpLoggingProperties.PROCESSINGSTATUS_COUNT_FAIL, String.valueOf(ptr.procStatusLogFormat.getProcStatusCountFail())); message.setInvocationProperty(AgpLoggingProperties.PROCESSINGSTATUS, ptr.procStatusLogFormat.getProcStatus()); message.setPayload(ptr.xml); return message; }
@Override public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { ExceptionPayload ep = message.getExceptionPayload(); Throwable e = ep.getException(); Throwable re = ep.getRootException(); String cid = message.getCorrelationId(); log.warn("CorrId: {}, Error: {}, {}", new Object[] {cid, e, re}); String errorText = e.getMessage(); if (re != null) { errorText += ", " + re.getMessage(); } LastUnsuccessfulSynchErrorType error = new LastUnsuccessfulSynchErrorType(); error.setCausingAgent(CausingAgentEnum.VIRTUALIZATION_PLATFORM); error.setCode(Integer.toString(ep.getCode())); error.setText(errorText); String logicalAddress = message.getInvocationProperty("logical-address"); message.setExceptionPayload(null); message.setPayload(new Object[] {logicalAddress, error}); return message; } }
/** * An exception is thrown if http.status >= 400 and exceptions are not disabled * through one of the following mechanisms in order of precedence: * * - setting to true the flow variable "http.disable.status.code.exception.check" * - setting to true the outbound property "http.disable.status.code.exception.check" * - setting to false the outbound endpoint attribute "exceptionOnMessageError" * * @return if an exception should be thrown */ protected boolean returnException(MuleEvent event, HttpMethod httpMethod) { String disableCheck = event.getMessage().getInvocationProperty(HttpConnector.HTTP_DISABLE_STATUS_CODE_EXCEPTION_CHECK); if (disableCheck == null) { disableCheck = event.getMessage().getOutboundProperty(HttpConnector.HTTP_DISABLE_STATUS_CODE_EXCEPTION_CHECK); } boolean throwException; if (disableCheck == null) { throwException = !"false".equals(endpoint.getProperty("exceptionOnMessageError")); } else { throwException = !BooleanUtils.toBoolean(disableCheck); } return httpMethod.getStatusCode() >= ERROR_STATUS_CODE_RANGE_START && throwException; }
protected TransmissionSession trackTransmission(B2BProvider b2bProvider, MuleEvent muleEvent, Direction direction, Transmission transmission, TransmissionType transmissionType) throws B2BProviderException { TransmissionSession transmissionSession = muleEvent.getMessage().getInvocationProperty(B2B_TRANSMISSION_SESSION_FLOW_VARIABLE_KEY); Factory<TransmissionContext> transmissionContextFactory = b2bProvider.getFactoryResolver().getFactory(TransmissionContext.class); TransmissionContext transmissionContext = transmissionContextFactory.create(); transmissionContext.setMuleEventId(muleEvent.getId()); transmissionContext.setTransmissionSession(transmissionSession); return b2bProvider.writeTransmission(direction, transmission, transmissionContext, transmissionType); }
@Override public MuleEvent process(MuleEvent event) throws MuleException { MuleEvent resultEvent; if (shouldProcessEvent(event)) { Object replyTo = event.getReplyToDestination(); ReplyToHandler replyToHandler = event.getReplyToHandler(); resultEvent = processNext(event); // Allow components to stop processing of the ReplyTo property (e.g. CXF) final String replyToStop = resultEvent.getMessage().getInvocationProperty( MuleProperties.MULE_REPLY_TO_STOP_PROPERTY); if (resultEvent != null && !VoidMuleEvent.getInstance().equals(resultEvent) && !BooleanUtils.toBoolean(replyToStop)) { // reply-to processing should not resurrect a dead event processReplyTo(event, resultEvent, replyToHandler, replyTo); } } else { resultEvent = processNext(event); } return resultEvent; }
public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { QueryObject qo = (QueryObject)message.getInvocationProperty("queryObject"); FindContentResponseType eiResp; List<Object[]> transformedPayload;
/** * {@inheritDoc} */ @Override protected final MuleEvent doProcess(MuleEvent event) throws Exception { this.notifyCallbackReception(event); try { this.adapter.setOauthVerifier(((String) event.getMessage() .getInvocationProperty("_oauthVerifier"))); this.adapter.fetchAccessToken(requestTokenUrl, this.getAccessTokenUrl(), authorizationUrl, this.getRedirectUri()); } catch (Exception e) { throw new MessagingException(MessageFactory.createStaticMessage("Unable to fetch access token"), event, e, this); } return event; }
private void incrementProcessAttemptCountAndRescheduleOrRemoveFromStore(final Serializable eventStoreKey, Exception lastException) { try { final MuleEvent event = getUntilSuccessfulConfiguration().getObjectStore().remove(eventStoreKey); final MuleEvent mutableEvent = threadSafeCopy(event); final MuleMessage message = mutableEvent.getMessage(); final Integer deliveryAttemptCount = message.getInvocationProperty( PROCESS_ATTEMPT_COUNT_PROPERTY_NAME, DEFAULT_PROCESS_ATTEMPT_COUNT_PROPERTY_VALUE); if (deliveryAttemptCount <= getUntilSuccessfulConfiguration().getMaxRetries()) { // we store the incremented version unless the max attempt count has // been reached message.setInvocationProperty(PROCESS_ATTEMPT_COUNT_PROPERTY_NAME, deliveryAttemptCount + 1); getUntilSuccessfulConfiguration().getObjectStore().store(eventStoreKey, mutableEvent); this.scheduleForProcessing(eventStoreKey, false); } else { abandonRetries(event, mutableEvent, lastException); } } catch (final ObjectStoreException ose) { logger.error("Failed to increment failure count for event stored with key: " + eventStoreKey, ose); } }