JMS 传输与 MQ 传输

发布于 2024-09-12 18:49:00 字数 139 浏览 6 评论 0原文

我使用 Oracle Service Bus(OSB) 作为 MOM,目标 URI 是 IBM MQ 队列。我只是想知道哪种交通是首选。 OSB 为同一个适配器提供了 2 个适配器:JMS 适配器和用于传输的 MQ 适配器。有谁知道相同的优点和缺点是什么。 TIA

I am using Oracle Service Bus(OSB) as the MOM, and the destination URI is a IBM MQ queue. I just want to know which would be the preferred transport. OSB provides 2 adapters for the same, JMS adapter and MQ adapter for transport. Does any one knows what are the PROS and CONS of the same. TIA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

傻比既视感 2024-09-19 18:49:00

通常,通过本机 MQI 接口发送消息比使用 JMS 更快。实际上,我怀疑您是否会看到真正的差异,除非您每天发送大量消息。然而,除了速度之外,还有其他事情需要考虑。例如,如果您不熟悉 MQI 应用程序,那么学习曲线将比 JMS 更陡峭。

当通过 MQ 发送到另一个 JMS 目标时,JMS 标头信息会映射到 MQRFH2 标头。 MQRFH2 标头的包含是由您创建的 Destination 对象驱动的。如果目标是 JMS 端点,则包含标头。

我在下面添加了一个链接,解释了如何映射字段:

  1. 将 JMS 消息映射到 MQI 消息。

实际上,除非您每天发送数百万条消息,否则我认为 WebsphereMQ 上的 JMS 性能足以满足您的需求。至于请求回复中的线程阻塞,我认为您不需要担心这一点。默认情况下,WebsphereMQ 中的回复由单独的线程而不是请求线程使用。

Typically, sending messages via the native MQI interface will be faster than using JMS. In reality I doubt you will see a real difference, unless you are sending tons of messages per day. However, there are other things to consider than just speed. For example, if you are not familiar with MQI applications the learning curve will be steeper than JMS.

JMS header information is mapped to an MQRFH2 header when sent to another JMS destination via MQ. The inclusion of a MQRFH2 header is driven off of the Destination object you create. If the destination is a JMS endpoint then the header is included.

I have included a link below that explains how the fields are mapped:

  1. Mapping JMS messages onto MQI messages.

In reality, unless you are sending millions of messages a day I would assume that the performance of JMS on WebsphereMQ will be more than adequate for your needs. As far as thread blocking goes in request reply I don't think you need to worry about this. By default the reply in WebsphereMQ is consumed by a seperate thread, not the requesting thread.

壹場煙雨 2024-09-19 18:49:00

只是想添加我发现对我有用的内容。创建队列实例时,您必须执行以下操作。

Queue queue = queueSession.createQueue("queue:///" + queueName + "?targetClient=1");
//Send w/o MQRFH2 header (i.e. receiver is not a JMS client but just MQ)

包含“?targetClient=1”会导致发送带有 oa 标头的原始消息。

希望这对某人有帮助。标记

Just wanted to add what I found that worked for me. You have to do the following when you create your Queue instance.

Queue queue = queueSession.createQueue("queue:///" + queueName + "?targetClient=1");
//Send w/o MQRFH2 header (i.e. receiver is not a JMS client but just MQ)

The inclusion of the "?targetClient=1" causes the raw message to be sent w/o a header.

Hope this helps someone. Mark

脱离于你 2024-09-19 18:49:00

这取决于 MQ 队列另一端的程序是否期望 JMS 或“本机”MQ 消息。

MQ 可以充当本机队列机制或 JMS 消息的传输。区别在于 JMS 消息在消息缓冲区的开头有一些标准标头字段,而“本机”mq 消息仅包含程序发送到缓冲区的数据。

It depends on whther the program at the other end of the MQ queue is expecting a JMS or "native" MQ message.

