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 { try {
queueConnection = mqConnectionFactory.createQueueConnection(jmsUser, jmsPass); queueConnection = mqConnectionFactory.createQueueConnection(jmsUser, jmsPass);
queueConnection.setExceptionListener(this); queueConnection.setExceptionListener(this);
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queueSession = queueConnection.createQueueSession(false, Session.CLIENT_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);

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

View File

@ -176,7 +176,7 @@ 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.AUTO_ACKNOWLEDGE); session = queueConnection.createQueueSession(false, QueueSession.CLIENT_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);