我正在使用Camel 2.18和Java8。有什么方法可以检查Camel中消息的大小,以便我可以对其进行验证?
例如,我有一个可以访问主体的处理器:
private PrintDocument _printDocument = new PrintDocument();
private int _checkPrint;
public Form1()
{
InitializeComponent();
_printDocument.BeginPrint += _printDocument_BeginPrint;
_printDocument.PrintPage += _printDocument_PrintPage;
}
private void btnPrint_Click(object sender, EventArgs e)
{
PrintDialog printDialog=new PrintDialog();
if (printDialog.ShowDialog() == DialogResult.OK)
_printDocument.Print();
}
private void _printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
// Print the content of RichTextBox. Store the last character printed.
_checkPrint = rchEditor.Print(_checkPrint, rchEditor.TextLength, e);
// Check for more pages
e.HasMorePages = _checkPrint < rchEditor.TextLength;
}
private void _printDocument_BeginPrint(object sender, PrintEventArgs e)
{
_checkPrint = 0;
}
现在,我想检查主体在内存中占用的大小。
原因是,如果正文大于1MB,我必须提出一个例外。
发布到我的骆驼端点的消息只是简单的json:
Message msgIn = exchange.getIn();
msgIn.getBody()