I have a very simple MDB (I am using JBoss 4.2.2 and ActiveMQ 5.,1 and 5.2 both have same behavior) that just consumes messages and throws them away. I can easily reproduce a scenario where I load 100 messages on the queue, 1 to 3 messages will never be delivered to the my MDB. If I stop/start the MDB, they get delivered fine. I tried moving to ActiveMQ 5.2 (I originally was 5.1) and I see the exact behavior. I can also reproduce the same issue but stopping the MDB, loading the messages on the queue, then starting the MDB. Again, messages that never get delivered.
Is there something wrong with this example?
@MessageDriven(activationConfig =
{
@ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
@ActivationConfigProperty(propertyName="destination", propertyValue="mylilmdb.test.queue"),
@ActivationConfigProperty(propertyName="maximumRedeliveries", propertyValue="0"),
@ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="Auto-acknowledge")
})
@ResourceAdapter("activemq-rar.rar")
@PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1)
public class MyLilMDB implements MessageListener {
static Logger logger = Logger.getLogger(MyLilMDB.class);
@Resource
private MessageDrivenContext mdc;
public void onMessage(Message message) {
try {
TextMessage msg = (TextMessage)message;
String xml = msg.getText();
logger.info("Chopped Message:" + xml.substring(0, 100));
}
catch (Exception e) {
logger.error(e.getMessage(),e);
mdc.setRollbackOnly();
}
}
I have an update on this. We applied jboss-messaging-1.4.0.SP3 on top of the 4.2.2 distribution (part of a different experiment) that was the cause of this unstable behavior with ActiveMQ. On a clean 4.2.2 distribution, this problem doesn't occur.