posting messages to remote queue on mq setup - Websphere

This is a discussion on posting messages to remote queue on mq setup - Websphere ; We are working on setting up of queues on MQ Series6.0. We were able to setup and send a message to the local Queue successfully, But could not send the message to the remote Queue. In case of local queue ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: posting messages to remote queue on mq setup

  1. posting messages to remote queue on mq setup

    We are working on setting up of queues on MQ Series6.0.

    We were able to setup and send a message to the local Queue successfully,

    But could not send the message to the remote Queue.



    In case of local queue we are not having any problem.

    Scenario:

    We have a Queue Manager and Queue in one system and

    Another Queue Manager and Queue in another system.

    We are trying to send a message to the remote queue by giving the ipadress of the remote queue manager.

    As it is required for communication between the queues.



    Below is the error displayed which we are encountering:

    javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for '172.20.51.174:QM_bmphm5s447'

    at com.ibm.mq.jms.services.ConfigEnvironment.newExcep tion(ConfigEnvironment.java:586)

    at com.ibm.mq.jms.MQConnection.createQM(MQConnection. java:2110)

    at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnec tion.java:1532)

    at com.ibm.mq.jms.MQQueueConnection.(MQQueueConnection.java:150)

    at com.ibm.mq.jms.MQQueueConnectionFactory.createQueu eConnection(MQQueueConnectionFactory.java:185)

    at com.ibm.mq.jms.MQQueueConnectionFactory.createQueu eConnection(MQQueueConnectionFactory.java:112)

    at QueueSend.init(QueueSend.java:45)

    at QueueSend.main(QueueSend.java:82)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:324)

    at com.intellij.rt.execution.application.AppMain.main (AppMain.java:86)

    Exception in thread "main"

    Process finished with exit code 1

    Here is the java prg for sending the message to remote queue.
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.Hashtable;
    import javax.jms.*;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import com.ibm.mq.jms.MQQueueConnectionFactory;
    import com.ibm.mq.jms.services.ConfigEnvironment;


    public class QueueSend
    {
    // Defines the JNDI context factory.
    public final static String JNDI_FACTORY=

    "com.sun.jndi.fscontext.RefFSContextFactory";
    // Defines the JMS context factory.
    public final static String JMS_FACTORY="DQCF";

    // Defines the queue.
    public final static String QUEUE="q2";

    //Define the url
    public final static String url="file:/C:/JNDI-Directory";
    private QueueConnectionFactory qconFactory;
    private QueueConnection qcon;
    private QueueSession qsession;
    private QueueSender qsender;
    private Queue queue;
    private TextMessage msg;

    /**
    * Creates all the necessary objects for sending
    * messages to a JMS queue.
    *
    * @param ctx JNDI initial context
    * @param queueName name of queue
    * @exception NamingException if operation cannot be performed
    * @exception JMSException if JMS fails to initialize due to internal error
    */
    public void init(Context ctx, String queueName)
    throws NamingException, JMSException
    {
    qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
    System.out.println("JMS Message Sent: "+qconFactory+"\n");
    qcon = qconFactory.createQueueConnection();
    System.out.println("JMS Message Sent1: "+qcon+"\n");
    qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
    System.out.println("JMS Message Sent2: "+qsession+"\n");
    queue = (Queue) ctx.lookup(queueName);
    System.out.println("JMS Message Sent3: "+queue+"\n");
    qsender = qsession.createSender(queue);
    System.out.println("JMS Message Sent4: "+qsender+"\n");
    msg = qsession.createTextMessage();
    System.out.println("JMS Message Sent5: "+msg+"\n");
    qcon.start();
    }

    /**
    * Sends a message to a JMS queue.
    *
    * @param message message to be sent
    * @exception JMSException if JMS fails to send message due to internal error
    */
    public void send(String message) throws JMSException {
    msg.setText(message);
    qsender.send(msg);
    }

    /**
    * Closes JMS objects.
    * @exception JMSException if JMS fails to close objects due to internal error
    */
    public void close() throws JMSException {
    qsender.close();
    qsession.close();
    qcon.close();
    }
    /** main() method.
    *
    * @param args WebLogic Server URL
    * @exception Exception if operation fails
    */
    public static void main(String[] args) throws Exception {

    InitialContext ic = getInitialContext();
    QueueSend qs = new QueueSend();
    qs.init(ic, QUEUE);
    readAndSend(qs);
    qs.close();
    }

    private static void readAndSend(QueueSend qs)
    throws IOException, JMSException
    {
    BufferedReader msgStream = new BufferedReader(new InputStreamReader(System.in));
    String line=null;
    boolean quitNow = false;
    do {
    System.out.print("Enter message (\"quit\" to quit): \n");
    line = msgStream.readLine();
    if (line != null && line.trim().length() != 0) {
    qs.send(line);
    System.out.println("JMS Message Sent: "+line+"\n");
    quitNow = line.equalsIgnoreCase("quit");
    }
    } while (! quitNow);

    }

    private static InitialContext getInitialContext()
    throws NamingException
    {
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
    env.put(Context.PROVIDER_URL, url);
    return new InitialContext(env);
    }

    }


    Please help.

  2. Re: posting messages to remote queue on mq setup


    The url you have provided is only for the JNDI lookup.I'm not sure if it'll do to identify the remote JVM. I am also facing the same problem.

+ Reply to Thread