I have a Bean managed MDB -InvoiceInquiryMessageBean with the following definition which calls a CMT - InvoiceManager which performs database operations.
The MDB is explicitly mentioned as Bean managed and the onMessage() has a transaction NOT_SUPPORTED. Therefore this MDB runs without a transaction demarcation.
The InvoiceManager bean below has no transaction type or transaction attribute defined. so by default its a container managed CMT and has a transaction type of REQUIRED by default.This bean performs database operations. The questions is
Question #1
If there are any errors/exceptions while performing the DB operations like(Primary key violated, DB deadlock like SQL server Error code 1205), the DB transaction is considered failed. Will this DB transaction failure impact the calling MDB.
The reason for this question is i see the messages getting redelivered to the MDB sometimes during database exceptions. Even though the MDB is defined not to participate in any container managed transaction, the db issue is related to the database transaction and will this cause the message to be redelivered to the MDB.
Please if my question is not clear let me know.
@TransactionManagement(TransactionManagementType.BEAN)
@MessageDriven(name = "NonPersistentInquiryMessageBean", activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") })
public class InvoiceInquiryMessageBean implements MessageListener
{
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void onMessage(Message msg)
{
call a CMT Bean(CMT_DB_Bean) which performs database operations
}
}
CMT Bean
@Stateless
public class InvoiceManager implements InvoiceManager Local {
entityManager.update();
}