ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Native MQ in java

Post new topic  Reply to topic
 Native MQ in java « View previous topic :: View next topic » 
Author Message
Gideon
PostPosted: Fri Mar 15, 2013 11:43 am    Post subject: Native MQ in java Reply with quote

Chevalier

Joined: 18 Aug 2009
Posts: 403

I am not a programmer, but need to build a native PTP code, eventually with a MQ TX MGr (I am assuming the MQ native allows TX use, but not the MQ JMS)

From this site:


http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=%2Fcom.ibm.mq.csqzaw.doc%2Fuj11050_.htm
I got hte following code:

Code:
// ===========================================================================
//
// Licensed Materials - Property of IBM
//
// 5724-H27, 5655-L82, 5724-L26
//
// (c) Copyright IBM Corp. 1995,2002,2005
//
// ===========================================================================
// WebSphere MQ classes for Java sample application
//
// This sample runs as a Java Application using the command :- java MQSample
//
// @(#) javabase/samples/MQSample.java, java, j000 1.8 04/12/03 10:59:49

import com.ibm.mq.*;            // Include the WebSphere MQ classes for Java package


public class MQSample
{
  private String qManager = "your_Q_manager";  // define name of queue
                                               // manager to connect to.
  private MQQueueManager qMgr;                 // define a queue manager
                                               // object
  public static void main(String args[]) {
     new MQSample();
  }

  public MQSample() {
   try {

      // Create a connection to the queue manager

      qMgr = new MQQueueManager(qManager);

      // Set up the options on the queue we wish to open...
      // Note. All WebSphere MQ Options are prefixed with MQC in Java.

      int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
                        MQC.MQOO_OUTPUT ;

      // Now specify the queue that we wish to open,
      // and the open options...

      MQQueue system_default_local_queue =
              qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",
                               openOptions);

      // Define a simple WebSphere MQ message, and write some text in UTF format..

      MQMessage hello_world = new MQMessage();
      hello_world.writeUTF("Hello World!");

      // specify the message options...

      MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the // defaults,
                                                           // same as MQPMO_DEFAULT

      // put the message on the queue

      system_default_local_queue.put(hello_world,pmo);

      // get the message back again...
      // First define a WebSphere MQ message buffer to receive the message into..

      MQMessage retrievedMessage = new MQMessage();
      retrievedMessage.messageId = hello_world.messageId;

      // Set the get message options...

      MQGetMessageOptions gmo = new MQGetMessageOptions(); // accept the defaults
                                                           // same as  MQGMO_DEFAULT
      // get the message off the queue...

      system_default_local_queue.get(retrievedMessage, gmo);

      // And prove we have the message by displaying the UTF message text

      String msgText = retrievedMessage.readUTF();
      System.out.println("The message is: " + msgText);
      // Close the queue...
      system_default_local_queue.close();
      // Disconnect from the queue manager

      qMgr.disconnect();
    }
      // If an error has occurred in the above, try to identify what went wrong
      // Was it a WebSphere MQ error?
    catch (MQException ex)
    {
      System.out.println("A WebSphere MQ error occurred : Completion code " +
                         ex.completionCode + " Reason code " + ex.reasonCode);
    }
      // Was it a Java buffer space error?
    catch (java.io.IOException ex)
    {
      System.out.println("An error occurred whilst writing to the message buffer: " + ex);
    }
  }
} // end of sample


When I compile it, the compiler reports that several items have been deprecated. I have seen that issue with other MQ exapmles as well

Where can I get a current and up to date Native code example ?

Thanks
Back to top
View user's profile Send private message Send e-mail
gbaddeley
PostPosted: Fri Mar 15, 2013 3:14 pm    Post subject: Reply with quote

Jedi

Joined: 25 Mar 2003
Posts: 2494
Location: Melbourne, Australia

Quote:
I am not a programmer, but need to build a native PTP code, eventually with a MQ TX MGr (I am assuming the MQ native allows TX use, but not the MQ JMS)

From this site:
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=%2Fcom.ibm.mq.csqzaw.doc%2Fuj11050_.htm
...

v6r0 = unsupport version of MQ.
Try http://pic.dhe.ibm.com/infocenter/wmqv7/v7r5/index.jsp

You will find Java sample code in a WMQ server installation that included the "samples" component.
_________________
Glenn
Back to top
View user's profile Send private message
Gideon
PostPosted: Mon Mar 18, 2013 2:27 pm    Post subject: Reply with quote

Chevalier

Joined: 18 Aug 2009
Posts: 403

I looked in that site, but could not find any example programs for JMS.

The closet I found was a page which discuses JMS extensions, but did not give a JMS example program that do not contain deprecated objects

Is there any place I can find a current example JMS program and how to compile and invoke it ?
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Native MQ in java
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.