IBM Websphere MQ-用于Tomcat部署的EJB和MDB迁移 [英] IBM Websphere MQ - EJB and MDB migration for Tomcat deployment

查看:166
本文介绍了IBM Websphere MQ-用于Tomcat部署的EJB和MDB迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为此苦苦挣扎很长时间了.我有一个使用EJB和MDB的IBM Websphere MQ

I have been struggling with this for a long time now. I have an IBM Websphere MQ, which uses EJB and MDB

以下是配置ejb mdb的位置.

The following is where the ejb mdb is configured.

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
    xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ejb-jar-bnd_1_0.xsd" version="1.0">
  <message-driven name="Queue1MDB">
    <jca-adapter activation-spec-binding-name="jms/Queue1MQActivationSpec" destination-binding-name="jms/Queue1RequestQueue"/>
    <resource-ref binding-name="jms/QueueConnectionFactory" name="jms/QueueConnectionFactory"/>
    <message-destination-ref binding-name="jms/SuccessfulResponseQueue" name="jms/SuccessfulResponseQueue"/>
    <message-destination-ref binding-name="jms/FailedResponseQueue" name="jms/FailedResponseQueue"/>
  </message-driven>

  <message-driven name="Queue2MDB">
    <jca-adapter activation-spec-binding-name="jms/Queue2MQActivationSpec" destination-binding-name="jms/Queue2RequestQueue"/>
    <resource-ref binding-name="jms/QueueConnectionFactory" name="jms/QueueConnectionFactory"/>
    <message-destination-ref binding-name="jms/SuccessfulResponseQueue" name="jms/SuccessfulResponseQueue"/>
    <message-destination-ref binding-name="jms/FailedResponseQueue" name="jms/FailedResponseQueue"/>
  </message-driven>

  <message-driven name="Queue3MDB">
    <jca-adapter activation-spec-binding-name="jms/Queue3MQActivationSpec" destination-binding-name="jms/Queue3RequestQueue"/>
    <resource-ref binding-name="jms/QueueConnectionFactory" name="jms/QueueConnectionFactory"/>
    <message-destination-ref binding-name="jms/SuccessfulResponseQueue" name="jms/SuccessfulResponseQueue"/>
    <message-destination-ref binding-name="jms/FailedResponseQueue" name="jms/FailedResponseQueue"/>
  </message-driven>

  <message-driven name="Queue4MDB">
    <jca-adapter activation-spec-binding-name="jms/Queue4MQActivationSpec" destination-binding-name="jms/Queue4RequestQueue"/>
    <resource-ref binding-name="jms/QueueConnectionFactory" name="jms/QueueConnectionFactory"/>
    <message-destination-ref binding-name="jms/SuccessfulResponseQueue" name="jms/SuccessfulResponseQueue"/>
    <message-destination-ref binding-name="jms/FailedResponseQueue" name="jms/FailedResponseQueue"/>
  </message-driven>
</ejb-jar-bnd>

这是在ear中配置的,已部署在IBM WAS中. destination-binding-name将从IBM WAS中选择​​相应的队列详细信息.

This is configured in ear, which is deployed in IBM WAS. The destination-binding-name will pick the corresponding queue details from the IBM WAS.

然后,在我的java类中配置MDB,如下所示,同时在所有队列上实现侦听并提取消息:

And later, my configuring the MDB in my java class like below, the listening is achieved on all the queues simultaneously and the messages are picked up:

@Resource(name = "jms/QueueContractConnectionFactory")
private ConnectionFactory connectionFactory;

@Resource(name = "jms/FailedResponseQueue")
private Queue errorQueue;

@Resource(name = "jms/SuccessfulResponseQueue")
private Queue responseQueue;

我现在必须删除ejb并修改mdb配置,以使其可在tomcat中部署.

I now have to remove the ejb and modify the mdb configurations to make it deploy-able in tomcat.

xml是某种东西,我真的不知道如何在没有ejb参数的情况下映射它.

The xml is something, which I literally have no idea on how to map it without the ejb parameters.

有人可以帮助或共享有关如何实现此目标的文档吗?我想举一个带有激活规范的IBM MQ到Spring JMS的例子.

Can someone help or share a document on how to achieve this? I would like to have a example of IBM MQ to Spring JMS with Activation Spec.

