everson . [
https://community.jboss.org/people/everjava] created the discussion
"consume queue is slow"
To view the discussion, visit:
https://community.jboss.org/message/778407#778407
--------------------------------------------------------------
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
[
https://community.jboss.org/message/778407#778407]
Start a new discussion in JBoss Messaging at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]