JBoss 5.1.0 + EJB 3.1 +联合管理系统
有人可以建议我在 jboss 中需要做什么来部署消息驱动 bean。特别是我正在寻找以下问题的答案:
- 我是否需要在配置文件中定义 jms 主题、连接工厂等,如果是的话,在哪里以及如何
- 我将在哪里指定远程 JMS 服务器的 url
确实有任何有用的链接或代码片段感谢
更新#1:也许我解释得不太好,我的澄清是关于架构的。我有部署在单独机器上的外部 JMS 服务器,我想创建 EJB3 MDR Bean 来接收来自特定 topc 的消息。我知道主机、端口、用户名和密码等所有属性,并且能够通过 JMS api 发送和接收消息。我想做的是在 jboss 之上正确创建和配置 MDR Bean,但我不确定将所有这些配置(如主机、端口、用户名、密码等)放在哪里......
Can somebody advice me what I need to do in jboss to deploy message driven bean. In particular I am looking answers on following questions:
- Do I need to define jms topic, connection factory etc... in config files, if yes where and how
- Where I will specify a url to remote JMS server
Any helpful links or code snippets really appreciated
UPDATE#1: Maybe I explained myself not very well, my clarification is about architecture. I have external JMS server which is deployed on separate machine and I want to create EJB3 MDR Bean to receive messages from particular topc. I know all properties like host, port, username and password, and I am able to send and receive messages via JMS api. What I want to do is to create and configure properly MDR Bean on top of jboss, but I am not sure where to put all these configuration like host, port, username, password etc...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的消息驱动 Bean 本身将使用符合标准 EJB 规范的部署描述符或 MDB 本身上的注释部署到容器中。
以下是来自 JBoss 社区 Wiki 的示例。它有点复杂,因为它有很多额外的东西,包括事务支持、会话 bean 注入等。但它演示了如何从注释创建 EJB3 MDB。也许值得尝试一下,看看可以省略什么。您可能还需要稍微玩一下它才能让它工作(例如您可能没有 IMySessionBean 的 bean - 所以也许您将完全摆脱它并用 println() 或其他东西来代替它 对于您的消息生产者,
如果其独立的 java 应用程序,则在创建 ConnectionFactory 时将通过提供给 JNDI InitialContext 的属性提供 url 等。这个 示例 对此进行了演示。
如果您在容器中,请参阅上面的第一个示例还提供了使用 JMSXA 连接工厂(特定于容器的特殊连接工厂,具有与 JCA 连接池等相关的附加功能)的示例。
Your Message Driven Bean itself will be deployed into the container using a standard EJB Spec compliant deployment descriptor or annotations on the MDB itself.
Here is an example from the JBoss Community Wiki. Its a little complex as it has a bunch of extra things in it including transaction support, injection of session beans, etc. But it demonstrates how to create an EJB3 MDB from annotations. It may be worth playing with just to see what you can omit. You may also need to play with it a bit just to get it to work(for instance you may not have a bean for IMySessionBean - so perhaps you will just get rid of this entirely and replace with a println() or something to get yourself started)
As for your message producer If its standalone java app the url's etc. will be supplied through the properties supplied to your JNDI InitialContext when creating your ConnectionFactory. This is demonstrated in this example
If you are in the container, refer to the first example above which also provides an example using the JMSXA connection factory(a special connection factory specific to the container that has addtional features related to JCA- connection pooling, etc.).