У меня есть StatelessSessionBean, что при вызове определенного метода создает MapMessage
для отправки в MDB.Остановить отправку сообщения MDB
QueueConnection connection = null;
QueueSession mSession = null;
QueueSender messageProducer = null;
try {
QueueConnectionFactory connectionFactory = (QueueConnectionFactory) home(session).getCTX().lookup(DocumentManagementTransactionUtil.QUEUE_CONNECTION_FACTORY);
connection = connectionFactory.createQueueConnection();
mSession = connection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
Queue dest = (Queue) home.getCTX().lookup(DocumentManagementTransactionUtil.QUEUE_DESTINATION);
messageProducer = mSession.createSender(dest);
messageProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
messageProducer.send(createJMSMessageFordocMessageReceiver(mSession, session, idnr, debugCode));
} catch (Exception ex) {
log.error("failed to start DocumentTransfer MDB", ex);
throw new AsaleException("failed to start DocumentTransfer MDB", ex);
} finally {
try { if (messageProducer != null) messageProducer.close(); } catch (Exception e) { }
try { if (mSession != null) mSession.close(); } catch (Exception e) { }
try { if (connection != null) connection.stop(); connection.close(); } catch (Exception e) { }
}
Теперь в моем onMessage
методе моего MDB я зачитать все, что мне нужно от моего сообщения и подтвердите его.
MapMessage msg = (MapMessage) message;
project = msg.getLong("project");
Long lang = msg.getLong("lang");
int firm = msg.getInt("opFirm");
int sub = msg.getInt("opSub");
long user = msg.getLong("user");
int debugCode = msg.getInt("debugCode");
log.debug(project + prelog + "DocumentManagementMDBean... Retrieved Message: User: " + user + " Project: " + project + " JMS MessageID: " + message.getJMSMessageID() + " Redelivered: " + message.getJMSRedelivered());
message.acknowledge();
и длительная операция начинается, которая занимает неопределенное время (от 1 до X минут) без возвращения из onMessage
метода.
Через 5 минут мое сообщение, как я могу видеть по ID и состоянию redelivered
, получает redelivered, хотя я его уже признал.
Я сделал что-то неправильно или есть способ сообщить Системе не переадресовывать сообщение?
Edit:
@TransactionManagement(TransactionManagementType.BEAN) @MessageDriven(mappedName = DocumentManagementTransactionUtil.MAPPED_NAME, activationConfig = { @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), @ActivationConfigProperty(propertyName = "destination", propertyValue = DocumentManagementTransactionUtil.QUEUE_DESTINATION), @ActivationConfigProperty(propertyName = "dLQMaxResent", propertyValue = "0")})
http://stackoverflow.com/questions/7362143/stop-message-being-redelivered-to-mdb –