java后台:消息的发布
MessageBroker msgBroker = MessageBroker.getMessageBroker(null); String clientID = UUIDUtils.createUUID(); AsyncMessage message = new AsyncMessage();message.setDestination("consumer"); message.setHeader("DSSubtopic", "test"); message.setClientId(clientID); message.setMessageId(UUIDUtils.createUUID()); message.setTimestamp(System.currentTimeMillis()); message.setBody(clientID); msgBroker.routeMessageToService(message, null);
flex前台订阅:
var fileReceiveConsumer:Consumer=new Consumer();
fileReceiveConsumer.destination="consumer";
fileReceiveConsumer.subtopic="test";
var channelSet:ChannelSet = new ChannelSet();
channelSet.addChannel( new StreamingAMFChannel(
"my-streaming-amf", "http://localhost:8080/szdlIM/messagebroker/streamingamf"););
fileReceiveConsumer.channelSet=channelSet;
fileReceiveConsumer.addEventListener(MessageEvent.MESSAGE,handle);
fileReceiveConsumer.subscribe();
配置文件message-config.xml
<destination id="consumer">
<properties>
<server>
<allow-subtopics>true</allow-subtopics>
<subtopic-separator>.</subtopic-separator>
</server>
</properties>
<channels>
<channel ref="my-streaming-amf" />
<channel ref="my-polling-amf" />
</channels>
</destination>