Migrating IBM MQ to javax.jms.* implementation - How does MQOPEN translate to JMS API?

自闭症网瘾萝莉.ら 提交于 2020-01-25 01:55:45

问题


How do you get the same effect as ibm's proprietary mq api's openOptions when using MQ with JMS api?

Is there even a concept of openOptions in the JMS API? If so, what is the equivilent in terms of the API classes/methods?

Related stackoverflow question - migrating-from-ibm-mq-to-javax-jms-weblogic


回答1:


You are comparing apples and oranges. Yes, both are fruit but they are completely different fruit. There is no direct comparison between the 2.

1) A JMS session with "transacted" and "createSender" is basically an open output with syncpoint. i.e.

// Open Options
int oo = MQC.MQOO_OUTPUT + MQC.MQOO_INQUIRE + MQC.MQOO_FAIL_IF_QUIESCING;
// Put Msg Options
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = MQC.MQPMO_SYNCPOINT + MQC.MQPMO_FAIL_IF_QUIESCING;

2) A JMS session with "createReceiver" (non-transacted) is basically an open input. i.e.

int oo = MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_INQUIRE + MQC.MQOO_FAIL_IF_QUIESCING;
// Get Msg Options
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_FAIL_IF_QUIESCING;



回答2:


This simple example shows to how to send a Message (using JBoss MQ):

    final Properties initialContextProperties = new Properties();
    initialContextProperties.put("java.naming.factory.initial",
            "org.jnp.interfaces.NamingContextFactory");
    initialContextProperties.put("java.naming.provider.url",
            "jnp://localhost:1099");

    //

    final InitialContext ic = new InitialContext(initialContextProperties);

    final QueueConnectionFactory qcf = (QueueConnectionFactory) ic
            .lookup("XAConnectionFactory");

    final Queue queue = (Queue) ic.lookup("queue/A");

    //

    final QueueConnection queueConnection = qcf.createQueueConnection();

    final boolean transacted = false;
    final QueueSession queueSession = queueConnection.createQueueSession(
            transacted, Session.AUTO_ACKNOWLEDGE);

    final QueueSender queueSender = queueSession.createSender(queue);

    final TextMessage textMessage = queueSession.createTextMessage("Hello");
    queueSender.send(textMessage);

so there are different options on different stages/levels:

  • You normally need to have some properties for the JNDI lookup (to get the InitialContext).
  • You have to lookup the factory and the queue by name using JNDI.
  • There are some settings when you create the QueueSession: transacted, acknowledge.
  • The usage is specified when you call createSender, createReceiver, createBrowser on the QueueSession instance.


来源:https://stackoverflow.com/questions/17436575/migrating-ibm-mq-to-javax-jms-implementation-how-does-mqopen-translate-to-jm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!