JMS chat
This application is similar to the previous chat program. The difference is that the target name is "JMS-Chat ". On the server side, the target is mapped to a JMS topic.
I. Run the demo:
1. Run the program http: // localhost: 8400/spring-Flex-testdrive/jmschat/index.html.
2. Open another browser, access the same URL, and open another instance of the same program.
3. Enter some messages in a client and click "send". The messages are displayed in the text boxes of the two instances.
4. You can also start the Java (swing) client and run spring-Flex-testdrive/bin/jmschat. bat. This demo demonstrates how to exchange messages between flex and Java programs through the JMS topic.
Ii. Understand the Code:
1. jmschat. mxml:
This program is similar to chat. mxml, but the destination of producer and consumer is different.
<Mx: Producer id = "producer" Destination = "JMS-Chat" channelset = "{CS}"/>
<Mx: Consumer id = "consumer" Destination = "JMS-Chat" channelset = "{CS}" message = "messagehandler (event. Message)"/>
2, flex-servlet.xml:
The message service configurations of JMS-chat are also different. <flex: JMS-message-Destination/> is used to specify the topic on JMS through JMS-destination. The configuration of chattopic is in spring/infrastructure-config.xml.
<Flex: JMS-message-destination ID = "JMS-Chat" JMS-Destination = "chattopic"/>
3. infrastructure-config.xml
The configuration of the chattopic is as follows:
<Bean id = "chattopic" class = "org. Apache. activemq. Command. activemqtopic">
<Constructor-Arg value = "sampletopic. Flex. JMS. Chat"/>
</Bean>
4. jmschat. Java
Another client of this chat program is the source code of the swing-based Java program.
5. activemq
The JMS server used in this demo is Apache activemq. Configure in infrastructure-config.xml:
<Bean id = "connectionfactory" class = "org. Apache. activemq. activemqconnectionfactory">
<Property name = "brokerurl" value = "VM :( broker :( TCP: // localhost: 61616 )? Persistent = false )? Marshal = false "/>
</Bean>
Iii. Summary:
The functions of this program are the same as those of chat demo. This demo focuses on displaying the intercommunication between blazeds and JMS. For more resources related to blazeds and JMS, see the blazeds development document.