use of javax.jms.QueueSender in project rabbitmq-jms-client by rabbitmq.
the class SSLSimpleQueueMessageIT method messageTestBase.
private void messageTestBase(MessageTestType mtt) throws Exception {
try {
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
drainQueue(queueSession, queue);
QueueSender queueSender = queueSession.createSender(queue);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
queueSender.send(mtt.gen(queueSession, (Serializable) queue));
} finally {
reconnect();
}
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
QueueReceiver queueReceiver = queueSession.createReceiver(queue);
mtt.check(queueReceiver.receive(TEST_RECEIVE_TIMEOUT), (Serializable) queue);
}
use of javax.jms.QueueSender in project rabbitmq-jms-client by rabbitmq.
the class AcknowledgeAnomaliesQueueMessageIT method messageTestBase.
private void messageTestBase(MessageTestType mtt) throws Exception {
try {
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
drainQueue(queueSession, queue);
QueueSender queueSender = queueSession.createSender(queue);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
for (int i = 0; i < 2; ++i) {
// send two messages
queueSender.send(mtt.gen(queueSession, (Serializable) queue));
}
} finally {
reconnect();
}
Message msgNotAcked = null;
try {
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, RMQSession.CLIENT_INDIVIDUAL_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
QueueReceiver queueReceiver = queueSession.createReceiver(queue);
msgNotAcked = queueReceiver.receive(TEST_RECEIVE_TIMEOUT);
mtt.check(msgNotAcked, (Serializable) queue);
Message msg2 = queueReceiver.receive(TEST_RECEIVE_TIMEOUT);
mtt.check(msg2, (Serializable) queue);
msg2.acknowledge();
// repeat acknowledgement: should be a no-op
msg2.acknowledge();
} finally // requeues unacknowledged messages
{
reconnect();
}
try {
// should get an illegal state exception
msgNotAcked.acknowledge();
} catch (IllegalStateException ise) {
// brilliant
} catch (Exception e) {
fail(String.format("Message acknowledged outside session gave wrong exception: %s", e));
}
{
queueConn.start();
// automatically acknowledged
QueueSession queueSession = queueConn.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
QueueReceiver queueReceiver = queueSession.createReceiver(queue);
Message msg = queueReceiver.receive(TEST_RECEIVE_TIMEOUT);
mtt.check(msg, (Serializable) queue);
// repeat ack: should be a no-op
msg.acknowledge();
}
}
use of javax.jms.QueueSender in project rabbitmq-jms-client by rabbitmq.
the class ReceiveNoWaitIT method messageTestBase.
private void messageTestBase(MessageTestType mtt) throws Exception {
try {
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
drainQueue(queueSession, queue);
QueueSender queueSender = queueSession.createSender(queue);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
queueSender.send(mtt.gen(queueSession, (Serializable) queue));
} finally {
reconnect();
}
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
QueueReceiver queueReceiver = queueSession.createReceiver(queue);
mtt.check(queueReceiver.receiveNoWait(), (Serializable) queue);
}
use of javax.jms.QueueSender in project rabbitmq-jms-client by rabbitmq.
the class RequeueMessageOnTimeoutIT method sendMessage.
private void sendMessage() throws Exception {
try {
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, 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();
}
}
use of javax.jms.QueueSender in project rabbitmq-jms-client by rabbitmq.
the class SimpleBrowseQueueMessageIT method messageTestBase.
private void messageTestBase(MessageTestType mtt, String selector, int numExpected) throws Exception {
try {
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
drainQueue(queueSession, queue);
QueueSender queueSender = queueSession.createSender(queue);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
queueSender.send(mtt.gen(queueSession, (Serializable) queue));
} finally {
reconnect();
}
queueConn.start();
QueueSession queueSession = queueConn.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(QUEUE_NAME);
{
// Browse queue before receiving message
QueueBrowser queueBrowser = queueSession.createBrowser(queue, selector);
Enumeration<?> e = queueBrowser.getEnumeration();
int numE = 0;
Message msg = null;
while (e.hasMoreElements()) {
++numE;
msg = (Message) e.nextElement();
mtt.check(msg, (Serializable) queue);
}
assertEquals(numExpected, numE, "Wrong number of messages on browse queue");
}
QueueReceiver queueReceiver = queueSession.createReceiver(queue);
mtt.check(queueReceiver.receive(TEST_RECEIVE_TIMEOUT), (Serializable) queue);
}
Aggregations