MQ can act as a native queue mechanism or a transport for JMS messages. The difference being that JMS messages have some standard header fields at the begining of the message buffer and "native" mq messages contain just the data your program sent to the buffer.

绻影浮沉 2024-09-19 18:49:00

性能并不是从 JMS 客户端向 MQ 服务器发送不带 JMS 标头的纯消息(MQ 格式)的唯一原因。消息使用者也可能是非 JMS 客户端,例如 Tivoli Workload Scheduler (TWS) 和 .net。

我提出了一种针对 Java 独立客户端的解决方案和针对 jboss 的解决方案,从 JMS 消息中删除 MQRFH2 格式并将其转换为纯消息:

独立 JMS 客户端

import com.ibm.msg.client.wmq.WMQConstants;
import com.ibm.mq.jms.MQQueue;

Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://...);

InitialContext context = new InitialContext(env);

ConnectionFactory connectionFactory = (ConnectionFactory)   context.lookup(JNDI_QUEUE_CONNECTION_FACTORY);

//the following to extra lines make sure that you send 'MQ' messages
MQQueue mqQueue = (MQQueue) iniCtx.lookup(queueJNDI);
mqQueue.setTargetClient(WMQConstants.WMQ_CLIENT_NONJMS_MQ);

Destination destination = (Destination) mqQueue;
...proceed as usual...

应用程序服务器 JBoss 7 资源适配器< /强>

<subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">
<resource-adapters>
<resource-adapter>
    <archive>wmq.jmsra.rar</archive>
    <transaction-support>NoTransaction</transaction-support>
    <connection-definitions>
        <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/jms/MqConnectionFactory" pool-name="MqConnectionFactoryPool">
            <config-property name="connectionNameList">${mqserver}</config-property>
            <config-property name="channel">${mqchannel}</config-property>
        </connection-definition>
    </connection-definitions>
    <admin-objects>
        <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/MyQueue" pool-name="MyQueuePool">
        <config-property name="baseQueueName">${queuename}</config-property>
        <config-property name="targetClient">MQ</config-property>
    </admin-object>
 </admin-objects>

Performance is not the only reason to send plain messages (MQ format) without the JMS Headers from JMS Client to MQ Server. It can also be that the message consumer is a non JMS client, such as Tivoli Workload Scheduler (TWS) and .net.

I present a solution for a Java standalone client and one for jboss as that remove the MQRFH2 format from the JMS message and turn it into plain message:

Standalone JMS client

import com.ibm.msg.client.wmq.WMQConstants;
import com.ibm.mq.jms.MQQueue;

Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://...);

InitialContext context = new InitialContext(env);

ConnectionFactory connectionFactory = (ConnectionFactory)   context.lookup(JNDI_QUEUE_CONNECTION_FACTORY);

//the following to extra lines make sure that you send 'MQ' messages
MQQueue mqQueue = (MQQueue) iniCtx.lookup(queueJNDI);
mqQueue.setTargetClient(WMQConstants.WMQ_CLIENT_NONJMS_MQ);

Destination destination = (Destination) mqQueue;
...proceed as usual...

Application Server JBoss 7 resource adapter

<subsystem xmlns="urn:jboss:domain:resource-adapters:1.0">
<resource-adapters>
<resource-adapter>
    <archive>wmq.jmsra.rar</archive>
    <transaction-support>NoTransaction</transaction-support>
    <connection-definitions>
        <connection-definition class-name="com.ibm.mq.connector.outbound.ManagedConnectionFactoryImpl" jndi-name="java:jboss/jms/MqConnectionFactory" pool-name="MqConnectionFactoryPool">
            <config-property name="connectionNameList">${mqserver}</config-property>
            <config-property name="channel">${mqchannel}</config-property>
        </connection-definition>
    </connection-definitions>
    <admin-objects>
        <admin-object class-name="com.ibm.mq.connector.outbound.MQQueueProxy" jndi-name="java:jboss/jms/MyQueue" pool-name="MyQueuePool">
        <config-property name="baseQueueName">${queuename}</config-property>
        <config-property name="targetClient">MQ</config-property>
    </admin-object>
 </admin-objects>

