【问题标题】:Connectivity to mainframes using JMS使用 JMS 连接到大型机
【发布时间】:2017-10-27 02:56:51
【问题描述】:

我们目前正在使用 WebSphere MQ 从大型机获取数据,并且有时会在 MQ 方面遇到问题。

我想知道是否有办法绕过 MQ 并改用 JMS 从大型机获取数据。我们使用 WebSphere Application Server 6.0.2。

【问题讨论】:

    标签: java jms mainframe


    【解决方案1】:

    抱歉,JMS 只是一个驱动程序接口而不是队列管理器实现。

    JMS 和队列管理器之间的区别与 JDBC 和数据库之间的区别相同。

    安德烈律师事务所

    【讨论】:

      【解决方案2】:

      当然,您可以在 java 端使用 JMS,它最终会包装对 MQ 的调用。您只需要注意邮件标题。 用另一个消息传递基础架构替换 MQ 取决于大型机可以与之通信的内容,因为我想您对此没有太多控制权,对吧?经常选择 MQ 是因为它受到 IBM 大型机系统的支持。

      格雷格

      【讨论】:

        【解决方案3】:

        请找出逻辑,

        1. 我们必须使用 ConnectionFactory、Connection和Session

        2. 我们需要使用队列创建队列引用

        3. 需要为我们计划使用 TextMessage 发送到队列的 Message 创建一个对象

        4. 我们必须创建对象来与队列交互。这里,MessageProducer 用于发送我们在步骤 3 中创建的消息,MessageConsumer 用于接收响应

        请找到下面的代码来实现,

        //Instantiate a Sun Java(tm) System Message Queue ConnectionFactory 
        ConnectionFactory myConnFactory = new com.sun.messaging.ConnectionFactory();
        
        String h = "HOSTNAME";
        String p = "PORTNO";
        
        // Set imqAddressList property
        ((com.sun.messaging.ConnectionFactory)myConnFactory).setProperty(
        com.sun.messaging.ConnectionConfiguration.imqAddressList,
        new StringBuffer().append("mq://").append(h).append(":").append(p).append("/jms").toString());
        
        //Create a connection to the Sun Java(tm) System Message Queue Message Service.
        Connection myConn = myConnFactory.createConnection();
        
        //Start the Connection created in step 3.
        myConn.start();
        
        //Create a session within the connection.
        Session mySess = myConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
        
        //Instantiate a Sun Java(tm) System Message Queue Destination administered object.
        Queue myQueue = new com.sun.messaging.Queue("<MODULENAME>");
        
        //Create a message producer.
        MessageProducer myMsgProducer = mySess.createProducer(myQueue);
        
        //Create and send a message to the queue.
        TextMessage myTextMsg = mySess.createTextMessage();
        myTextMsg.setText("<message>");
        
        System.out.println("Sending Message: " + myTextMsg.getText());
        myMsgProducer.send(myTextMsg);
        
        //Create a message consumer.
        MessageConsumer myMsgConsumer = mySess.createConsumer(myQueue);
        
        //Start the Connection created in step 3.
        myConn.start();
        
        //Receive a message from the queue.
        Message msg = myMsgConsumer.receive();
        
        //Retreive the contents of the message.
        if (msg instanceof TextMessage) {
        TextMessage txtMsg = (TextMessage) msg;
        System.out.println("Read Message: " + txtMsg.getText());
        }
        
        //Close the session and connection resources.
        mySess.close();
        myConn.close();
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2023-03-05
          • 2020-05-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-04-17
          • 1970-01-01
          相关资源
          最近更新 更多