- 浏览: 459211 次
- 性别:
- 来自: 陕西.西安
文章分类
最新评论
-
gaodadawei:
登录失败,请重试楼主,我目前遇到这样一个错误,claros i ...
James+Claros+intouch2.1配置 -
VerRan:
qq346448412 写道请问。你上一节、 用的ORACLE ...
James+Claros+intouch2.1配置 -
qq346448412:
请问。你上一节、 用的ORACLE数据库、 这一节又用的是MY ...
James+Claros+intouch2.1配置 -
paladin1988:
good,我喜欢..
Hibernate自关联关系 -
lygxy12:
请问,能给163发邮件吗?该怎么配置?我安装上面的操作,发给1 ...
James+Claros+intouch2.1配置
What Is a Message-Driven Bean?
A message-driven bean is an enterprise bean that allows J2EE applications to process messages asynchronously. It normally acts as a JMS message listener, which is similar to an event listener except that it receives JMS messages instead of events. The messages can be sent by any J2EE component--an application client, another enterprise bean, or a web component--or by a JMS application or system that does not use J2EE technology. Message-driven beans can process either JMS messages or other kinds of messages.
For a simple code sample, see Chapter 28. For more information about using message-driven beans, see Using the JMS API in a J2EE Application and Chapter 34.
What Makes Message-Driven Beans Different from Session and Entity Beans?
The most visible difference between message-driven beans and session and entity beans is that clients do not access message-driven beans through interfaces. Interfaces are described in the section Defining Client Access with Interfaces. Unlike a session or entity bean, a message-driven bean has only a bean class.
In several respects, a message-driven bean resembles a stateless session bean.
- A message-driven bean's instances retain no data or conversational state for a specific client.
- All instances of a message-driven bean are equivalent, allowing the EJB container to assign a message to any message-driven bean instance. The container can pool these instances to allow streams of messages to be processed concurrently.
- A single message-driven bean can process messages from multiple clients.
The instance variables of the message-driven bean instance can contain some state across the handling of client messages--for example, a JMS API connection, an open database connection, or an object reference to an enterprise bean object.
Client components do not locate message-driven beans and invoke methods directly on them. Instead, a client accesses a message-driven bean through JMS by sending messages to the message destination for which the message-driven bean class is the
MessageListener
. You assign a message-driven bean's destination during deployment by using Application Server resources.Message-driven beans have the following characteristics:
When a message arrives, the container calls the message-driven bean's
onMessage
method to process the message. TheonMessage
method normally casts the message to one of the five JMS message types and handles it in accordance with the application's business logic. TheonMessage
method can call helper methods, or it can invoke a session or entity bean to process the information in the message or to store it in a database.A message can be delivered to a message-driven bean within a transaction context, so all operations within the
onMessage
method are part of a single transaction. If message processing is rolled back, the message will be redelivered. For more information, see Chapter 28.When to Use Message-Driven Beans
Session beans and entity beans allow you to send JMS messages and to receive them synchronously, but not asynchronously. To avoid tying up server resources, you may prefer not to use blocking synchronous receives in a server-side component. To receive messages asynchronously, use a message-driven bean.
评论
design your enterprise beans as single-threaded components and never need to
worry about thread synchronization when concurrent clients access your
component. In order to service concurrent client requests, your EJB container
automatically instantiates multiple instances of your component.
The container’s thread services can be both a benefit and a restriction. The
benefit is that you don’t need to worry about race conditions or deadlock in
your application code. The restriction is that some problems lend themselves
well to multithreaded programming, and that class of problems cannot be
easily solved in an EJB environment.
So why doesn’t the EJB specification allow for multithreaded beans? EJB is
intended to relieve the component developers’ worry about threads or thread
synchronization. The EJB container handles those issues for you by load
balancing client requests to multiple instances of a single-threaded component.
An EJB server provides a highly scalable environment for single-threaded
components.
If the EJB specification allowed for beans to control threads, a Pandora’s box
of problems would result. For example, an EJB container would have a very
hard time controlling transactions if beans were randomly starting and
stopping threads, especially because transaction information is often
associated with a thread.
The bottom line is that EJB was not meant to be a Swiss army knife, solving
every problem in existence. It was designed to assist with server-side business
problems, which are largely single-threaded. For applications that absolutely
must be multithreaded, EJB may not be the correct choice of distributed object
architectures.
发表评论
-
springboot学习 - hello world
2017-03-15 18:15 492引子: 开始之前允许我介绍下我认识的spr ... -
Ext显示乱码问题
2012-04-03 13:27 1149转自:http://blog.csdn.net/raren/a ... -
Hadoop学习资料
2011-10-21 10:20 841http://www.cnblogs.com/wayne101 ... -
NodeJs和 mongodb初识
2011-10-20 14:41 1049NodeJS: 提供javascirpt 实现服务器端功能的引 ... -
WebService 非阻塞模式
2011-03-30 16:05 1681package com.datastruct.sort; ... -
利用 Java dump 进行 JVM 故障诊断
2011-01-11 15:58 1448转自:http://jimmyleeee.blog.163.c ... -
LocalTransactionContainment 期间回滚了一个或多个本地事务资源。
2011-01-09 10:29 1960此问题查过很多,但是大家解决方法不一。下面列出 YuLiMin ... -
RETE 算法的描述(转)
2010-07-20 16:57 1278转自:http://www.cnblogs.com/ipoin ... -
Hermes配置
2010-02-02 18:09 1123一直报错UnmarshalException 后来发现 ... -
界面原型设计工具–Balsamiq Mockups
2009-12-09 13:31 1763原文地址:http://www.pbdigg.net/s ... -
JTA 事务使用
2009-11-23 15:20 1555业务场景: 客户下发订单后,订单到竣工需要走三个岗位1,2, ... -
webSphere 下消息驱动Bean 与队列JNDI的关联
2009-09-21 17:44 14591. 消息驱动Bean配置ejb-jar.xml ... -
Hibernate 二级缓存
2008-07-15 10:17 3261Hibernate二级缓存 1. HIbernate.cfg ... -
webService-小记
2008-03-24 18:57 1036A web service has one or more p ... -
Hessian
2008-02-16 11:16 1518Hessian is a simple binary pro ... -
利用反射机制动态将XML信息设置入对象
2007-12-05 14:23 2278引言:XML和J2EE密切的程度是不用说的了,由于我们的接口程 ... -
Action – JSP – Javascript之间的参数传递
2007-11-19 19:04 3630Action – JSP – Javascript之间的参数传 ... -
java 获取存储过程 输出参数
2007-11-13 15:21 5229connection = session.c ... -
js获得<table>的单元格信息
2007-11-08 16:41 54401. 获取表格中的某个单元格的内容 var tid= ... -
Eclipse快捷键
2007-10-23 10:47 912作用域 功能 快捷键 全 ...
相关推荐
基于java的开发源码-Message-Driven Bean EJB实例源代码.zip 基于java的开发源码-Message-Driven Bean EJB实例源代码.zip 基于java的开发源码-Message-Driven Bean EJB实例源代码.zip 基于java的开发源码-Message-...
- 使用`@MessageDriven`注解标记该类,指定JMS目的地类型(队列或主题),以及其他配置属性。 - 在ejb-jar.xml或元数据注解中配置MDB,如JNDI名称、消息驱动适配器等。 6. **源代码解析**: 压缩包中的源代码...
2. **编写MDB类**:MDB类需要实现`javax.ejb.MessageDrivenBean`接口或者继承`javax.jms.MessageListener`接口,并标注`@MessageDriven`注解。这个注解包含了JMS目的地的配置信息,如目的地类型、激活配置等。 3. *...
"基于Java的实例开发源码-Message-Driven Bean EJB实例源代码.zip" 这个标题揭示了本次讨论的核心内容,即一个关于Java编程的实例项目,特别是涉及了Java企业版(Java EE)中的Message-Driven Bean(MDB)组件。...
Java Message-Driven Bean(MDB)是企业级Java(EJB)技术的一部分,它主要用于处理Java消息服务(JMS)中的消息。在Java EE环境中,MDBs是无状态的bean,它们作为后台服务运行,监听消息队列或主题,并对到来的消息...
- 使用`@MessageDriven`注解来声明bean是一个MDB,并指定JMS配置,如目的地类型(队列或主题)、消息驱动适配器等。 - 可以通过`@ActivationConfigProperty`注解进一步配置MDB的行为,例如设置消息选择器、最大...
Java中的Message-Driven Bean (MDB) 是Enterprise JavaBeans (EJB) 规范的一部分,用于处理JMS(Java Message Service)消息。这个压缩包“基于Java的源码-Message-Driven Bean EJB实例源代码.zip”显然包含了实现...
在EJB项目中,我们需要在ejb-jar.xml或@MessageDriven注解中配置MDB的相关属性,如消息监听接口、JMS目的地类型(队列或主题)、JNDI名称等。 **4. MDB的源码分析** 在提供的源码中,我们可能会看到以下关键组件: ...
7. **部署**:在EJB 3.1及更高版本中,MDB的部署变得更加简单,可以使用注解(如`@MessageDriven`)来代替XML配置,进一步简化了开发过程。 在这个源代码实例中,你可能会看到以下几个关键部分: 1. **MDB类**:...
### Message-Driven Bean (MDB) 培训知识点解析 #### 一、Java消息服务(JMS) **1.1 Java消息服务概念** Java消息服务(Java Message Service,简称JMS)是一种面向消息中间件的标准API,它使得Java应用程序能够...
1. **MDB类定义**:MDB类需要实现 javax.jms.MessageListener 接口,并且通常会带有 @MessageDriven 注解。例如: ```java import javax.ejb.MessageDriven; import javax.jms.MessageListener; import javax.jms....
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,...
在Spring MVC框架中,`mvc:annotation-driven`和`mvc:message-converters`是两个非常重要的元素,它们在处理基于注解的控制器和数据转换方面起着关键作用。本篇文章将深入探讨这两个组件的工作原理以及如何在实际...
@MessageDriven(activationConfig={ @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"), @ActivationConfigProperty(propertyName="destination", propertyValue=...
- Session Bean和Message-Driven Bean的事务处理通常采用CMT(Container-Managed Transactions),而Entity Bean可以采用BMT或CMP。 7. 事务处理属性: - EJB的事务属性包括Supports、Should、NotSupported、...
EJB3图文教程之开发Message Driven Bean