This commit is contained in:
Peter Hormanns 2023-09-13 20:15:04 +02:00
parent 99f33b5b4b
commit a8857091f9
4 changed files with 6 additions and 10 deletions

View File

@ -72,7 +72,7 @@ public class QueueStatusReceiverServlet extends HttpServlet
try {
queueConnection = mqConnectionFactory.createQueueConnection(jmsUser, jmsPass);
queueConnection.setExceptionListener(this);
queueSession = queueConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(jmsStatusQueue);
queueConnection.start();
QueueReceiver receiver = queueSession.createReceiver(queue);
@ -127,7 +127,6 @@ public class QueueStatusReceiverServlet extends HttpServlet
final long queueTaskId = detachedQT.getId();
QueueTask persistentQT = em.find(QueueTask.class, queueTaskId);
if (persistentQT == null) {
jmsMessage.acknowledge();
errorCount++;
throw new TechnicalException("QueueTask not found, id: " + queueTaskId);
}

View File

@ -62,7 +62,7 @@ public class Transaction {
public Queue lookupJMSQueue(String queueName) {
try {
final QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.CLIENT_ACKNOWLEDGE);
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
final Queue queue = session.createQueue(queueName);
return queue;
} catch (JMSException e) {

View File

@ -36,7 +36,7 @@ public class QueueClient {
String jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
String jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
jmsConnection = jmsConnectionFactory.createQueueConnection(jmsUser, jmsPass);
jmsSession = jmsConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
jmsSession = jmsConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
jmsSender = jmsSession.createSender(jmsSystemQueue);
}
@ -44,7 +44,6 @@ public class QueueClient {
try {
ObjectMessage jmsMessage = jmsSession.createObjectMessage(task);
jmsSender.send(jmsMessage);
jmsMessage.acknowledge();
} catch (JMSSecurityException secExc) {
secExc.printStackTrace();
throw new ProcessorException("Not allowed to send to queue "

View File

@ -111,7 +111,7 @@ public class QueueServer implements MessageListener, ExceptionListener {
mqConnectionFactory.setTrustAllPackages(true);
queueConnection = mqConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
queueConnection.setExceptionListener(this);
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.CLIENT_ACKNOWLEDGE);
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(jmsSystemQueue);
queueConnection.start();
final QueueReceiver receiver = session.createReceiver(queue);
@ -146,7 +146,6 @@ public class QueueServer implements MessageListener, ExceptionListener {
logException(throwable);
task.setException(throwable.getMessage());
} finally {
try { jmsMessage.acknowledge(); } catch (JMSException e) { }
sendStatus(task);
notifyAll();
}
@ -176,14 +175,13 @@ public class QueueServer implements MessageListener, ExceptionListener {
try {
queueConnection = mqConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
queueConnection.setExceptionListener(this);
session = queueConnection.createQueueSession(false, QueueSession.CLIENT_ACKNOWLEDGE);
session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
final Queue queue = session.createQueue(jmsStatusQueue);
queueConnection.start();
producer = session.createProducer(queue);
final ObjectMessage statusMessage = session.createObjectMessage(queueMessage);
logger.log(Level.INFO, "send(" + statusMessage + ")");
producer.send(statusMessage);
statusMessage.acknowledge();
logger.log(Level.INFO, "send(" + statusMessage + ")");
} catch (Exception statusException) {
logger.log(Level.SEVERE, statusException.getMessage(), statusException);
} finally {