Hi,
I am using Glassfish version 3.1.2 for my testing cenario.
I want to configure an MDB on Glassfish with ActivationConfigProperty (redeliveryInterval = 10000 and redeliveryAttempts = 5).
When I explicitly force rollback with setRollbackOnly() inside onMessage method, the server redelivery my message constantly on loop.
Does this two ActivationConfigProperty exists on glassfish?
What I'm doing wrong?
Because I need that after 5 unsuccessful redeliveries, the topic send the message to de DMQ queue.
Here is my MDB code definition:
@MessageDriven(
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "TestTopic"),
@ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "transaction-type", propertyValue = "Container"),
@ActivationConfigProperty(propertyName = "trans-attribute", propertyValue = "Required"),
@ActivationConfigProperty(propertyName = "redeliveryInterval", propertyValue = "10000"),
@ActivationConfigProperty(propertyName = "redeliveryAttempts", propertyValue = "5"),
@ActivationConfigProperty(propertyName = "clientId", propertyValue = "TestTopicMDB2"),
@ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "TestTopicMDB2")
}
, mappedName = "TestTopic")
public class TestTopicMDB2 implements MessageListener {
@Resource
private MessageDrivenContext mdctx;
/**
* Default constructor.
*/
public TestTopicMDB2() {
// TODO Auto-generated constructor stub
}
public void setMessageDrivenContext(MessageDrivenContext mdctx)
{
this.mdctx = mdctx;
System.out.println("TextMDB.setMessageDrivenContext, this=" +
hashCode());
}
@Override
public void onMessage(Message message) {
// try {
// message.setStringProperty("JMS_Sun_JMSJCA_RedeliveryHandling", "2:5000");
// } catch (JMSException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
TextMessage txtMessage = (TextMessage) message;
try {
System.out.println ("\nMesg ID:" + message.getJMSMessageID ());
System.out.println ("Is Message redelivered:" + message.getJMSRedelivered ());
} catch (JMSException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//throw new RuntimeException("Exception thrown to simulate a bad message");
mdctx.setRollbackOnly();
//
// try {
// System.out.println("First Listener: " + txtMessage.getText());
// } catch (Exception e) {
// e.printStackTrace();
// }
}
}
Thanks in advance.
António Oliveira