智能公交调度系统-系统结合了GPSGIS GPRS 等,将车辆的状态信息实时传到调度中心,调度中心可以自动调度和监控车辆。通过将GPS接入后台在通过消息中间件将消息发送到前端,前端可以实时看到车辆运行状态、运行轨迹等信息。该县的公交数量有280辆,我们采用BlazeDS(免费)完全可以胜任,LCDS(商业)比较昂贵,但性能好。
那就简单介绍一下是以Flex为前台,结合BlazeDS和ActiveMQ以及Spring实现接收JMS消息的方法(publish/subscribe模式)。在消息订阅上采用UDP还是TCP根据具体情况具体选择,UDP传输速度快,TCP传输速度不如UDP,但可靠性好。视频传输、聊天软件大多采用的都是UDP。
具体的实现方式是:
1.用Spring中配置的Sender bean的send()方法向ActiveMQ发送JMS消息;
2.用Spring中配置的Receiver bean 的receive()方法从ActiveMQ接收消息;
3.然后通过BlazeDS的messaging模式将消息发送到Flex的消息订阅者上(推送到客户端)。
本例需要用到的环境包括:FlexPlugin、MyEclipse、ActiveMQ、BlazeDS
一.Blazeds
blazeDS采用amf协议。该协议可以传输Object,Array, Date, XML。由于AMF采用二进制编码,这种方式可以高度压缩数据,因此非常适合用来传递大量的资料。数据量越大,FlashRemoting的传输效能就越高,远远超过WebService。至于XML,LoadVars和loadVariables(),它们使用纯文本的传输方式,效能就更不能与FlashRemoting相提并论了。
将下载的blazeds.war 拷贝到tomcat webapp目录下,运行tomcat。Tomcat webapp目录下会生成blazeds文件夹。
二.ActiveMQ
ActiveMQ是Apache出品,最流行的、功能强大的即时通讯和集成模式的开源服务器。ActiveMQ 是一个完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现。提供客户端支持跨语言和协议,带有易于在充分支持JMS 1.1和1.4使用J2EE企业集成模式和许多先进的功能。
到官网下载activeMQ5.9 修改activeMQ conf文件夹下activemq.xml配置文件,加入UDP传输方式(<transportConnector name="udp" uri="udp://0.0.0.0:8123" />)
activemq.xml
- -<!--LicensedtotheApacheSoftwareFoundation(ASF)underoneormore
- contributorlicenseagreements.SeetheNOTICEfiledistributedwith
- thisworkforadditionalinformationregardingcopyrightownership.
- TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0
- (the"License");youmaynotusethisfileexceptincompliancewith
- theLicense.YoumayobtainacopyoftheLicenseat
- http://www.apache.org/licenses/LICENSE-2.0
- Unlessrequiredbyapplicablelaworagreedtoinwriting,software
- distributedundertheLicenseisdistributedonan"ASIS"BASIS,
- WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
- SeetheLicenseforthespecificlanguagegoverningpermissionsand
- limitationsundertheLicense.
- -->
- -
- -<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://activemq.apache.org/schema/corehttp://activemq.apache.org/schema/core/activemq-core.xsd">
- -
- -<beanclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- -<propertyname="locations">
- <value>file:${activemq.conf}/credentials.properties</value>
- </property>
- </bean>
- -
- <beanid="logQuery"class="org.fusesource.insight.log.log4j.Log4jLogQuery"lazy-init="false"scope="singleton"init-method="start"destroy-method="stop"/>
- -
- -<brokerxmlns="http://activemq.apache.org/schema/core"brokerName="localhost"dataDirectory="${activemq.data}">
- -<destinationPolicy>
- -<policyMap>
- -<policyEntries>
- -<policyEntrytopic=">">
- -<!--TheconstantPendingMessageLimitStrategyisusedtoprevent
- slowtopicconsumerstoblockproducersandaffectotherconsumers
- bylimitingthenumberofmessagesthatareretained
- Formoreinformation,see:
- http://activemq.apache.org/slow-consumer-handling.html
- -->
- -<pendingMessageLimitStrategy>
- <constantPendingMessageLimitStrategylimit="1000"/>
- </pendingMessageLimitStrategy>
- </policyEntry>
- </policyEntries>
- </policyMap>
- </destinationPolicy>
- -<!--ThemanagementContextisusedtoconfigurehowActiveMQisexposedin
- JMX.Bydefault,ActiveMQusestheMBeanserverthatisstartedby
- theJVM.Formoreinformation,see:
- http://activemq.apache.org/jmx.html
- -->
- -<managementContext>
- <managementContextcreateConnector="false"/>
- </managementContext>
- -<!--Configuremessagepersistenceforthebroker.Thedefaultpersistence
- mechanismistheKahaDBstore(identifiedbythekahaDBtag).
- Formoreinformation,see:
- http://activemq.apache.org/persistence.html
- -->
- -<persistenceAdapter>
- <kahaDBdirectory="${activemq.data}/kahadb"/>
- </persistenceAdapter>
- -<!--ThesystemUsagecontrolsthemaximumamountofspacethebrokerwill
- usebeforedisablingcachingand/orslowingdownproducers.Formoreinformation,see:
- http://activemq.apache.org/producer-flow-control.html
- -->
- -<systemUsage>
- -<systemUsage>
- -<memoryUsage>
- <memoryUsagepercentOfJvmHeap="70"/>
- </memoryUsage>
- -<storeUsage>
- <storeUsagelimit="100gb"/>
- </storeUsage>
- -<tempUsage>
- <tempUsagelimit="50gb"/>
- </tempUsage>
- </systemUsage>
- </systemUsage>
- -<!--ThetransportconnectorsexposeActiveMQoveragivenprotocolto
- clientsandotherbrokers.Formoreinformation,see:
- http://activemq.apache.org/configuring-transports.html
- -->
- -<transportConnectors>
- -
- <transportConnectorname="openwire"uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
- <transportConnectorname="udp"uri="udp://0.0.0.0:8123"/>
- <transportConnectorname="amqp"uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
- <transportConnectorname="stomp"uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
- <transportConnectorname="mqtt"uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
- <transportConnectorname="ws"uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
- </transportConnectors>
- -
- -<shutdownHooks>
- <beanxmlns="http://www.springframework.org/schema/beans"class="org.apache.activemq.hooks.SpringContextHook"/>
- </shutdownHooks>
- </broker>
- -<!--Enablewebconsoles,RESTandAjaxAPIsanddemos
- Thewebconsolesrequiresbydefaultlogin,youcandisablethisinthejetty.xmlfile
- Takealookat${ACTIVEMQ_HOME}/conf/jetty.xmlformoredetails
- -->
- <importresource="jetty.xml"/>
- </beans>
- -
-
三.创建 web project(j2ee 5.0)

