flex消息机制 flex-blazeds-java

来源:互联网 发布:换掉山本宽 知乎 编辑:程序博客网 时间:2024/05/17 09:16

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>



 

原创粉丝点击