4 Replies Latest reply on Mar 20, 2014 6:40 AM by S V S G Krishna Murthy K

    Multiple Ports are opened while pushing message to Queue

    S V S G Krishna Murthy K Novice

      Hi,

         I'm trying to push 1000 messages to the Internal Queue of JBOSS 7.1 Using the below code.The messages are successfully published.But the problem is during publish there are 1000 ports are getting opened.Can't we establish single port in publishing all 1000 messages.Please find the below code and suggest the same.And should i need to make any changes in the standalone configurations to achieve this.?Please suggest the same

       

      Code:

      public static void publishMessage(String message)

        {

        QueueConnectionFactory qconFactory;

        QueueConnection qcon = null;

        QueueSession qsession = null;

        QueueSender qsender = null;

        Queue queue;

        TextMessage msg = null;

       

       

        try

        {

        //*************** Connection Factory JNDI name *************************

        String CNN_FACTORY="/JmsXA";

       

        //*************** Connection Factory JNDI name *************************

        String QUEUE_NAME="queue/TestQ";

       

        InitialContext ctx = new InitialContext();

        qconFactory = (QueueConnectionFactory) ctx.lookup(CNN_FACTORY);

        qcon = qconFactory.createQueueConnection();

        qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

        queue = (Queue) ctx.lookup(QUEUE_NAME);

        qsender = qsession.createSender(queue);

        msg = qsession.createTextMessage();

        qcon.start();

       

          msg.setText(message); // Messages

              qsender.send(msg); // Messages sent

       

       

        }

        catch(Exception exception)

        {

        }

        finally

        {

        try

        {

        if(qsession!=null)

        qsession.close();

        if(qsender!=null)

        qsender.close();

        if(qcon!=null)

        {

        qcon.close();

        }

        }

        catch(Exception e)

        {

       

       

        }

        }

       

        }