加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Blazeds Messaging service

发布时间:2020-12-15 04:27:53 所属栏目:百科 来源:网络整理
导读:Blazeds核心包括RPC Service和Messageing Service。 详情可以参考: http://www.iteye.com/topic/267517? http://www.iteye.com/topic/267521 Messaging Service 你需要在messaging-config.xml下的service节点下添加一个子节点:destination id="TestKenny"/

Blazeds核心包括RPC Service和Messageing Service。

详情可以参考:

http://www.iteye.com/topic/267517?

http://www.iteye.com/topic/267521

Messaging Service 你需要在messaging-config.xml下的service节点下添加一个子节点:<destination id="TestKenny"/>

如图1.

然后写Flex 代码:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" 
			   minWidth="955" minHeight="600" xmlns:pivot="com.flexmonster.pivot.*"
			   creationComplete="application1_creationCompleteHandler(event)">
	<fx:Declarations>  
		<s:Producer acknowledge="producer_acknowledgeHandler(event)"
					fault="producer_faultHandler(event)"
					destination="TestKenny" id="producer"/>
		<s:Consumer id="consumer" destination="TestKenny" fault="producer_faultHandler(event)" 
					message="consumer_messageHandler(event)"/>
	</fx:Declarations>  
	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			import mx.messaging.ChannelSet;
			import mx.messaging.channels.AMFChannel;
			import mx.messaging.events.MessageAckEvent;
			import mx.messaging.events.MessageEvent;
			import mx.messaging.events.MessageFaultEvent;
			import mx.messaging.messages.AsyncMessage;
			
			
			protected function button2_clickHandler(event:MouseEvent):void
			{
				var msg:AsyncMessage = new AsyncMessage();
				msg.body = "aaa";
				producer.send(msg);
			}
			
			protected function producer_acknowledgeHandler(event:MessageAckEvent):void
			{
				trace("producer_acknowledgeHandler");
				
			}
			
			protected function producer_faultHandler(event:MessageFaultEvent):void
			{
				trace("producer_faultHandler");
				
			}
			
			protected function consumer_messageHandler(event:MessageEvent):void
			{
				trace("consumer_messageHandler" + event.message.body);
				
			}
			
			protected function application1_creationCompleteHandler(event:FlexEvent):void
			{
				var channelSet:ChannelSet = new ChannelSet();
				var myPollingAMF:AMFChannel = new AMFChannel("my-polling-amf","http://localhost:8400/blazeds/messagebroker/amfpolling");
				myPollingAMF.pollingEnabled = true;
				myPollingAMF.pollingInterval = 2000;
				channelSet.addChannel(myPollingAMF);
				consumer.channelSet = channelSet;
				producer.channelSet = channelSet;
				consumer.subscribe();
			}
			
		]]>
	</fx:Script>
	<s:Button label="Test" click="button2_clickHandler(event)"/>
</s:Application>

?然后重启下Tomcat,然后访问就可以了。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读