use of javax.jms.QueueSender in project wildfly by wildfly.
the class MDBLifecycleCallback method sendReply.
private void sendReply(Queue destination, String messageID, Exception e) throws JMSException {
QueueConnection conn = qFactory.createQueueConnection();
try {
QueueSession session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
QueueSender sender = session.createSender(destination);
ObjectMessage message = session.createObjectMessage(e == null ? "SUCCESS" : e);
message.setJMSCorrelationID(messageID);
sender.send(message, DeliveryMode.NON_PERSISTENT, 4, 500);
} finally {
conn.close();
}
}
use of javax.jms.QueueSender in project openolat by klemens.
the class JmsIndexer method indexDocument.
@Override
public void indexDocument(String type, Long key) {
QueueSender sender;
QueueSession session;
try {
JmsIndexWork workUnit = new JmsIndexWork(JmsIndexWork.INDEX, type, key);
session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
ObjectMessage message = session.createObjectMessage();
message.setObject(workUnit);
sender = session.createSender(getJmsQueue());
sender.send(message);
session.close();
} catch (JMSException e) {
log.error("", e);
}
}
use of javax.jms.QueueSender in project openolat by klemens.
the class JmsIndexer method indexDocument.
@Override
public void indexDocument(String type, List<Long> keyList) {
QueueSender sender;
QueueSession session;
try {
JmsIndexWork workUnit = new JmsIndexWork(JmsIndexWork.INDEX, type, keyList);
session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
ObjectMessage message = session.createObjectMessage();
message.setObject(workUnit);
sender = session.createSender(getJmsQueue());
sender.send(message);
session.close();
} catch (JMSException e) {
log.error("", e);
}
}
use of javax.jms.QueueSender in project openolat by klemens.
the class CertificatesManagerImpl method sendJmsCertificateFile.
private void sendJmsCertificateFile(Certificate certificate, CertificateTemplate template, Float score, Boolean passed, boolean sendMail) {
QueueSender sender;
QueueSession session = null;
try {
JmsCertificateWork workUnit = new JmsCertificateWork();
workUnit.setCertificateKey(certificate.getKey());
if (template != null) {
workUnit.setTemplateKey(template.getKey());
}
workUnit.setPassed(passed);
workUnit.setScore(score);
workUnit.setSendMail(sendMail);
session = connection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
ObjectMessage message = session.createObjectMessage();
message.setObject(workUnit);
sender = session.createSender(getJmsQueue());
sender.send(message);
} catch (JMSException e) {
log.error("", e);
} finally {
if (session != null) {
try {
session.close();
} catch (JMSException e) {
// last hope
}
}
}
}
use of javax.jms.QueueSender in project rabbitmq-jms-client by rabbitmq.
the class RabbitMQRedeliverOnNackIT method testRMQRedeliverOnNack.
/**
* Test that Rabbit re-delivers a received message which has been rolled-back.
* @throws Exception on test failure
*/
@Test
public void testRMQRedeliverOnNack() throws Exception {
try {
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, /*not transacted*/
Session.CLIENT_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
QueueSender queueSender = queueSession.createSender(queue);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
TextMessage message = queueSession.createTextMessage(MESSAGE);
queueSender.send(message);
} finally {
reconnect();
}
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(true, /*transacted*/
Session.DUPS_OK_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
QueueReceiver queueReceiver = queueSession.createReceiver(queue);
TextMessage message = (TextMessage) queueReceiver.receive(TEST_RECEIVE_TIMEOUT);
assertNotNull(message, "No message delivered initially");
assertEquals(MESSAGE, message.getText(), "Wrong message delivered initially");
queueSession.rollback();
message = (TextMessage) queueReceiver.receive(TEST_RECEIVE_TIMEOUT);
assertNotNull(message, "No message delivered after rollback");
assertEquals(MESSAGE, message.getText(), "Wrong message redelivered");
assertTrue(message.getJMSRedelivered(), "Message not marked 'redelivered'");
queueSession.commit();
}
Aggregations