9 Replies Latest reply on Jan 8, 2009 1:43 PM by stas burdan

    problems connecting to a Queue

    Johan Eriksson Newbie

      Hi,

      I've got a weird problem with Messaging, I'm trying to connect to the queue from a standalone application and I'm getting "Failed to download and/or install client side AOP stack" which I cant seem to find the explanation of.

      The description of the queue is:

      The code I'm

      <?xml version="1.0" encoding="UTF-8"?>
      <server>
       <mbean code="org.jboss.mq.server.jmx.Queue"
       name="jboss.mq.destination:service=Queue,name=TNB-Queue">
       <attribute name="JNDIName">queue/tnb/inbound</attribute>
       <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
       </mbean>
      </server>
      


      the Code I'm using to connect is:


       public boolean setUpJMS(String server)
       {
       Properties props = new Properties();
       props.setProperty( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory" );
       props.setProperty( "java.naming.provider.url", server );
       props.setProperty( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" );
       System.out.println("Got Props, connecting to " + server);
       try
       {
       InitialContext ic = new InitialContext(props);
       System.out.println("Got IC");
      
       connectionFactory = (ConnectionFactory)ic.lookup("ConnectionFactory");
       String sQueueName = "queue/tnb/inbound";
       queue = (Destination)ic.lookup(sQueueName);
       System.out.println("Got queue: " + sQueueName + " aka: " + queue.toString());
      
       connection = connectionFactory.createConnection();
       System.out.println("Got connection");
      
       connection.setExceptionListener(new ExceptionListenerImpl());
       System.out.println("setExceptionListener");
      
       session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
       System.out.println("Got session");
      
       producer = session.createProducer(queue);
       System.out.println("Got producer");
      
       return true;
       }
       catch(Throwable t)
       {
       System.out.println(t.getMessage());
       return false;
       }
       }
      


      when running the app I get the following:
      Server: 192.168.2.230 argsLen = 1
      Starting:192.168.2.230 v0.1
      Got Props, connecting to 192.168.2.230
      Got IC
      Got queue: queue/tnb/inbound aka: JBossQueue[TNB-Queue]
      log4j:WARN No appenders could be found for logger (org.jboss.remoting.transport.socket.MicroSocketClientInvoker).
      log4j:WARN Please initialize the log4j system properly.
      Failed to download and/or install client side AOP stack
      



      and the second strange thing is that when I run the same code from the same machine JBoss is on (Red Hat Fedora 8), I get
      Server: 192.168.2.230 argsLen = 1
      Starting:192.168.2.230 v0.1
      Got Props, connecting to 192.168.2.230
      Got IC
      null
      


      Any help would be really appreciated.

      Cheers
      Johan


        • 1. Re: problems connecting to a Queue
          Frank Henry Novice

          Are you even using any AOP stuff?
          Check your project settings. In eclipse the AOP stuff in the Context-Menu is dangerously close to other much needed functions and maybe you just hit the wrong one, as I have often done.

          Can you see the queue 'queue/tnb/inbound' in the JNDI viewer?

          Also and might not even really be a problem but I use this code:

          ctx = new InitialContext();
          Queue queue = (Queue) ctx.lookup("queue/MyQueue");
          QueueConnectionFactory factory = (QueueConnectionFactory)ctx.lookup("ConnectionFactory");
          QueueConnection connection = factory.createQueueConnection();
          QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
          


          I got it from somewhere else and it works.
          Maybe the order is important or something.

          Also the access code you have written uses those props that are only needed on the client side.
          That might be a reason why it is not working. (really guessing here)
          Remove the props from the new InitialContext() and try it.

          HTH

          • 2. Re: problems connecting to a Queue
            Johan Eriksson Newbie

            Hi Frank,

            Thanks for your reply, I noticed that there were a few errors in my code... I was using the wrong JMS implementation for one...
            I got it to work now, many thanks!

            J

            • 3. Re: problems connecting to a Queue
              Johan Eriksson Newbie

              still seem to have a problem I'm afraid.. I can now connect to the queue and send a message with

              public boolean SendMessage(String server)
               {
               Properties props = new Properties();
               props.setProperty( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory" );
               props.setProperty( "java.naming.provider.url", server );
               props.setProperty( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" );
               System.out.println("Got Props, connecting to " + server);
               try{
               String sQueueName = "queue/tnb/inbound";
               InitialContext ic = new InitialContext(props);
               Queue queue = (Queue) ic.lookup(sQueueName);
               QueueConnectionFactory factory = (QueueConnectionFactory)ic.lookup("ConnectionFactory");
               QueueConnection connection = factory.createQueueConnection();
               QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
               QueueSender qs = session.createSender(queue);
               TextMessage m = session.createTextMessage();
               m.setText("Hello world!");
               qs.send(m);
               qs.close();
               session.close();
               connection.close();
               }
               catch(Exception e)
               {
               e.printStackTrace();
               }
               return true;
               }


              but when I try to read messages I get nothing
              public boolean ReceiveMessage(String server)
               {
               Properties props = new Properties();
               props.setProperty( "java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory" );
               props.setProperty( "java.naming.provider.url", server );
               props.setProperty( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" );
               try{
               String sQueueName = "queue/tnb/inbound";
               InitialContext ic = new InitialContext(props);
               Queue queue = (Queue) ic.lookup(sQueueName);
               QueueConnectionFactory factory = (QueueConnectionFactory)ic.lookup("ConnectionFactory");
               QueueConnection connection = factory.createQueueConnection();
               QueueSession session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
               QueueReceiver qr = session.createReceiver(queue);
               Message m = qr.receive(3000);
               if(m!=null)
               {
               if(m instanceof TextMessage)
               {
               TextMessage tm = (TextMessage) m;
               System.out.println("Message. " + tm.getText());
               }
               }
               else
               {
               System.out.println("No message received.");
               }
               qr.close();
               connection.close();
               }catch(Exception e)
               {
               e.printStackTrace();
               }
               return true;
               }
              


              I can see the messages in the JNDI viewer, so I know they're being sent to the queue.
              Any ideas?

              • 4. Re: problems connecting to a Queue
                Tim Fox Master

                 

                "jeuk" wrote:

                Any ideas?


                You didn't start the connection:

                connection.start();
                


                java.sun.com provides a good JMS tutorial which goes through the basics, I suggest trying it out. :)

                • 5. Re: problems connecting to a Queue
                  Daniel Bevenius Master

                  Hi,

                  I can't see that you have started the connection. Try starting the connection and you should receive the messages.

                  Regards,

                  Daniel

                  • 6. Re: problems connecting to a Queue
                    Johan Eriksson Newbie

                    ohh man... what an idiot I am... yes ofcourse that was it...

                    its all working now!

                    • 7. Re: problems connecting to a Queue
                      Johan Eriksson Newbie

                      one more thing though (not really related to the queue), the AOP seems to throw alot of logging messages, is there a simple way of turning that off?


                      [aop-trace] org.jboss.jms.wireformat.JMSWireFormat Writing InvocationRequest[ed0338, JMS, ConnectionFactoryGetClientAOPStackRequest[6e70c7]]
                      [aop-trace] org.jboss.jms.wireformat.JMSWireFormat Stream is a DataOutputStream
                      [aop-trace] org.jboss.jms.wireformat.JMSWireFormat JBM Request
                      [aop-trace] org.jboss.jms.wireformat.JMSWireFormat Writing packet: ConnectionFactoryGetClientAOPStackRequest[6e70c7]
                      [aop-trace] org.jboss.jms.wireformat.JMSWireFormat Wrote packet


                      • 8. Re: problems connecting to a Queue
                        Tim Fox Master

                        See the log4j site for how to configure log4j.

                        • 9. Re: problems connecting to a Queue
                          stas burdan Newbie

                          jeuk,

                          were you able to find a way to stop outputting [aop-trace] messages?
                          I've tried alt. log4j configuration on my client to no avail. Is this really
                          a log4j related output?