`
keren
  • 浏览: 1578255 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

BlazeDS + JMS + ActiveMQ

    博客分类:
  • Flex
阅读更多
http://www.joshuaostrom.com/2008/08/01/tunkey-blazeds-jms-activemq/
I spent some time this week with BlazeDS and JMS. I wanted to integrate a Flex RIA with some [existing] backend Java classes. One goal was to interface the two in a loosely coupled fashion, enter Java Message Service (JMS).

The RIA uses a mx:producer to publish messages to a JMS topic which the backend Java class is listening in on [consuming] elsewhere in the enterprise. I used an ‘external install’ of ActiveMQ.

I downloaded the turnkey BlazeDS server to get things rolling.

I came across a few great posts in looking into this…

【Michael Martin’s Simplified BlazeDS and JMS】
http://mmartinsoftware.blogspot.com/2008/05/simplified-blazeds-and-jms.html

Christophe Coenraets
【Flex and JMS: Portfolio Viewer (LCDS jRun)】
http://coenraets.org/blog/2006/06/flex-and-jms-portfolio-viewer-updated-for-flex-2-ga/
【30 Minutes Flex Test-Drive for Java Developers (FDS)】
http://coenraets.org/blog/30-minutes-flex-test-drive-for-java-developers/

To be helpful, I’ve included some error messages and their causes:

Flex Runtime Error:
There was an unhandled failure on the server. MessageClient has been invalidated.
Cause: ActiveMQ not running.

Flex Runtime Error:
Client.Message.Encoding
Type ‘com.dl.samples.PersonVO’ not found.
Cannot create class of type ‘com.dl.samples.PersonVO’.
Cause: Java classes not on server.

Java Runtime Error
javax.naming.NameNotFoundException: messageTopic
at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:225)
at javax.naming.InitialContext.lookup(Unknown Source)
at Chat.(Chat.java:55)
at Chat.main(Chat.java:27)
Cause: jndi.properties not present for java class

Java Runtime [BlazeDS] Error
[BlazeDS] JMS consumer for JMS destination ‘[destinationName]’ is being removed from the JMS adapter due to the following error: Name jms is not bound in this Context
[BlazeDS] JMS consumer for JMS destination ‘[destinationName]’ is stopping.
[BlazeDS] The corresponding MessageClient for JMS consumer for JMS destination ‘[destinationName]’ is being invalidated

Cause: context.xml Resource names do not match messaging-config.xml connection-factory / destination-jndi-name tags. (i.e. the ‘org.apache.activemq.ActiveMQConnectionFactory’ resource name in context.xml should match the connection-factory value in messaging-config and the ‘org.apache.activemq.command.ActiveMQTopic’ resource name in context.xml should match the destination-jndi-name value in messaging-config).

Adding the logging pattern ‘Service.Message.JMS’ to your services-config.xml can be very helpful in debugging BlazeDS JMS problems.

Here are the config files

C:/blazeds/tomcat/webapps/MyApp/WEB-INF/flex/services-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service-include file-path="messaging-config.xml" />
</services>
<security/>
<channels>
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://localhost:8400/BlazeTest/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>
<logging>
<target class="flex.messaging.log.ConsoleTarget" level="Debug">
<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>
<pattern>Service.Message.JMS</pattern>
</filters>
</target>
</logging>
</services-config>


C:/blazeds/tomcat/webapps/MyApp/WEB-INF/flex/messaging-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service" class="flex.messaging.services.MessageService">
<adapters>
<adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" />
<adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/>
</adapters>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
<destination id="simpleJMS">
<properties>
<jms>
<destination-type>Topic</destination-type>
<!--<message-type>javax.jms.TextMessage</message-type>-->
<message-type>javax.jms.ObjectMessage</message-type>
<connection-factory>java:comp/env/TopicConnectionFactory</connection-factory>
<destination-jndi-name>java:comp/env/messageTopic</destination-jndi-name>
<delivery-mode>NON_PERSISTENT</delivery-mode>
<message-priority>DEFAULT_PRIORITY</message-priority>
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
<initial-context-environment>
<property>
<name>Context.INITIAL_CONTEXT_FACTORY</name>
<value>org.apache.activemq.jndi.ActiveMQInitialContextFactory</value>
</property>
<property>
<name>Context.PROVIDER_URL</name>
<value>tcp://localhost:61616</value>
</property>
</initial-context-environment>
</jms>
</properties>
<channels>
<channel ref="my-amf"/>
</channels>
<adapter ref="jms"/>
</destination>
</service>


C:/blazeds/tomcat/webapps/MyApp/WEB-INF/web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>BlazeDS</display-name>
<description>BlazeDS Application</description>
<!-- Http Flex Session attribute and binding listener support -->
<listener>
<listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
<!-- MessageBroker Servlet -->
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<display-name>MessageBrokerServlet</display-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-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>


C:/blazeds/tomcat/webapps/MyApp/META-INF/context.xml

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/BlazeTest">
<Resource name="TopicConnectionFactory"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp://localhost:61616"
brokerName="myBroker"/>
<Resource name="messageTopic"
type="org.apache.activemq.command.ActiveMQTopic"
description="a simple topic"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="messageTopic"/>
</Context>


Using the above messaging-config’s destination the message will come across as an ObjectMessage in Java.
分享到:
评论

相关推荐

    spring3+ActiveMQ+blazeds+flex consumer

    本项目“spring3+ActiveMQ+blazeds+flex consumer”旨在整合一系列技术,以实现这样的功能。下面将详细阐述这些技术及其整合过程。 首先,Spring框架(Spring3)是Java领域最流行的轻量级应用框架之一,它提供了...

    Flex4.X+BlazeDS+Spring3L实战开发在线书店四

    【标题】"Flex4.X+BlazeDS+Spring3实战开发在线书店四"涉及的核心技术栈是Adobe Flex 4.6、BlazeDS、Spring 3框架以及Java相关的JPA和Hibernate,配合MySQL数据库实现一个在线书店的完整系统。下面将详细阐述这些...

    BlazeDS+Spring+activeMQ outofmemory

    标题 "BlazeDS+Spring+activeMQ outofmemory" 指的是在使用BlazeDS、Spring和ActiveMQ集成的环境中遇到了内存溢出问题。BlazeDS是一个开放源码的服务器端技术,它允许双向通信,使Flex或AJAX客户端能够与Java后端...

    Flex + BlazeDS + Java + JMS 通信实例(附源码)

    BlazeDS还提供了LiveCycle Data Services扩展,其中包括对JMS的支持,使得Flex能够订阅和发布JMS消息。 3. **Java**:在后端,Java通过Spring或其它框架处理业务逻辑,并与JMS服务器进行交互。Java应用通过JMS API...

    Flex4.X+BlazeDS+Spring3L实战开发在线书店二

    在本课程中,我们将深入探讨如何使用Flex 4.6、BlazeDS、Spring 3 和其他相关技术来构建一个实际的在线书店应用。Flex 4.6 是Adobe Flex框架的一个重要版本,它提供了强大的富互联网应用程序(RIA)开发工具,使...

    PureMVC+Flex+BlazeDS+Spring+Hibernate.doc

    标题中的“PureMVC+Flex+BlazeDS+Spring+Hibernate.doc”指的是一项整合了多种技术的Web应用开发方案,这些技术包括PureMVC、Flex、BlazeDS、Spring和Hibernate。这篇文档可能是指导读者如何将这些技术结合在一起...

    flex+blazeds+spring

    标题“flex+blazeds+spring”表明我们要探讨的是如何将Flex前端与BlazeDS中继层和Spring后端框架结合起来,实现完整的数据交互和应用程序逻辑。 在Flex与Spring集成的环境中,Flex作为用户界面展示层,负责与用户...

    Flex4.X+BlazeDS+Spring3L实战开发在线书店三

    《Flex4.X+BlazeDS+Spring3 实战开发在线书店》是一门深入探讨使用Adobe Flex 4.6、BlazeDS、Spring 3框架以及Java相关技术进行Web应用程序开发的课程。这门课程旨在帮助开发者掌握如何构建功能丰富的、交互性强的...

    flex4+blazeDS+spring+ibatis开发教程

    ### Flex4+BlazeDS+Spring+iBatis 开发教程详解 #### 一、富互联网应用(RIA)概念与背景 ##### RIA定义 富互联网应用(Rich Internet Application,简称RIA)是一种新兴的应用程序形式,它结合了客户端与服务器端...

    Myeclipse6.5+flex3+Blazeds+spring+hibernate完美整合

    Myeclipse6.5+flex3+Blazeds+spring+hibernate完美整合,写的非常详细

    Flex4+blazeds+JAVA+JDBC+mysql

    Flex4+BlazeDS+Java+JDBC+MySQL是一个经典的前端与后端交互技术栈,用于构建富互联网应用程序(Rich Internet Applications,RIAs)。在这个架构中,Flex4作为客户端的展示层,BlazeDS作为服务器端的数据通信中间件...

    Flex + blazeds + Java推送

    Flex + blazeds + Java推送Demo 本例实现由Flex一端客户端发送消息, 然后由Java端在发布到所有订阅的其它Flex端. 里面有说明与源码, 还有一个直接放到Tomcat里面的直接发布的项目 小编使用工具 eclipse3.5 flex sdk...

    spring+blazeDS+flex4 例子

    在“spring+blazeDS+flex4 例子”项目中,我们看到一个完整的集成示例。该项目可以直接运行,所有必要的jar包都已包含。首先,我们需要在Spring配置中定义BlazeDS的通道配置和服务接口。然后,在Flex4的MXML或AS3...

    Flex + blazeds + Java入门搭建与简单应用

    《Flex + BlazeDS + Java 入门搭建与简单应用详解》 在当今的Web开发领域,富互联网应用程序(Rich Internet Applications, RIA)已经成为提升用户体验的重要手段。Flex作为Adobe公司推出的RIA开发框架,搭配...

    flex+Spring+Hibernate+Cairngorm+BlazeDS+Spring BlazeDS Integration整合框架

    使用flex 4.5 + Spring 3.0 + Hibernate 3.3 + Cairngorm 2.2.1 + BlazeDS 3.3.0 + Spring BlazeDS Integration 1.0.3整合出的一个登录的小demo·

    Flex+J2EE实例(cairngorm+blazeDS+hibernate+spring)完整版本

    一个 Flex+J2EE实例(cairngorm+blazeDS+hibernate+spring) 本实例为一个 flex 与 java通信项目。前端采用cairngorm框架,后台 采用hibernate+spring 每个部署 步骤,附详细 图文解释。旨在 采用 一种快速开发 ...

    Flex+BlazeDS+Spring+Hibernate

    Flex+BlazeDS+Spring+Hibernate 是一个经典的前端与后端集成方案,广泛应用于构建富互联网应用程序(Rich Internet Applications,RIA)。在这个框架组合中,Flex 作为用户界面层,提供了丰富的交互体验;BlazeDS ...

    Flex+blazeDS+Spring官方Demo,环境搭建

    Flex+blazeDS+Spring官方Demo,环境搭建,内含十几个例子,从易到难,包括spring消息,spring安全,注解方式和非注解配置文件方式,十分好用。内含有tomcat,可直接启动并运行用户手册。

    Flex+BlazeDS+java通信详细笔记和源代码

    Flex+BlazeDS+Java通信是构建富互联网应用程序(RIA)的一种常见技术组合,它允许前端的Flex客户端与后端的Java服务器进行实时双向通信。本文将深入探讨Flex、BlazeDS以及Java之间的通信机制,并提供相关的源代码...

Global site tag (gtag.js) - Google Analytics