apply patch and add test for: https://issues.apache.org/jira/browse/AMQ-3436 Some modifications needed for the patch to work correctly.