List of usage examples for javax.jms InvalidDestinationException InvalidDestinationException
public InvalidDestinationException(String reason)
From source file:com.amazon.sqs.javamessaging.SQSMessageProducer.java
/** * Sends a message to a queue.// w w w .ja v a2 s . c om * * @param queue * the queue destination to send this message to * @param message * the message to send * @throws InvalidDestinationException * If a client uses this method with a destination other than * SQS queue destination. * @throws MessageFormatException * If an invalid message is specified. * @throws UnsupportedOperationException * If a client uses this method with a MessageProducer that * specified a destination at creation time. * @throws JMSException * If session is closed or internal error. */ @Override public void send(Queue queue, Message message) throws JMSException { if (!(queue instanceof SQSQueueDestination)) { throw new InvalidDestinationException( "Incompatible implementation of Queue. Please use SQSQueueDestination implementation."); } checkIfDestinationAlreadySet(); sendInternal(queue, message); }
From source file:com.amazon.sqs.javamessaging.SQSMessageProducer.java
/** * Sends a message to a queue destination. * // www.j ava 2 s . com * @param destination * the queue destination to send this message to * @param message * the message to send * @throws InvalidDestinationException * If a client uses this method with a destination other than * valid SQS queue destination. * @throws MessageFormatException * If an invalid message is specified. * @throws UnsupportedOperationException * If a client uses this method with a MessageProducer that * specified a destination at creation time. * @throws JMSException * If session is closed or internal error. */ @Override public void send(Destination destination, Message message) throws JMSException { if (destination == null) { throw new InvalidDestinationException("Destination cannot be null"); } if (destination instanceof SQSQueueDestination) { send((Queue) destination, message); } else { throw new InvalidDestinationException( "Incompatible implementation of Destination. Please use SQSQueueDestination implementation."); } }
From source file:net.timewalker.ffmq4.local.FFMQEngine.java
/** * Unsubscribe a durable subscriber from all related topics */// ww w . ja v a 2 s. c o m public void unsubscribe(String clientID, String subscriptionName) throws JMSException { if (durableSubscriptionManager == null) throw new FFMQException("Engine is stopped.", "ENGINE_STOPPED"); // Check that the registration is valid if (!durableSubscriptionManager.isRegistered(clientID, subscriptionName)) throw new InvalidDestinationException( "Invalid subscription : " + subscriptionName + " for client " + clientID); // [JMS spec] // Try to remove all remanent subscriptions first synchronized (topicMap) { Iterator<LocalTopic> topics = topicMap.values().iterator(); while (topics.hasNext()) { LocalTopic topic = topics.next(); topic.unsubscribe(clientID, subscriptionName); } } // Then delete subscription related queues String subscriberID = clientID + "-" + subscriptionName; synchronized (queueMap) { List<String> queuesToDelete = new ArrayList<>(); Iterator<String> queueNames = queueMap.keySet().iterator(); while (queueNames.hasNext()) { String queueName = queueNames.next(); if (queueName.endsWith(subscriberID)) queuesToDelete.add(queueName); } // Delete matching queues for (int i = 0; i < queuesToDelete.size(); i++) deleteQueue(queuesToDelete.get(i)); } // Clean-up the subscription itself if (!durableSubscriptionManager.unregister(clientID, subscriptionName)) log.error("Unknown durable subscription : " + clientID + "-" + subscriptionName); }
From source file:net.timewalker.ffmq4.local.session.LocalMessageConsumer.java
protected final void initDestination() throws JMSException { // Security : a consumer destination may only be set at creation time // so we check permissions here once and for all. LocalConnection conn = (LocalConnection) session.getConnection(); if (conn.isSecurityEnabled()) { if (destination instanceof Queue) { String queueName = ((Queue) destination).getQueueName(); if (conn.isRegisteredTemporaryQueue(queueName)) { // OK, temporary destination } else if (queueName.equals(FFMQConstants.ADM_REQUEST_QUEUE)) { // Only the internal admin thread can consume on this queue if (conn.getSecurityContext() != null) throw new FFMQException("Access denied to administration queue " + queueName, "ACCESS_DENIED"); } else if (queueName.equals(FFMQConstants.ADM_REPLY_QUEUE)) { conn.checkPermission(Resource.SERVER, Action.REMOTE_ADMIN); } else { // Standard queue conn.checkPermission(destination, Action.CONSUME); }//from w ww . j a va2 s .c om } else if (destination instanceof Topic) { String topicName = ((Topic) destination).getTopicName(); if (conn.isRegisteredTemporaryTopic(topicName)) { // OK, temporary destination } else { // Standard topic conn.checkPermission(destination, Action.CONSUME); } } } // Lookup a local destination object from the given reference if (destination instanceof Queue) { Queue queueRef = (Queue) destination; this.localQueue = engine.getLocalQueue(queueRef.getQueueName()); // Check temporary destinations scope (JMS Spec 4.4.3 p2) session.checkTemporaryDestinationScope(localQueue); this.localQueue.registerConsumer(this); } else if (destination instanceof Topic) { Topic topicRef = (Topic) destination; this.localTopic = engine.getLocalTopic(topicRef.getTopicName()); // Check temporary destinations scope (JMS Spec 4.4.3 p2) session.checkTemporaryDestinationScope(localTopic); // Deploy a local queue for this consumer TopicDefinition topicDef = this.localTopic.getDefinition(); QueueDefinition tempDef = topicDef.createQueueDefinition(topicRef.getTopicName(), subscriberId, !isDurable()); if (engine.localQueueExists(tempDef.getName())) this.localQueue = engine.getLocalQueue(tempDef.getName()); else this.localQueue = engine.createQueue(tempDef); // Register on both the queue and topic this.localQueue.registerConsumer(this); this.localTopic.registerConsumer(this); } else throw new InvalidDestinationException("Unsupported destination : " + destination); }
From source file:net.timewalker.ffmq4.local.session.LocalSession.java
/** * Called from producers when sending a message * @param message message to dispatch/* ww w . j a v a 2 s.c o m*/ * @throws JMSException */ public final void dispatch(AbstractMessage message) throws JMSException { // Security LocalConnection conn = (LocalConnection) getConnection(); if (conn.isSecurityEnabled()) { Destination destination = message.getJMSDestination(); if (destination instanceof Queue) { String queueName = ((Queue) destination).getQueueName(); if (conn.isRegisteredTemporaryQueue(queueName)) { // OK, temporary destination } else if (queueName.equals(FFMQConstants.ADM_REQUEST_QUEUE)) { conn.checkPermission(Resource.SERVER, Action.REMOTE_ADMIN); } else if (queueName.equals(FFMQConstants.ADM_REPLY_QUEUE)) { // Only the internal admin thread can produce on this queue if (conn.getSecurityContext() != null) throw new FFMQException("Access denied to administration queue " + queueName, "ACCESS_DENIED"); } else { // Standard queue conn.checkPermission(destination, Action.PRODUCE); } } else if (destination instanceof Topic) { String topicName = ((Topic) destination).getTopicName(); if (conn.isRegisteredTemporaryTopic(topicName)) { // OK, temporary destination } else { // Standard topic conn.checkPermission(destination, Action.PRODUCE); } } else throw new InvalidDestinationException("Unsupported destination : " + destination); } if (debugEnabled) log.debug(this + " [PUT] in " + message.getJMSDestination() + " - " + message); externalAccessLock.readLock().lock(); try { checkNotClosed(); pendingPuts.add(message); if (!transacted) commitUpdates(false, null, true); // FIXME Async commit ? } finally { externalAccessLock.readLock().unlock(); } }
From source file:net.timewalker.ffmq4.local.session.LocalSession.java
private AbstractLocalDestination getLocalDestination(AbstractMessage message) throws JMSException { Destination destination = message.getJMSDestination(); if (destination instanceof Queue) { Queue queueRef = (Queue) destination; return engine.getLocalQueue(queueRef.getQueueName()); } else if (destination instanceof Topic) { Topic topicRef = (Topic) destination; return engine.getLocalTopic(topicRef.getTopicName()); } else//from w ww . j a va 2 s . co m throw new InvalidDestinationException("Unsupported destination : " + destination); }
From source file:org.springframework.integration.jms.ChannelPublishingJmsMessageListener.java
/** * Determine a reply destination for the given message. * <p>/* w w w . j ava 2s .c o m*/ * This implementation first checks the boolean 'error' flag which signifies that the reply is an error message. If * reply is not an error it will first check the JMS Reply-To {@link Destination} of the supplied request message; * if that is not <code>null</code> it is returned; if it is <code>null</code>, then the configured * {@link #resolveDefaultReplyDestination default reply destination} is returned; if this too is <code>null</code>, * then an {@link InvalidDestinationException} is thrown. * @param request the original incoming JMS message * @param session the JMS Session to operate on * @return the reply destination (never <code>null</code>) * @throws JMSException if thrown by JMS API methods * @throws InvalidDestinationException if no {@link Destination} can be determined * @see #setDefaultReplyDestination * @see javax.jms.Message#getJMSReplyTo() */ private Destination getReplyDestination(javax.jms.Message request, Session session) throws JMSException { Destination replyTo = request.getJMSReplyTo(); if (replyTo == null) { replyTo = resolveDefaultReplyDestination(session); if (replyTo == null) { throw new InvalidDestinationException("Cannot determine reply destination: " + "Request message does not contain reply-to destination, and no default reply destination set."); } } return replyTo; }
From source file:org.springframework.jms.listener.adapter.AbstractAdaptableMessageListener.java
/** * Determine a response destination for the given message. * <p>The default implementation first checks the JMS Reply-To * {@link Destination} of the supplied request; if that is not {@code null} * it is returned; if it is {@code null}, then the configured * {@link #resolveDefaultResponseDestination default response destination} * is returned; if this too is {@code null}, then an * {@link javax.jms.InvalidDestinationException} is thrown. * @param request the original incoming JMS message * @param response the outgoing JMS message about to be sent * @param session the JMS Session to operate on * @return the response destination (never {@code null}) * @throws JMSException if thrown by JMS API methods * @throws javax.jms.InvalidDestinationException if no {@link Destination} can be determined * @see #setDefaultResponseDestination/* w ww .j a v a 2s.c o m*/ * @see javax.jms.Message#getJMSReplyTo() */ protected Destination getResponseDestination(Message request, Message response, Session session) throws JMSException { Destination replyTo = request.getJMSReplyTo(); if (replyTo == null) { replyTo = resolveDefaultResponseDestination(session); if (replyTo == null) { throw new InvalidDestinationException("Cannot determine response destination: " + "Request message does not contain reply-to destination, and no default response destination set."); } } return replyTo; }