将tomcat blazeds文件夹中的文件覆盖掉 工程SpringFlexMQWebRoot下的文件。
四.Web.xml配置
- <?xmlversion="1.0"encoding="UTF-8"?>
- -<web-appversion="2.5"xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
- -<welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- -<listener>
- <listener-class>flex.messaging.HttpFlexSession</listener-class>
- </listener>
- -<servlet>
- <servlet-name>flex</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- -<init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath*:applicationContext.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- -<servlet-mapping>
- <servlet-name>flex</servlet-name>
- <url-pattern>/messagebroker/*</url-pattern>
- </servlet-mapping>
- -<servlet>
- <servlet-name>MessageBrokerServlet</servlet-name>
- <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
- -<init-param>
- <param-name>services.configuration.file</param-name>
- <param-value>/WEB-INF/flex/services-config.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- -<servlet>
- <servlet-name>ControlServlet1</servlet-name>
- <servlet-class>com.test.jms.servlet.ControlServlet1</servlet-class>
- </servlet>
- -<servlet-mapping>
- <servlet-name>ControlServlet1</servlet-name>
- <url-pattern>/ControlServlet1</url-pattern>
- </servlet-mapping>
- </web-app>
-
SSH整合的时候会注册spring 的ContextLoaderListene,但在这里给去掉了。似乎不是完美,这些问题以后会慢慢解决。
五.工程建好以后可以看到flex文件夹里的四个配置文件,修改配置文件。
1.messaging-config.xml
- <?xmlversion="1.0"encoding="UTF-8"?>
- -<serviceid="message-service"class="flex.messaging.services.MessageService">
- -<adapters>
- <adapter-definitionid="actionscript"class="flex.messaging.services.messaging.adapters.ActionScriptAdapter"default="true"/>
- -
- </adapters>
- -<default-channels>
- <channelref="my-polling-amf"/>
- <channelref="my-streaming-amf"/>
- </default-channels>
- </service>
-
2.proxy-config.xml
- <?xmlversion="1.0"encoding="UTF-8"?>
- -<serviceid="proxy-service"class="flex.messaging.services.HTTPProxyService">
- -<properties>
- -<connection-manager>
- <max-total-connections>100</max-total-connections>
- <default-max-connections-per-host>2</default-max-connections-per-host>
- </connection-manager>
- <allow-lax-ssl>true</allow-lax-ssl>
- </properties>
- -<adapters>
- <adapter-definitionid="http-proxy"class="flex.messaging.services.http.HTTPProxyAdapter"default="true"/>
- <adapter-definitionid="soap-proxy"class="flex.messaging.services.http.SOAPProxyAdapter"/>
- </adapters>
- -<default-channels>
- <channelref="my-amf"/>
- </default-channels>
- <destinationid="DefaultHTTP"/>
- </service>
-
3.remoting-config.xml
- <?xmlversion="1.0"encoding="UTF-8"?>
- -<serviceid="remoting-service"class="flex.messaging.services.RemotingService">
- -<adapters>
- <adapter-definitionid="java-object"class="flex.messaging.services.remoting.adapters.JavaAdapter"default="true"/>
- </adapters>
- -<default-channels>
- <channelref="my-amf"/>
- </default-channels>
- </service>
-
4.services-config.xml
- <?xmlversion="1.0"encoding="UTF-8"?>
- -<services-config>
- -<services>
- <service-includefile-path="remoting-config.xml"/>
- <service-includefile-path="proxy-config.xml"/>
- <service-includefile-path="messaging-config.xml"/>
- </services>
- -<services>
- -<default-channels>
- <channelref="my-amf"/>
- </default-channels>
- </services>
- -<security>
- <login-commandclass="flex.messaging.security.TomcatLoginCommand"server="Tomcat"/>
- -<!--Uncommentthecorrectappserver
- <login-commandclass="flex.messaging.security.TomcatLoginCommand"server="JBoss">
- <login-commandclass="flex.messaging.security.JRunLoginCommand"server="JRun"/>
- <login-commandclass="flex.messaging.security.WeblogicLoginCommand"server="Weblogic"/>
- <login-commandclass="flex.messaging.security.WebSphereLoginCommand"server="WebSphere"/>
- -->
- -<!--
- <security-constraintid="basic-read-access">
- <auth-method>Basic</auth-method>
- <roles>
- <role>guests</role>
- <role>accountants</role>
- <role>employees</role>
- <role>managers</role>
- </roles>
- </security-constraint>
- -->
- </security>
- -<channels>
- -<channel-definitionid="my-amf"class="mx.messaging.channels.AMFChannel">
- <endpointurl="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"class="flex.messaging.endpoints.AMFEndpoint"/>
- </channel-definition>
- -<channel-definitionid="my-secure-amf"class="mx.messaging.channels.SecureAMFChannel">
- <endpointurl="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure"class="flex.messaging.endpoints.SecureAMFEndpoint"/>
- -<properties>
- <add-no-cache-headers>false</add-no-cache-headers>
- </properties>
- </channel-definition>
- -<channel-definitionid="my-polling-amf"class="mx.messaging.channels.AMFChannel">
- <endpointurl="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling"class="flex.messaging.endpoints.AMFEndpoint"/>
- -<properties>
- <polling-enabled>true</polling-enabled>
- <polling-interval-seconds>4</polling-interval-seconds>
- </properties>
- </channel-definition>
- -<channel-definitionid="my-streaming-amf"class="mx.messaging.channels.StreamingAMFChannel">
- <endpointurl="http://{server.name}:{server.port}/{context.root}/messagebroker/streamingamf"class="flex.messaging.endpoints.StreamingAMFEndpoint"/>
- -<properties>
- <idle-timeout-minutes>0</idle-timeout-minutes>
- <max-streaming-clients>100</max-streaming-clients>
- <server-to-client-heartbeat-millis>5000</server-to-client-heartbeat-millis>
- -<user-agent-settings>
- <user-agentmatch-on="MSIE"kickstart-bytes="2048"max-streaming-connections-per-session="100"/>
- <user-agentmatch-on="Firefox"kickstart-bytes="2048"max-streaming-connections-per-session="100"/>
- </user-agent-settings>
- </properties>
- </channel-definition>
- </channels>
- -<logging>
- -<targetclass="flex.messaging.log.ConsoleTarget"level="Error">
- -<properties>
- <prefix>[BlazeDS]</prefix>
- <includeDate>false</includeDate>
- <includeTime>false</includeTime>
- <includeLevel>false</includeLevel>
- <includeCategory>false</includeCategory>
- </properties>
- -<filters>
- <pattern>Endpoint.*</pattern>
- <pattern>Service.*</pattern>
- <pattern>Configuration</pattern>
- </filters>
- </target>
- </logging>
- -<system>
- -<redeploy>
- <enabled>false</enabled>
- </redeploy>
- </system>
- </services-config>
-
六.Spring的配置文件applicationContext.xml
- <?xmlversion="1.0"encoding="UTF-8"?>
- -<beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"xmlns:flex="http://www.springframework.org/schema/flex"xmlns:amq="http://activemq.apache.org/schema/core"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-3.0.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-3.0.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-3.0.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-3.0.xsdhttp://www.springframework.org/schema/flexhttp://www.springframework.org/schema/flex/spring-flex-1.0.xsdhttp://activemq.apache.org/schema/corehttp://activemq.apache.org/schema/core/activemq-core-5.2.0.xsd">
- -
- -<flex:message-brokerid="_messageBroker">
- <flex:message-servicedefault-channels="my-streaming-amf,my-polling-amf"/>
- </flex:message-broker>
- -
- <flex:message-destinationid="market-data-feed"channels="my-streaming-amf,my-polling-amf"allow-subtopics="true"subtopic-separator="."/>
- <beanclass="org.springframework.flex.servlet.MessageBrokerHandlerAdapter"/>
- <beanid="Reciver"class="com.test.jms.util.Receive"/>
- <beanid="Sender"class="com.test.jms.util.Sender"/>
- <flex:remoting-destinationref="Reciver"/>
- <flex:remoting-destinationref="Sender"/>
- </beans>
-
七.Java后台代码
1.Sender.java
- packagecom.test.jms.util;
- importjavax.jms.Connection;
- importjavax.jms.ConnectionFactory;
- importjavax.jms.Destination;
- importjavax.jms.JMSException;
- importjavax.jms.MessageProducer;
- importjavax.jms.Session;
- importorg.apache.activemq.ActiveMQConnection;
- importorg.apache.activemq.ActiveMQConnectionFactory;
- publicclassSender{
- publicvoidsend(Strings){
- try{
- //连接工厂,负责创建Connection
- ConnectionFactoryconnectionFactory=null;
- //负责创建Session
- Connectionconnection=null;
- //创建MessageProducer(用来发消息)和MessageConsumer(用来接收消息)
- Sessionsession=null;
- //消息的目的地
- Destinationdestination=null;
- connectionFactory=newActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_USER,ActiveMQConnection.DEFAULT_PASSWORD,"udp://192.168.1.22:8123");
- connection=connectionFactory.createConnection();
- connection.start();
- session=connection.createSession(Boolean.FALSE,Session.AUTO_ACKNOWLEDGE);
- //创建Topic,名字为myTopic
- destination=session.createTopic("myTopic");
- MessageProducermessage_producer=session.createProducer(destination);
- //通过消息生产者发出消息
- message_producer.send(session.createTextMessage(s));
- }catch(JMSExceptione){
- e.printStackTrace();
- }
- }
- }
2.Receive.java
- packagecom.test.jms.util;
- importjavax.jms.Connection;
- importjavax.jms.ConnectionFactory;
- importjavax.jms.Destination;
- importjavax.jms.JMSException;
- importjavax.jms.Message;
- importjavax.jms.MessageConsumer;
- importjavax.jms.MessageListener;
- importjavax.jms.TextMessage;
- importjavax.jms.Session;
- importflex.messaging.MessageBroker;
- importflex.messaging.messages.AsyncMessage;
- importflex.messaging.messages.AcknowledgeMessage;
- importflex.messaging.messages.CommandMessage;
- importflex.messaging.util.UUIDUtils;
- importorg.apache.activemq.ActiveMQConnection;
- importorg.apache.activemq.ActiveMQConnectionFactory;
- importflex.messaging.endpoints.Endpoint;
- publicclassReceive{
- privatestaticConnectionFactoryconnectionFactory=null;
- privatestaticConnectionconnection=null;
- privatestaticSessionsession=null;
- privatestaticDestinationdestination=null;
- privatestaticMessageConsumermessageConsumer=null;
- publicvoiddoReceive(){
- try{
- connectionFactory=newActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_USER,ActiveMQConnection.DEFAULT_PASSWORD,"udp://192.168.1.22:8123");
- connection=connectionFactory.createConnection();
- connection.start();
- session=connection.createSession(Boolean.FALSE,Session.AUTO_ACKNOWLEDGE);
- destination=session.createTopic("myTopic");
- if(messageConsumer==null){
- messageConsumer=session.createConsumer(destination);
- //重写MessageListener类的onMessage方法
- messageConsumer.setMessageListener(newMessageListener(){
- publicvoidonMessage(Messagemessage){
- try{
- TextMessagetextMessage=(TextMessage)message;
- Stringmsg=null;
- msg=textMessage.getText();
- System.out.println(msg);
- //获取消息代理,此处的参数就是Spring配置文件中配置的messagebroker的id
- MessageBrokermessageBroker=MessageBroker.getMessageBroker("_messageBroker");
- StringclientID=UUIDUtils.createUUID();
- //创建AsyncMessage类的对象是为了Flex端用Messaging模式接收消息
- AsyncMessageasynMsg=newAsyncMessage();
- //设置消息的地址,这个必须跟Spring配置文件中信道的destination一致
- asynMsg.setDestination("market-data-feed");
- //flex可以通过header过滤消息
- asynMsg.setHeader("msg","new");
- asynMsg.setClientId(clientID);
- asynMsg.setMessageId(UUIDUtils.createUUID());
- asynMsg.setTimestamp(System.currentTimeMillis());
- asynMsg.setBody(msg);
- messageBroker.routeMessageToService(asynMsg,null);
- }catch(JMSExceptione){
- e.printStackTrace();
- try{
- connection.close();
- }catch(JMSExceptione1){
- e1.printStackTrace();
- }
- }
- }
- });
- }
- }catch(Exceptione){
- }
- }
- }
3.ControlServlet1.java
- packagecom.test.jms.servlet;
- importjava.io.IOException;
- importjava.io.PrintWriter;
- importjavax.servlet.ServletContext;
- importjavax.servlet.ServletException;
- importjavax.servlet.http.HttpServlet;
- importjavax.servlet.http.HttpServletRequest;
- importjavax.servlet.http.HttpServletResponse;
- importorg.springframework.context.ApplicationContext;
- importorg.springframework.web.context.WebApplicationContext;
- importorg.springframework.web.context.support.WebApplicationContextUtils;
- publicclassControlServlet1extendsHttpServlet{
- publicvoidinit()throwsServletException{
- }
- publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)
- throwsServletException,IOException{
- doPost(request,response);
- }
- publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)
- throwsServletException,IOException{
- }
- }
八.前台Flex的代码
- <?xmlversion="1.0"encoding="utf-8"?>
- <s:Applicationxmlns: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"creationComplete="init();">
- <fx:Script>
- <![CDATA[
- importmx.controls.Alert;
- importmx.messaging.events.MessageEvent;
- importmx.messaging.events.MessageFaultEvent;
- importmx.rpc.events.FaultEvent;
- importmx.messaging.ChannelSet;
- importmx.messaging.channels.AMFChannel;
- importmx.messaging.channels.SecureStreamingAMFChannel;
- importmx.messaging.channels.StreamingAMFChannel;
- protectedfunctioninit():void{
- //调用后台的Receive类中的doReceive方法,实现订阅和监听消息
- ReceiveMessage.doReceive();
- //给我们定义的consumer对象指定一个信道,我们定义了两种信道,在services-config.xml文件中,此处选用my-streaming-amf
- consumer.subscribe();
- }
- //按钮点击触发的操作
- protectedfunctionbtnSendMessage_clickHandler(event:MouseEvent):void
- {
- Send.send(myinput.text);
- myinput.text="";
- }
- //点击按钮后操作失败的处理
- protectedfunctionSend_faultHandler(event:FaultEvent):void
- {
- Alert.show("sendisfail,because:"+event.fault.toString());
- }
- //收到消息的失败处理
- protectedfunctionReceiveMessage_faultHandler(event:FaultEvent):void
- {
- Alert.show("receiveisfail,because:"+event.fault.toString());
- }
- //生产者收到消息的错误处理
- protectedfunctionconsumer_faultHandler(event:MessageFaultEvent):void
- {
- Alert.show("error");
- Alert.show(event.faultString);
- }
- //生产者收到消息后的处理
- protectedfunctionconsumer_messageHandler(event:MessageEvent):void
- {
- txtMessage.text=txtMessage.text+event.message.body.toString()+"\n";
- }
- ]]>
- </fx:Script>
- <fx:Declarations>
- <s:ConsumerchannelSet="{cs}"id="consumer"destination="market-data-feed"fault="consumer_faultHandler(event)"message="consumer_messageHandler(event)"/>
- <s:RemoteObjectid="ReceiveMessage"channelSet="{amf_channel}"destination="Reciver"
- fault="ReceiveMessage_faultHandler(event)"/>
- <s:RemoteObjectid="Send"channelSet="{amf_channel}"destination="Sender"
- fault="Send_faultHandler(event)"/>
- <s:AMFChannelid="myamfChannel"
- url="http://192.168.1.22:8088/SpringFlexMQ/messagebroker/amf"/>
- <mx:ChannelSetid="amf_channel"channels="{[myamfChannel]}"/>
- <s:ChannelSetid="cs">
- <s:StreamingAMFChannelurl="http://192.168.1.22:8088/SpringFlexMQ/messagebroker/streamingamf"/>
- </s:ChannelSet>
- </fx:Declarations>
- <mx:VBoxheight="100%"horizontalAlign="center"width="100%"verticalAlign="middle"chromeColor="#9F9F9F"dropShadowVisible="true"backgroundColor="#6A232F"backgroundAlpha="0.6">
- <mx:VBoxwidth="438"verticalAlign="middle"horizontalAlign="center"paddingBottom="5"paddingTop="5"paddingLeft="5"paddingRight="5"backgroundColor="#87194D"focusColor="#6C1D2A"cornerRadius="10">
- <s:VGrouphorizontalAlign="center"gap="11"paddingBottom="5"paddingTop="5"paddingLeft="5"paddingRight="5"contentBackgroundColor="#EDEDED">
- <mx:TextAreaid="txtMessage"x="62"y="100"width="408"height="249"dropShadowVisible="true"text=""borderColor="#97515D"chromeColor="#F0BABA"contentBackgroundColor="#F2FCFA"/>
- <s:TextInputid="myinput"x="0"y="250"width="408"height="42"contentBackgroundColor="#F4F9F8"borderColor="#8B3B3B"/>
- <mx:Buttonid="btnSendMessage"x="0"y="302"label="Send"click="btnSendMessage_clickHandler(event)"chromeColor="#97D2EB"paddingBottom="0"/>
- </s:VGroup>
- </mx:VBox>
- </mx:VBox>
- </s:Application>
九.启动ActiveMQ

十.启动程序

十一.总结
1.ActiveMQ如何将对象推送到前端,前端又是如何接受对象?
2.Spring如何更有效地管理ActiveMQ?
3. 如何实现订阅的信息筛选?
4. jar包下载地址http://download.csdn.net/detail/allen_gang/6659767