别把无礼当个性 2024-09-19 18:49:00

根据丰富的个人经验,如果可能的话,我强烈建议使用 Native MQ

JMS 传输缺点(使用 WMQ 时)-

  1. JMS 中的消息速率较慢(我已经测量过!)
  2. 使用“.bindings”文件(充当 JNDI 服务器)是很麻烦,因为它只能使用 WMQ Explorer(或可怕的 JMSAdmin cmd 工具)进行编辑
  3. 它需要 WMQ 和 Weblogic 方面的高级知识
  4. 每次配置更改都需要重新启动 OSB 域

唯一主要的专业 JMS 传输超过本机 MQ就是它对XA事务的支持。此问题已在 OSB 11.1.1.7 中得到解决,现在两种传输都支持 XA。

本机 MQ 优点 -

  1. 更快的
  2. OSB 可以直接访问 MQ 标头(这太棒了!)
  3. 可以在运行时配置本机 MQ 传输(使用 sbconsole)
  4. 轻松管理连接池

再次,我强烈建议使用 <尽可能使用 OSB 传输本机 MQ。

From an abundance of personal experience, I strongly recommend using Native MQ if possible.

JMS Transport cons (when using WMQ) -

  1. Slower message rates in JMS (I have measured!)
  2. Use of ".bindings" file (which acts as your JNDI server) is cumbersome as it can only be editted using the WMQ Explorer (or the horrible JMSAdmin cmd tool)
  3. It requires advanced knowledge in both WMQ and Weblogic
  4. It requires restart of your OSB Domain for every change of configuration

The only major pro JMS Transport had over native MQ is its support of XA transaction. This has been resoled in OSB 11.1.1.7 and now both transports support XA.

Native MQ Pros -

  1. faster
  2. OSB has direct access to MQ Headers (this is great!)
  3. Native MQ transport can be configured during runtime (using sbconsole)
  4. easy management of connection pool

Again, I strongly recommend use of Native MQ Transport in OSB whenever possible.

婴鹅 2024-09-19 18:49:00

对于其他可能在这里查看的人来说,我的 2c 是截至 2017 年的一点更新视图:

  • 本机 MQ 库 自版本 8.0 起处于“稳定”状态,因此不会添加任何新功能即将推出的版本,只会有错误/安全修复。例如,他们声称异步消耗和自动重新连接在非 JMS 库中不可用。

更多信息请参见此处 选择API

自 v8 以来的一般声明是新应用程序应该使用 IBM MQ 类进行 JMS。当然,这并不意味着 selotape 提到的所有优点和缺点都无效。您仍然需要更多配置,开箱即用的性能可能会较差。实际上,有一个针对 v8 的 MP0E 文档,声称他们已将 Java JMS MQ 应用程序与 C++ MQI 应用程序进行了比较,根据情况,前者速度慢了 35%(所以如果您得到的是 50 与 900,那么您正在做有问题

Just my 2c for everybody else that might be looking here, a bit updated view as of 2017:

  • Native MQ libraries are in "stabilized" state as of version 8.0, therefore there will be no new features added in the upcoming versions, there will be just bug/security fixes. For example they claim that asynchronous consume and automatic reconnection is not available in non JMS libraries.

More info here Choice of API

General statement since v8 is that new applications should use IBM MQ classes for JMS. This of course does not invalidate all the pros and cons mentioned by selotape. You still need some more configuration and performance may be inferior out of the box. Actually there is a MP0E document for v8 that claims that they've compared Java JMS MQ App with C++ MQI app and the former was up to 35% slower depending on scenario (so if you are getting 50 vs 900 you are doing something wrong)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文