25. 基于VM的事件驱动框架的实现----实例
QueueChannel queueChannel = new QueueChannel();
// register the queueChannel
ChannelRegistry.registerMessageChannel(channelName,queueChannel);
// build a new message
Message<String> message = MessageBuilder.withPayload("this is a message")
.setHeader("headerA", "headerValue").build();
// send a message to the queueChannel
queueChannel.send(message);
// lookup the queueChannl,may be an empty channel before the registried
QueueChannel queueChannel = ChannelRegistry.lookupQueueChannel(channelName);
// blocking until there is a message
Message message = queueChannel.receive();
System.out.println("Received message : " + message.toString());
www.qunar.com