private InternalMessage createFailureResponse(final InternalMessage requestMessage,
final int statusCode,
final String stateDescription,
String... params)
{
final InternalMessageHeader requestHeader = requestMessage.getMessageHeader();
final MutableMessageHeader responseHeader = new MutableMessageHeader();
responseHeader.setCorrelationId(requestHeader.getCorrelationId() == null
? requestHeader.getMessageId()
: requestHeader.getCorrelationId());
responseHeader.setMessageId(UUID.randomUUID().toString());
for(String header : requestHeader.getHeaderNames())
{
responseHeader.setHeader(header, requestHeader.getHeader(header));
}
responseHeader.setHeader(STATUS_CODE_HEADER, statusCode);
responseHeader.setHeader(STATUS_DESCRIPTION_HEADER, MessageFormat.format(stateDescription, params));
return InternalMessage.createBytesMessage(_virtualHost.getMessageStore(), responseHeader, new byte[0]);