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

View File

@ -62,7 +62,7 @@ public class Transaction {
public Queue lookupJMSQueue(String queueName) { public Queue lookupJMSQueue(String queueName) {
try { try {
final QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(jmsUsername, jmsPassword); 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); final Queue queue = session.createQueue(queueName);
return queue; return queue;
} catch (JMSException e) { } catch (JMSException e) {

View File

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

View File

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