JBoss Community

consume queue is slow

created by everson . in JBoss Messaging - View the full discussion

What could I do to check or fix slow consume in my queues ? I'm using jboss 5.01 + jbossesb 4.9

Follow my code.

 

private InitialContext getInitialContext() throws NamingException {

        Properties jndiProps = new Properties();

        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

        jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

        jndiProps.put(Context.PROVIDER_URL, "jnp://localhost:1099");

        InitialContext initialContext = new InitialContext(jndiProps);

        return initialContext;

    }

 

 

    public ObjectMessage getMessage(String lookup, String messageSelector) {

        Session session = null;

        Connection connection = null;

        ObjectMessage om = null;

        try {

            ConnectionFactory factory = (QueueConnectionFactory) getInitialContext().lookup("/ConnectionFactory");

            connection = factory.createConnection();

            session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);

            Destination destination = (Destination) getInitialContext().lookup(lookup);

            MessageConsumer consumer = session.createConsumer(destination, messageSelector);

            connection.start();

            Message message = null;

 

            message = consumer.receiveNoWait(); //here, if I use receive(), I'm going to wait about 10-15 seconds to get the message. Sometimes I get in 1 or 2 seconds...

            if (message == null)               

                message = consumer.receive(15000);

 

           

            om = (ObjectMessage) message;

        } catch (Exception e) {

Reply to this message by going to Community

Start a new discussion in JBoss Messaging at Community