this.sess = sess;
}
public void onMessage(Message m)
{
TextMessage tm = (TextMessage)m;
count++;
log.info(this + " Got message:" + count);
try
{
log.info(this + " message:" + tm.getText());
if (count == 1)
{
if (!("a".equals(tm.getText())))
{
log.info("Should be a but was " + tm.getText());
failed = true;
latch.release();
}
log.info("Throwing exception");
throw new RuntimeException("Aardvark");
}
else if (count == 2)
{
log.info("ack mode:" + sess.getAcknowledgeMode());
if (sess.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE || sess.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE)
{
//Message should be immediately redelivered
if (!("a".equals(tm.getText())))
{
log.info("Should be a but was " + tm.getText());
failed = true;
latch.release();
}
if (!tm.getJMSRedelivered())
{
failed = true;
latch.release();
}
}
else
{
//Transacted or CLIENT_ACKNOWLEDGE - next message should be delivered
if (!("b".equals(tm.getText())))
{
log.info("Should be b but was " + tm.getText());
failed = true;
latch.release();
}
}
}
else if (count == 3)
{
if (sess.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE || sess.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE)
{
if (!("b".equals(tm.getText())))
{
log.info("Should be b but was " + tm.getText());
failed = true;
latch.release();
}
}
else
{
if (!("c".equals(tm.getText())))
{
log.info("Should be c but was " + tm.getText());
failed = true;
latch.release();
}
latch.release();
}
}
else if (count == 4)
{
if (sess.getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE || sess.getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE)
{
if (!("c".equals(tm.getText())))
{
log.info("Should be c but was " + tm.getText());
failed = true;
latch.release();
}
latch.release();
}