everson . [http://community.jboss.org/people/everjava] created the discussion
"Sometimes consume message, sometimes doesn't..." To view the discussion, visit: http://community.jboss.org/message/635513#635513 -------------------------------------------------------------- Hello! I have this code below and sometimes I can't consume a message, I get return null. But when I'll go to jboss admin-console and search on "list durable messages" using the message selector as I used inside the code it is found. Initially it happend when I call getMessage(..) inside a loop for(), so I thought it was a problem because of several calls. But happend again when just have one call. It doesn't happen everytime, just sometimes What could be wrong ?? ObjectMessage om = jms.getMessage( "queue/MyQueue", "cpf='" + p.getCpf().trim()+ "'"); public ObjectMessage getMessage( String lookup, String messageSelector) { Session session = null; Connection connection = null; ObjectMessage om = null; try { ConnectionFactory factory = (QueueConnectionFactory) getInitialContext().lookup("/ConnectionFactory");//java:/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 = consumer.receive(5000); om = (ObjectMessage) message; } catch (Exception e) {} return om; } -------------------------------------------------------------- Reply to this message by going to Community [http://community.jboss.org/message/635513#635513] Start a new discussion in JBoss Messaging at Community [http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]
_______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user