channel.send(MessageBuilder.withPayload("FooMessage").setHeader("foo", "bar").build());
Map<String, String> headers = new HashMap<String, String>();
headers.put("foo", "bar");
MessageSelector selector = new HeaderMatchingMessageSelector(headers);
Message<?> receivedMessage = channel.receive(selector, 1000L);
Assert.assertEquals(receivedMessage.getPayload(), "FooMessage");
Assert.assertEquals(receivedMessage.getHeaders().get("foo"), "bar");