当前位置: 首页>>代码示例>>Java>>正文


Java InvalidDestinationException类代码示例

本文整理汇总了Java中javax.jms.InvalidDestinationException的典型用法代码示例。如果您正苦于以下问题:Java InvalidDestinationException类的具体用法?Java InvalidDestinationException怎么用?Java InvalidDestinationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InvalidDestinationException类属于javax.jms包,在下文中一共展示了InvalidDestinationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connect

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
public void connect(String clientId) throws InvalidObjectException {
    String serverUri = null;

    try {
        InetAddress inet = InetAddress.getLocalHost();
        InetAddress[] ips = InetAddress.getAllByName(inet.getCanonicalHostName());
        if (ips != null && ips.length != 0) {
            serverUri = "tcp://" + ips[0].getHostAddress();
        }
        else {
            throw new InvalidDestinationException("Not network device.");
        }
    }
    catch (Throwable throwable) {
        showException(throwable);
    }

    if(serverUri != null) {
        connect(clientId, serverUri);
    }
}
 
开发者ID:Hill30,项目名称:amq-kahadb-tool,代码行数:22,代码来源:MqttConsumer.java

示例2: testFQQNTopicWhenQueueDoesNotExist

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
@Test
public void testFQQNTopicWhenQueueDoesNotExist() throws Exception {
   Exception e = null;
   String queueName = "testQueue";

   Connection connection = createConnection(false);
   try {
      connection.setClientID("FQQNconn");
      connection.start();
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Topic topic = session.createTopic(multicastAddress.toString() + "::" + queueName);
      session.createConsumer(topic);
   } catch (InvalidDestinationException ide) {
      e = ide;
   } finally {
      connection.close();
   }
   assertNotNull(e);
   assertTrue(e.getMessage().contains("Queue: '" + queueName + "' does not exist"));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:21,代码来源:AmqpFullyQualifiedNameTest.java

示例3: testQueueSpecial

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
/**
 * Broker should return exception if no address is passed in FQQN.
 * @throws Exception
 */
@Test
public void testQueueSpecial() throws Exception {
   server.createQueue(anycastAddress, RoutingType.ANYCAST, anycastQ1, null, true, false, -1, false, true);

   Connection connection = createConnection();
   Exception expectedException = null;
   try {
      connection.start();
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

      //::queue ok!
      String specialName = CompositeAddress.toFullQN(new SimpleString(""), anycastQ1).toString();
      javax.jms.Queue q1 = session.createQueue(specialName);
      session.createConsumer(q1);
   } catch (InvalidDestinationException e) {
      expectedException = e;
   }
   assertNotNull(expectedException);
   assertTrue(expectedException.getMessage().contains("Queue: 'q1' does not exist for address ''"));
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:AmqpFullyQualifiedNameTest.java

示例4: testCreateConsumerOnNonExistentTopic

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
@Test
public void testCreateConsumerOnNonExistentTopic() throws Exception {
   Connection pconn = null;

   try {
      pconn = createConnection();

      Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);

      try {
         ps.createConsumer(new Topic() {
            @Override
            public String getTopicName() throws JMSException {
               return "NoSuchTopic";
            }
         });
         ProxyAssertSupport.fail("should throw exception");
      } catch (InvalidDestinationException e) {
         // OK
      }
   } finally {
      if (pconn != null) {
         pconn.close();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:MessageConsumerTest.java

示例5: testCreateConsumerOnNonExistentQueue

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
@Test
public void testCreateConsumerOnNonExistentQueue() throws Exception {
   Connection pconn = null;

   try {
      pconn = createConnection();

      Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);

      try {
         ps.createConsumer(new Queue() {
            @Override
            public String getQueueName() throws JMSException {
               return "NoSuchQueue";
            }
         });
         ProxyAssertSupport.fail("should throw exception");
      } catch (InvalidDestinationException e) {
         // OK
      }
   } finally {
      if (pconn != null) {
         pconn.close();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:MessageConsumerTest.java

示例6: testDurableSubscriptionOnTemporaryTopic

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
@Test
public void testDurableSubscriptionOnTemporaryTopic() throws Exception {
   Connection conn = null;

   conn = createConnection();

   try {
      conn.setClientID("doesn't actually matter");
      Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Topic temporaryTopic = s.createTemporaryTopic();

      try {
         s.createDurableSubscriber(temporaryTopic, "mySubscription");
         ProxyAssertSupport.fail("this should throw exception");
      } catch (InvalidDestinationException e) {
         // OK
      }
   } finally {
      if (conn != null) {
         conn.close();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:DurableSubscriptionTest.java

示例7: testCreateProducerOnInexistentDestination

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
@Test
public void testCreateProducerOnInexistentDestination() throws Exception {
   getJmsServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateQueues(false));
   getJmsServer().getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false));
   Connection pconn = createConnection();
   try {
      Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      try {
         ps.createProducer(ActiveMQJMSClient.createTopic("NoSuchTopic"));
         ProxyAssertSupport.fail("should throw exception");
      } catch (InvalidDestinationException e) {
         // OK
      }
   } finally {
      pconn.close();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:18,代码来源:MessageProducerTest.java

示例8: testCreateBrowserOnNonExistentQueue

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
@Test
public void testCreateBrowserOnNonExistentQueue() throws Exception {
   Connection pconn = getConnectionFactory().createConnection();

   try {
      Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);

      try {
         ps.createBrowser(new Queue() {
            @Override
            public String getQueueName() throws JMSException {
               return "NoSuchQueue";
            }
         });
         ProxyAssertSupport.fail("should throw exception");
      } catch (InvalidDestinationException e) {
         // OK
      }
   } finally {
      if (pconn != null) {
         pconn.close();
      }
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:25,代码来源:BrowserTest.java

示例9: createConsumer

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
@Override
public MessageConsumer createConsumer(final Destination destination,
                                      final String messageSelector,
                                      final boolean noLocal) throws JMSException {
   if (destination == null) {
      throw new InvalidDestinationException("Cannot create a consumer with a null destination");
   }

   if (!(destination instanceof ActiveMQDestination)) {
      throw new InvalidDestinationException("Not an ActiveMQDestination:" + destination);
   }

   ActiveMQDestination jbdest = (ActiveMQDestination) destination;

   if (jbdest.isTemporary() && !connection.containsTemporaryQueue(jbdest.getSimpleAddress())) {
      throw new JMSException("Can not create consumer for temporary destination " + destination +
                                " from another JMS connection");
   }

   return createConsumer(jbdest, null, messageSelector, noLocal, ConsumerDurability.NON_DURABLE);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:ActiveMQSession.java

示例10: createDurableSubscriber

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
@Override
public TopicSubscriber createDurableSubscriber(final Topic topic,
                                               final String name,
                                               String messageSelector,
                                               final boolean noLocal) throws JMSException {
   // As per spec. section 4.11
   if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) {
      throw new IllegalStateException("Cannot create a durable subscriber on a QueueSession");
   }
   checkTopic(topic);
   if (!(topic instanceof ActiveMQDestination)) {
      throw new InvalidDestinationException("Not an ActiveMQTopic:" + topic);
   }
   if ("".equals(messageSelector)) {
      messageSelector = null;
   }

   ActiveMQDestination jbdest = (ActiveMQDestination) topic;

   if (jbdest.isQueue()) {
      throw new InvalidDestinationException("Cannot create a subscriber on a queue");
   }

   return createConsumer(jbdest, name, messageSelector, noLocal, ConsumerDurability.DURABLE);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:ActiveMQSession.java

示例11: deleteTemporaryQueue

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
public void deleteTemporaryQueue(final ActiveMQDestination tempQueue) throws JMSException {
   if (!tempQueue.isTemporary()) {
      throw new InvalidDestinationException("Not a temporary queue " + tempQueue);
   }
   try {
      QueueQuery response = session.queueQuery(tempQueue.getSimpleAddress());

      if (!response.isExists()) {
         throw new InvalidDestinationException("Cannot delete temporary queue " + tempQueue.getName() +
                                                  " does not exist");
      }

      if (response.getConsumerCount() > 0) {
         throw new IllegalStateException("Cannot delete temporary queue " + tempQueue.getName() +
                                            " since it has subscribers");
      }

      SimpleString address = tempQueue.getSimpleAddress();

      session.deleteQueue(address);

      connection.removeTemporaryQueue(address);
   } catch (ActiveMQException e) {
      throw JMSExceptionHelper.convertFromActiveMQException(e);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:27,代码来源:ActiveMQSession.java

示例12: getLocalDestination

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
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
	throw new InvalidDestinationException("Unsupported destination : "+destination);
  }
 
开发者ID:timewalker74,项目名称:ffmq,代码行数:19,代码来源:LocalSession.java

示例13: sendToDestination

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
@Override
protected final void sendToDestination(Destination destination, boolean destinationOverride, Message srcMessage, int deliveryMode, int priority, long timeToLive) throws JMSException
   {
       // Check that the destination was specified
       if (destination == null)
           throw new InvalidDestinationException("Destination not specified");  // [JMS SPEC]

       // Create an internal copy if necessary
       AbstractMessage message = MessageTools.makeInternalCopy(srcMessage);
       
       externalAccessLock.readLock().lock();
       try
	{
   		checkNotClosed();
   		
        // Dispatch to session
           ((LocalSession)session).dispatch(message);
	}
       finally
       {
       	externalAccessLock.readLock().unlock();
       }
   }
 
开发者ID:timewalker74,项目名称:ffmq,代码行数:24,代码来源:LocalMessageProducer.java

示例14: asRef

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
/**
 * Make sure the given destination is a light-weight serializable destination reference
 */
public static DestinationRef asRef( Destination destination ) throws JMSException
{
    if (destination == null)
        return null;
        
    if (destination instanceof DestinationRef)
        return (DestinationRef)destination;
    
    if (destination instanceof Queue)
        return new QueueRef(((Queue)destination).getQueueName());
    
    if (destination instanceof Topic)
        return new TopicRef(((Topic)destination).getTopicName());
    
    throw new InvalidDestinationException("Unsupported destination type : "+destination,"INVALID_DESTINATION");
}
 
开发者ID:timewalker74,项目名称:ffmq,代码行数:20,代码来源:DestinationTools.java

示例15: checkTopic

import javax.jms.InvalidDestinationException; //导入依赖的package包/类
private void checkTopic(Destination topic) throws InvalidDestinationException
{
    if (topic == null)
    {
        throw new UnsupportedOperationException("Topic is null");
    }
    if (!(topic instanceof Topic))
    {
        throw new InvalidDestinationException("Destination " + topic + " is not a topic");
    }
    if(!(topic instanceof AMQDestination))
    {
        throw new InvalidDestinationException("Destination " + topic + " is not a Qpid topic");
    }

}
 
开发者ID:wso2,项目名称:andes,代码行数:17,代码来源:TopicPublisherAdapter.java


注:本文中的javax.jms.InvalidDestinationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。