[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions on the HTTP API utility



I use the Java Message Service Framework to post and receive messages from an MQ Server running on our iSeries.
 
Here's a sample program that might help you to get started.  For more information, check out Suns website.

//*************************************************************************
//
//  Program: mqClient
//
//  Purpose: Connect to a remote MQ Series QManager and retrieve messages
//
//  Paramaters:  Host IP Address or Name; QManager Name; Channel; QName
//
//**************************************************************************
 

import com.ibm.mq.*;
import com.ibm.mqjms.*;
 
 
import java.io.*;
 
 
public class mqClient
 
{
 
    String                  msgResponse  = "";
    String                  qName        = "";
    String                  qManager     = "";
    String                  qChannel     = "";
    String                  qHostIP      = "";
    Queue                   ioQueue      = null;
    QueueSession            session      = null;
    QueueConnection         connection   = null;
    QueueConnectionFactory  factory      = null;
    String                  msgResponse  = "";
    
 
 
 
 
 
//***********************************************************************
// main() method
//***********************************************************************
public void main(String args[])
{
      
   buildJNDIFactory(args[0], args[1], args[2]);
   startConnection();
   obtainSession();
   msgResponse = getMessages();
   closeResources();
 
}
 

//***********************************************************************
// Create a new JNDI Connection Factory
//***********************************************************************
public void buildJNDIFactory(String Host, String qManager, String Channel)
{
 
    factory = new com.ibm.mq.jms.MQQueueConnectionFactory();
 
    factory= new MQQueueConnectionFactory();
    factory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
    factory.setQueueManager(qManager);
    factory.setHostName(qHostIP);
    factory.setChannel(qChannel);
 

}
 
//***********************************************************************
// Create a connection
//***********************************************************************
public void startConnection()
  {
  connection = factory.createQueueConnection();
  connection.start;
  }
 
 
 
//*************************************************************************
// Obtain Session
//*************************************************************************
public void obtainSession()
{
  boolean transacted = false;
 
  session = connection.createQueueSession(transacted, Session.AUTO_ACKNOWLEDGE);
  ioQueue = session.createQueue(qName);
 
// Set Queue Receiver
QueueReceiver queueReceiver = session.createReceiver(ioQueue);
 
 
 
}
 
//********************************************************************************
// Get Messages off of Queue
//********************************************************************************
public String getMessages()
{
 
   Message inMessage = queueReceiver.receive(1000);
 
   // Check to see if the receive call has actually returned a
      // message. If it hasn't, report this and throw an exception...
  if( inMessage == null )
     {
 System.out.println( "No Messages on Queue");
 throw new JMSException("Failed to retrieve a message");
      }
 
  System.out.println( "\n" + "Got message"+": "+inMessage);
 
      // Check that the message received (a) is of the correct type,
      // and (b) contains the same text as the one sent, reporting the
      // result of these two checks
      if( inMessage instanceof TextMessage ) {
 
 // Extract the message content with getText()
 String replyString = ((TextMessage) inMessage).getText();
     
      }
        return replyString;
 
}
 
//********************************************************************************
// Close Resources
//********************************************************************************
public void closeResources()
{
      // Closing QueueReceiver
      System.out.println("Closing QueueReceiver");
      queueReceiver.close();
 
      // Closing QueueSesssion.
      System.out.println("Closing Session");
      session.close();
      session = null;
 
      // Closing QueueConnection.
      System.out.println("Closing Connection");
      connection.close();
      connection = null;
}
 
}
 
Shannon O'Donnell
----- Original Message -----
Sent: Tuesday, March 29, 2005 12:58 PM
Subject: Questions on the HTTP API utility

I have several questions concerning the HTTP API utility:
 
1. We are having problems with throughput from an AS/400 to a WebSphere MQ server. Is there an API procedure that performs like the HTTP_URL_Post without waiting for any return code?  Is there a better way than using the HTTP API utility to post transactions from an AS/400 to a WebSphere MQ server?
 
2. The HTTP_URL_Post function is not handling special characters such as % - / or , . Is it true that this function should automatically encode these characters?
 
Kevin Kauffman
CoreSource Lancaster
 


This e-mail message and all attachments transmitted with it may contain
confidential information intended solely for the
use of the addressee. If the reader of this message is not the intended
recipient, you are hereby notified that any reading, dissemination,
distribution, copying or other use of this message or its attachments is
strictly prohibited.
If you have received this message in error please
notify the sender immediately by telephone or by electronic mail and
delete this message and all copies and backups thereof