Case study: FIG + spring 13th: JMS chat

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.