[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: Sporadic read timeouts for app client reading a msg sent
scott.stark@jboss.org
do-not-reply at jboss.com
Thu Sep 11 22:59:53 EDT 2008
I'm not sure what Jesper is looking at, but this is doing a receive(timeout):
| QueueConnection connection = null;
|
| try {
| TestUtil.logTrace("getting connection");
| connection = qcFactory.createQueueConnection();
| QueueSession session = connection.createQueueSession(true, 0);
| TestUtil.logTrace("creating receiver");
| QueueReceiver receiver = session.createReceiver(queue);
| connection.start();
| return getMessage(receiver, timeout);
| } catch (Exception e) {
| handleException("Error receiving message", e);
| } finally {
| if (connection != null) {
| try {
| connection.close();
| } catch (Exception e) {
| handleException("Error closing queue connection", e);
| }
| }
| }
| ...
| public static String getMessage(QueueReceiver receiver, long timeout) {
|
| TextMessage msg;
| String message;
| int retries = 0;
|
| try {
|
| do {
| Message m = receiver.receive(timeout);
|
| if (m == null) {
| TestUtil.logTrace("no message received");
| return TimerImpl.NOMSGRECEIVED;
| }
| else {
| if (m instanceof TextMessage) {
| msg = (TextMessage) m;
| message = msg.getText();
| TestUtil.logTrace("Receiving message at " +
| System.currentTimeMillis() + ": " + message);
| String mTestName = msg.getStringProperty("testName");
| String testName = TestUtil.getProperty("testName");
| if (testName.equals(mTestName)) {
| TestUtil.logTrace("test name property of message is correct: accepting");
| return message;
| }
| TestUtil.logErr("message from " + mTestName + " received - ignoring");
| ++retries;
| }
| else {
| TestUtil.logErr("non-text message received!");
| ++retries;
| }
| }
| } while (retries < 5);
| TestUtil.logTrace("No valid message received after " + retries + " attempts");
|
| } catch (Exception e) {
| TimerImpl.handleException("Error receiving message", e);
| }
| return TimerImpl.NOMSGRECEIVED;
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4176022#4176022
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4176022
More information about the jboss-dev-forums
mailing list