谢谢.

推荐答案

正如已经提到的,用Tomcat替换WAS并不是简单的问题,因为它们不是同一种容器.因此,您不能直接将WAS工件(尤其是MDB)直接部署到Tomcat中.为了使它们进入Tomcat,必须将它们重写.

As has been commented, it's not simply a matter of replacing WAS with Tomcat, as they are not the same kind of container. So you can not directly deploy your WAS artifacts (the MDBs, notably) directly in to Tomcat. In order to get these in to Tomcat, they will have to be rewritten.

通过成为MDB,容器可以为您管理:连接到JMS服务器,将消息从队列/主题路由到逻辑,多线程消息处理(一次处理多个队列中的消息),以及大多数尤其是交易管理.

By being an MDB, the container manages for you: connecting to the JMS server, routing of messages from the queue/topic to your logic, multi-threaded message processing (handling more than one queued message at once) and, most notably, transaction management.

现在,针对JMS的消息处理非常简单.您可以轻松建立与JMS的连接.您可以从网络上复制示例并使其正常运行.在后台运行处理非常简单,也有示例. JMS 2.0比JMS 1.x更易于使用.没有理由不移植到该端口(除非MQ不支持JMS 2.0).

Now, message processing against JMS is pretty straightforward. You can make a connection to JMS readily. You can copy an example off the net and get that working. Running processing in the background is straightforward, there are examples of that as well. JMS 2.0 is easier to use than JMS 1.x. No reason not to port to that (unless MQ doesn't support JMS 2.0).

以事务方式运行逻辑的多个实例并不是那么简单,但是也许这不是您处理的敏锐方面.

Running multiple instances of the logic, transactionally, is not so straightforward, but maybe that's not a keen aspect of your processing.

但是,即使您能够完成所有工作,目前也无法保证您的逻辑将直接起作用.我们不知道您是否逻辑调用其他EJB或利用其他Java EE基础结构.如果这样做,他们还必须移植逻辑的这一方面,而不仅仅是MDB连接.

However, even if you were able to get all of that working, there's no guarantee at this juncture that your logic will work directly. We don't know if you logic calls other EJBs or leverages any of the other Java EE infrastructure. Were it to do so, them you have to port that aspect of your logic as well, not just the MDB connectivity.

因此,这是一个更深层次的问题.说只在Tomcat中部署它"很容易,但是可能有一些细节使它脱轨,需要加以考虑.

So, this is a deeper problem. It's easy to say "just deploy it in Tomcat", but there could be details that derail that and need to be accounted for.

另一种方法是将逻辑转换为Spring,因为它可以轻松地部署在Tomcat中.但这并不一定比其他任何事情都要简单-所有警告仍然存在.

Another take is to convert the logic to Spring, as that can deploy in Tomcat readily. But that's not necessarily simpler than anything else -- all of the caveats remain.

最后,在这种情况下,部署Tomcat"几乎是不言而喻的,因为MDB不是Web Apps,并且Tomcat部署了Web Apps.您可以创建Web应用程序的外壳,该外壳除了容纳消息驱动的逻辑外什么也不做.这很容易做到,我和许多其他人已经将Web App的生命周期滥用到了我们自己对此类事情的恶毒目的.

Finally, "deploying in Tomcat" is almost a non-sequitur in this case because MDBs are not Web Apps, and Tomcat deploys Web Apps. You can create a shell of a Web App that does nothing but house your message driven logic. It's easy to do, I and many others have abused the Web App life cycles to our own nefarious ends for things like this.

因此,最后,我认为您需要更清楚地了解"Tomcat中的部署"的真正含义,最终的期望以及消息逻辑是否依赖于其他Java EE基础结构等.目标是可以在Tomcat中运行,也可以不在WAS中运行(在这种情况下,如注释中所述,您可能会使用其他应用服务器,这些服务器将更容易过渡到该服务器).

So, in the end, I think you need more clarity as to what "deploy in Tomcat" really means, what the expectations are in the end, and whether your message logic relies on other Java EE infrastructure etc. Is the goal to run in Tomcat or to not run in WAS (in that case, as noted in the comments, there are other app servers you could possibly use that would be much easier to transition to).

这篇关于IBM Websphere MQ-用于Tomcat部署的EJB和MDB迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