client_ack

This commit is contained in:
Peter Hormanns 2023-09-13 19:43:17 +02:00
parent ad42d23545
commit c530a65461
4 changed files with 6 additions and 5 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.AUTO_ACKNOWLEDGE);
queueSession = queueConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(jmsStatusQueue);
queueConnection.start();
QueueReceiver receiver = queueSession.createReceiver(queue);

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.AUTO_ACKNOWLEDGE);
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.CLIENT_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.AUTO_ACKNOWLEDGE);
jmsSession = jmsConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
jmsSender = jmsSession.createSender(jmsSystemQueue);
}
@ -44,6 +44,7 @@ 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 "
@ -55,7 +56,7 @@ public class QueueClient {
}
}
private String queueName(Queue jmsSystemQueue2) {
private String queueName(Queue jmsSystemQueue) {
try {
return jmsSystemQueue.getQueueName();
} catch (Exception exc) {

View File

@ -176,7 +176,7 @@ public class QueueServer implements MessageListener, ExceptionListener {
try {
queueConnection = mqConnectionFactory.createQueueConnection(jmsUsername, jmsPassword);
queueConnection.setExceptionListener(this);
session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
session = queueConnection.createQueueSession(false, QueueSession.CLIENT_ACKNOWLEDGE);
final Queue queue = session.createQueue(jmsStatusQueue);
queueConnection.start();
producer = session.createProducer(queue);