Skip to content

Instantly share code, notes, and snippets.

@cgorshing
Created May 8, 2014 20:58
Show Gist options
  • Save cgorshing/008fa21c1a2501cc76a5 to your computer and use it in GitHub Desktop.
Save cgorshing/008fa21c1a2501cc76a5 to your computer and use it in GitHub Desktop.
In IdempotentRedeliveryPolicy
private String getIdForEvent(MuleEvent event) throws Exception
{
if (useSecureHash)
{
Object payload = event.getMessage().getPayload();
byte[] bytes = (byte[]) objectToByteArray.transform(payload);
if (payload instanceof InputStream)
{
// We've consumed the stream.
event.getMessage().setPayload(bytes);
}
MessageDigest md = MessageDigest.getInstance(messageDigestAlgorithm);
byte[] digestedBytes = md.digest(bytes);
return (String)byteArrayToHexString.transform(digestedBytes);
}
else
{
return event.getMuleContext().getExpressionManager().parse(idExpression, event, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment