use of javax.jms.InvalidDestinationException in project qpid-broker-j by apache.
the class QueueSenderTest method sendToUnknownQueue.
@Test
public void sendToUnknownQueue() throws Exception {
QueueConnection connection = ((QueueConnection) getConnectionBuilder().build());
try {
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue invalidDestination = session.createQueue("unknown");
try {
QueueSender sender = session.createSender(invalidDestination);
sender.send(session.createMessage());
fail("Exception not thrown");
} catch (InvalidDestinationException e) {
// PASS
}
} finally {
connection.close();
}
}
use of javax.jms.InvalidDestinationException in project qpid-broker-j by apache.
the class QueueSenderTest method anonymousSenderSendToUnknownQueue.
@Test
public void anonymousSenderSendToUnknownQueue() throws Exception {
QueueConnection connection = ((QueueConnection) getConnectionBuilder().setSyncPublish(true).build());
try {
QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue invalidDestination = session.createQueue("unknown");
try {
QueueSender sender = session.createSender(null);
sender.send(invalidDestination, session.createMessage());
fail("Exception not thrown");
} catch (InvalidDestinationException e) {
// PASS
}
} finally {
connection.close();
}
}
use of javax.jms.InvalidDestinationException in project rabbitmq-jms-client by rabbitmq.
the class RMQMessageProducer method internalSend.
private void internalSend(RMQDestination destination, Message message, int deliveryMode, int priority, long timeToLiveOrExpiration, MessageExpirationType messageExpirationType) throws JMSException {
logger.trace("send/publish message({}) to destination({}) with properties deliveryMode({}), priority({}), timeToLive({})", message, destination, deliveryMode, priority, timeToLiveOrExpiration);
this.sendingContextConsumer.accept(new SendingContext(destination, message));
if (destination == null)
destination = this.destination;
if (destination == null)
throw new InvalidDestinationException("No destination supplied, or implied.");
if (deliveryMode != javax.jms.DeliveryMode.PERSISTENT)
deliveryMode = javax.jms.DeliveryMode.NON_PERSISTENT;
/* Normalise message to internal form */
RMQMessage rmqMessage = RMQMessage.normalise(message);
/* Set known JMS message properties that need to be set during this call */
long currentTime = System.currentTimeMillis();
long expiration;
long ttl;
if (messageExpirationType == MessageExpirationType.TTL) {
expiration = timeToLiveOrExpiration == 0L ? 0L : currentTime + timeToLiveOrExpiration;
ttl = timeToLiveOrExpiration;
} else {
expiration = timeToLiveOrExpiration;
ttl = timeToLiveOrExpiration - currentTime;
}
rmqMessage.setJMSDeliveryMode(deliveryMode);
rmqMessage.setJMSPriority(priority);
rmqMessage.setJMSExpiration(expiration);
rmqMessage.setJMSDestination(destination);
rmqMessage.setJMSTimestamp(currentTime);
rmqMessage.generateInternalID();
/* Now send it */
if (destination.isAmqp()) {
sendAMQPMessage(destination, rmqMessage, message, deliveryMode, priority, ttl);
} else {
sendJMSMessage(destination, rmqMessage, message, deliveryMode, priority, ttl);
}
}
Aggregations