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


Java ActiveMQDestination.createDestination方法代码示例

本文整理汇总了Java中org.apache.activemq.command.ActiveMQDestination.createDestination方法的典型用法代码示例。如果您正苦于以下问题:Java ActiveMQDestination.createDestination方法的具体用法?Java ActiveMQDestination.createDestination怎么用?Java ActiveMQDestination.createDestination使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.activemq.command.ActiveMQDestination的用法示例。


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

示例1: addConsumerTest

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
@Test(priority=5)
public void addConsumerTest(){
	//set up a mock for ConsumerInfo
	ActiveMQDestination activeMQDestinationMQ =  ActiveMQDestination.createDestination("mockMQDestionation",  (byte) 1 );		
	activeMQDestinationMQ.setPhysicalName(MQ_PHYSICAL_NAME);
	
	ConsumerInfo consumerInfoActiveMQ = mock(ConsumerInfo.class);
	when(consumerInfoActiveMQ.getDestination()).thenReturn(activeMQDestinationMQ);
	
	//set up mock for ProducerInfo
	producerInfo = mock(ProducerInfo.class);
	when(producerInfo.getDestination()).thenReturn(activeMQDestination);	
	
	try {
		this.oneopsAuthBroker.addConsumer(connectionContextMock, consumerInfoActiveMQ);
	} catch (Exception e) {
		logger.warn("caught exception, make sure Broker is mocked",e);
		throw new RuntimeException(e);
	}
	
}
 
开发者ID:oneops,项目名称:oneops,代码行数:22,代码来源:OneopsAuthBrokerTest.java

示例2: createEndpoint

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    BrokerConfiguration brokerConfiguration = new BrokerConfiguration();
    setProperties(brokerConfiguration, parameters);

    byte destinationType = ActiveMQDestination.QUEUE_TYPE;

    if (remaining.startsWith(JmsConfiguration.QUEUE_PREFIX)) {
        remaining = removeStartingCharacters(remaining.substring(JmsConfiguration.QUEUE_PREFIX.length()), '/');
    } else if (remaining.startsWith(JmsConfiguration.TOPIC_PREFIX)) {
        destinationType = ActiveMQDestination.TOPIC_TYPE;
        remaining = removeStartingCharacters(remaining.substring(JmsConfiguration.TOPIC_PREFIX.length()), '/');
    } else if (remaining.startsWith(JmsConfiguration.TEMP_QUEUE_PREFIX)) {
        destinationType = ActiveMQDestination.TEMP_QUEUE_TYPE;
        remaining = removeStartingCharacters(remaining.substring(JmsConfiguration.TEMP_QUEUE_PREFIX.length()), '/');
    } else if (remaining.startsWith(JmsConfiguration.TEMP_TOPIC_PREFIX)) {
        destinationType = ActiveMQDestination.TEMP_TOPIC_TYPE;
        remaining = removeStartingCharacters(remaining.substring(JmsConfiguration.TEMP_TOPIC_PREFIX.length()), '/');
    }


    ActiveMQDestination destination = ActiveMQDestination.createDestination(remaining, destinationType);
    BrokerEndpoint brokerEndpoint = new BrokerEndpoint(uri, this, destination, brokerConfiguration);
    return brokerEndpoint;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:26,代码来源:BrokerComponent.java

示例3: createDestination

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
/**
 * Given an AMQP endpoint, deduce the appropriate ActiveMQDestination type and create
 * a new instance.  By default if the endpoint address does not carry the standard prefix
 * value then we default to a Queue type destination.  If the endpoint is null or is an
 * AMQP Coordinator type endpoint this method returns null to indicate no destination
 * can be mapped.
 *
 * @param endpoint the AMQP endpoint to construct an ActiveMQDestination from.
 * @return a new ActiveMQDestination that best matches the address of the given endpoint
 * @throws AmqpProtocolException if an error occurs while deducing the destination type.
 */
public static ActiveMQDestination createDestination(Object endpoint) throws AmqpProtocolException {
   if (endpoint == null) {
      return null;
   } else if (endpoint instanceof Coordinator) {
      return null;
   } else if (endpoint instanceof org.apache.qpid.proton.amqp.messaging.Terminus) {
      org.apache.qpid.proton.amqp.messaging.Terminus terminus = (org.apache.qpid.proton.amqp.messaging.Terminus) endpoint;
      if (terminus.getAddress() == null || terminus.getAddress().length() == 0) {
         if (terminus instanceof org.apache.qpid.proton.amqp.messaging.Source) {
            throw new AmqpProtocolException("amqp:invalid-field", "source address not set");
         } else {
            throw new AmqpProtocolException("amqp:invalid-field", "target address not set");
         }
      }

      return ActiveMQDestination.createDestination(terminus.getAddress(), ActiveMQDestination.QUEUE_TYPE);
   } else {
      throw new RuntimeException("Unexpected terminus type: " + endpoint);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:32,代码来源:AmqpSupport.java

示例4: createDestination

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
private ActiveMQDestination createDestination(Object terminus) throws AmqpProtocolException {
    if (terminus == null) {
        return null;
    } else if (terminus instanceof org.apache.qpid.proton.amqp.messaging.Source) {
        org.apache.qpid.proton.amqp.messaging.Source source = (org.apache.qpid.proton.amqp.messaging.Source) terminus;
        if (source.getAddress() == null || source.getAddress().length() == 0) {
            throw new AmqpProtocolException("amqp:invalid-field", "source address not set");
        }
        return ActiveMQDestination.createDestination(source.getAddress(), ActiveMQDestination.QUEUE_TYPE);
    } else if (terminus instanceof org.apache.qpid.proton.amqp.messaging.Target) {
        org.apache.qpid.proton.amqp.messaging.Target target = (org.apache.qpid.proton.amqp.messaging.Target) terminus;
        if (target.getAddress() == null || target.getAddress().length() == 0) {
            throw new AmqpProtocolException("amqp:invalid-field", "target address not set");
        }
        return ActiveMQDestination.createDestination(target.getAddress(), ActiveMQDestination.QUEUE_TYPE);
    } else if (terminus instanceof Coordinator) {
        return null;
    } else {
        throw new RuntimeException("Unexpected terminus type: " + terminus);
    }
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:22,代码来源:AmqpProtocolConverter.java

示例5: createDestinationInfo

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
protected ActiveMQDestination createDestinationInfo(StubConnection connection,
                                                    ConnectionInfo connectionInfo1,
                                                    byte destinationType) throws Exception {
   if ((destinationType & ActiveMQDestination.TEMP_MASK) != 0) {
      DestinationInfo info = createTempDestinationInfo(connectionInfo1, destinationType);
      connection.send(info);
      return info.getDestination();
   } else {
      return ActiveMQDestination.createDestination(queueName, destinationType);
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:12,代码来源:BrokerNetworkWithStuckMessagesTest.java

示例6: testWildcardConsume

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
public void testWildcardConsume() throws Exception {

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo1);

      // setup the wildcard consumer.
      ActiveMQDestination compositeDestination = ActiveMQDestination.createDestination("WILD.*.TEST", destinationType);
      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, compositeDestination);
      consumerInfo1.setPrefetchSize(100);
      connection1.send(consumerInfo1);

      // These two message should NOT match the wild card.
      connection1.send(createMessage(producerInfo1, ActiveMQDestination.createDestination("WILD.CARD", destinationType), deliveryMode));
      connection1.send(createMessage(producerInfo1, ActiveMQDestination.createDestination("WILD.TEST", destinationType), deliveryMode));

      // These two message should match the wild card.
      ActiveMQDestination d1 = ActiveMQDestination.createDestination("WILD.CARD.TEST", destinationType);
      connection1.send(createMessage(producerInfo1, d1, deliveryMode));

      Message m = receiveMessage(connection1);
      assertNotNull(m);
      assertEquals(d1, m.getDestination());

      ActiveMQDestination d2 = ActiveMQDestination.createDestination("WILD.FOO.TEST", destinationType);
      connection1.request(createMessage(producerInfo1, d2, deliveryMode));
      m = receiveMessage(connection1);
      assertNotNull(m);
      assertEquals(d2, m.getDestination());

      assertNoMessagesLeft(connection1);
      connection1.send(closeConnectionInfo(connectionInfo1));
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:39,代码来源:BrokerTest.java

示例7: testCompositeConsume

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
public void testCompositeConsume() throws Exception {

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo1);

      // setup the composite consumer.
      ActiveMQDestination compositeDestination = ActiveMQDestination.createDestination("A,B", destinationType);
      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, compositeDestination);
      consumerInfo1.setRetroactive(true);
      consumerInfo1.setPrefetchSize(100);
      connection1.send(consumerInfo1);

      // Publish to the two destinations
      ActiveMQDestination destinationA = ActiveMQDestination.createDestination("A", destinationType);
      ActiveMQDestination destinationB = ActiveMQDestination.createDestination("B", destinationType);

      // Send a message to each destination .
      connection1.send(createMessage(producerInfo1, destinationA, deliveryMode));
      connection1.send(createMessage(producerInfo1, destinationB, deliveryMode));

      // The consumer should get both messages.
      for (int i = 0; i < 2; i++) {
         Message m1 = receiveMessage(connection1);
         assertNotNull(m1);
      }

      assertNoMessagesLeft(connection1);
      connection1.send(closeConnectionInfo(connectionInfo1));
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:36,代码来源:BrokerTest.java

示例8: closeConsumerAndConnectionConcurrently

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
private void closeConsumerAndConnectionConcurrently(int targetNode, int remoteNode) throws Exception {

      String targetUri = getServerUri(targetNode);
      System.out.println("uri is " + targetUri);
      ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(targetUri);
      Connection conn = null;
      CountDownLatch active = new CountDownLatch(1);
      try {
         conn = factory.createConnection();
         conn.start();
         Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         Destination dest = ActiveMQDestination.createDestination("queue0", ActiveMQDestination.QUEUE_TYPE);
         ConsumerThread consumer = new ConsumerThread(session, dest);
         consumer.setMessageCount(0);
         consumer.setFinished(active);
         consumer.start();

         assertTrue("consumer takes too long to finish!", active.await(5, TimeUnit.SECONDS));
      } finally {
         conn.close();
      }

      Wait.waitFor(() -> getRemoteQueueBinding(servers[remoteNode]) != null);

      //check remote server's consumer count
      RemoteQueueBinding remoteBinding = getRemoteQueueBinding(servers[remoteNode]);

      assertNotNull(remoteBinding);

      Wait.waitFor(() -> remoteBinding.consumerCount() >= 0);
      int count = remoteBinding.consumerCount();
      assertTrue("consumer count should never be negative " + count, count >= 0);
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:34,代码来源:MessageRedistributionTest.java

示例9: assertReceiveNoMessageOn

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
private void assertReceiveNoMessageOn(String destinationName,
                                      byte destinationType) throws Exception, InterruptedException {

   ActiveMQDestination destination = ActiveMQDestination.createDestination(destinationName, destinationType);

   // Send the message to the local broker.
   producerConnection.send(createMessage(producerInfo, destination, destinationType));

   // Make sure the message was delivered via the remote.
   Message m = createConsumerAndReceiveMessage(destination);
   assertNull(m);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:13,代码来源:DemandForwardingBridgeFilterTest.java

示例10: setUp

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
@BeforeClass
/**
 * sets up mocks which get re-used in the tests
 */
public void setUp()  {		

	//set up the mock for CMSClient
	cmsClient = mock(CMSClient.class);
	//- and the mock data that mock will return
	CmsCISimple cmsCISimple = new CmsCISimple();
	Map<String,String> ciAttributes = new HashMap<String,String>(1);
	ciAttributes.put(AUTH_ATTR_KEY, AUTH_KEY_VALUE);
	cmsCISimple.setCiAttributes(ciAttributes);
	//for getCloud(user-name,cloud-name)
	when(cmsClient.getCloudCi(CLOUD_NAME, CLOUD_NAME)).thenReturn(cmsCISimple);
	when(cmsClient.getCloudCi("user", CLOUD_NAME)).thenReturn(cmsCISimple);
	
	//set up the mock for ConnectionInfo:  system/blahblah
	connectionInfoSystem = mock(ConnectionInfo.class);
	when(connectionInfoSystem.getClientId()).thenReturn(SYSTEM_CLIENT_ID);
	when(connectionInfoSystem.getUserName()).thenReturn(SYSTEM_CLIENT_ID + ":" + CLOUD_NAME);
	when(connectionInfoSystem.getPassword()).thenReturn(AUTH_KEY_VALUE);
	
	//and another ConnectionInfo stubbedClientId/foobarbizbat
	connectionBadInfo = mock(ConnectionInfo.class);
	when(connectionBadInfo.getClientId()).thenReturn(MOCK_CLIENT_ID);
	when(connectionBadInfo.getUserName()).thenReturn(CLOUD_NAME + ":" + CLOUD_NAME);
	when(connectionBadInfo.getPassword()).thenReturn(CONN_INFO_PASS_BAD); //to cause fail paasword check		
	
	//and another ConnectionInfo stubbedClientId/blahblah
	connectionInfoUser = mock(ConnectionInfo.class);
	when(connectionInfoUser.getClientId()).thenReturn(MOCK_CLIENT_ID);
	when(connectionInfoUser.getUserName()).thenReturn("user" + ":" + CLOUD_NAME);
	when(connectionInfoUser.getPassword()).thenReturn("blahblah"); //to cause fail paasword check		
	
	// construct ConnectionContext, passing it the system's connection info
	connectionContextSystem = new ConnectionContext(connectionInfoSystem);
	
	//create a mock ConnectionContext
	connectionContextMock = mock(ConnectionContext.class);
	 final Connection connectionMock = mock(Connection.class);
	when(connectionMock.getRemoteAddress()).thenReturn(MOCK_REMOTE_ADDR);
			
	when(connectionContextMock.getClientId()).thenReturn(MOCK_CLIENT_ID);
	when(connectionContextMock.getConnection()).thenAnswer(new Answer<Connection>() {
		@Override
		public Connection answer(InvocationOnMock invocation)
				throws Throwable {
			return connectionMock;
		}
	});
	
	//set up mock for ConsumerInfo
	activeMQDestination =  ActiveMQDestination.createDestination("mockMQDestionation",  (byte) 1 );		
	activeMQDestination.setPhysicalName(MOCK_PHYSICAL_NAME);
	
	consumerInfo = mock(ConsumerInfo.class);
	when(consumerInfo.getDestination()).thenReturn(activeMQDestination);
}
 
开发者ID:oneops,项目名称:oneops,代码行数:60,代码来源:OneopsAuthBrokerTest.java

示例11: copyMessageTo

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
public boolean copyMessageTo(String messageId, String destinationName) throws Exception {
    ConnectionContext context = BrokerSupport.getConnectionContext(broker.getContextBroker());
    ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
    return ((Queue)destination).copyMessageTo(context, messageId, toDestination);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:6,代码来源:QueueView.java

示例12: copyMatchingMessagesTo

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
public int copyMatchingMessagesTo(String selector, String destinationName) throws Exception {
    ConnectionContext context = BrokerSupport.getConnectionContext(broker.getContextBroker());
    ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
    return ((Queue)destination).copyMatchingMessagesTo(context, selector, toDestination);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:6,代码来源:QueueView.java

示例13: moveMatchingMessagesTo

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
public int moveMatchingMessagesTo(String selector, String destinationName) throws Exception {
    ConnectionContext context = BrokerSupport.getConnectionContext(broker.getContextBroker());
    ActiveMQDestination toDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
    return ((Queue)destination).moveMatchingMessagesTo(context, selector, toDestination);
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:6,代码来源:QueueView.java

示例14: testCompositeSend

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
public void testCompositeSend() throws Exception {

      // Setup a first connection
      StubConnection connection1 = createConnection();
      ConnectionInfo connectionInfo1 = createConnectionInfo();
      SessionInfo sessionInfo1 = createSessionInfo(connectionInfo1);
      ProducerInfo producerInfo1 = createProducerInfo(sessionInfo1);
      connection1.send(connectionInfo1);
      connection1.send(sessionInfo1);
      connection1.send(producerInfo1);

      ActiveMQDestination destinationA = ActiveMQDestination.createDestination("A", destinationType);
      ConsumerInfo consumerInfo1 = createConsumerInfo(sessionInfo1, destinationA);
      consumerInfo1.setRetroactive(true);
      consumerInfo1.setPrefetchSize(100);
      connection1.request(consumerInfo1);

      // Setup a second connection
      StubConnection connection2 = createConnection();
      ConnectionInfo connectionInfo2 = createConnectionInfo();
      SessionInfo sessionInfo2 = createSessionInfo(connectionInfo2);
      connection2.send(connectionInfo2);
      connection2.send(sessionInfo2);

      ActiveMQDestination destinationB = ActiveMQDestination.createDestination("B", destinationType);
      ConsumerInfo consumerInfo2 = createConsumerInfo(sessionInfo2, destinationB);
      consumerInfo2.setRetroactive(true);
      consumerInfo2.setPrefetchSize(100);
      connection2.request(consumerInfo2);

      // Send the messages to the composite destination.
      ActiveMQDestination compositeDestination = ActiveMQDestination.createDestination("A,B", destinationType);
      for (int i = 0; i < 4; i++) {
         connection1.request(createMessage(producerInfo1, compositeDestination, deliveryMode));
      }

      // The messages should have been delivered to both the A and B
      // destination.
      for (int i = 0; i < 4; i++) {
         Message m1 = receiveMessage(connection1);
         Message m2 = receiveMessage(connection2);

         assertNotNull(m1);
         assertNotNull(m2);

         assertEquals(m1.getMessageId(), m2.getMessageId());
         assertEquals(compositeDestination, m1.getOriginalDestination());
         assertEquals(compositeDestination, m2.getOriginalDestination());

         connection1.request(createAck(consumerInfo1, m1, 1, MessageAck.STANDARD_ACK_TYPE));
         connection2.request(createAck(consumerInfo2, m2, 1, MessageAck.STANDARD_ACK_TYPE));

      }

      assertNoMessagesLeft(connection1);
      assertNoMessagesLeft(connection2);

      connection1.send(closeConnectionInfo(connectionInfo1));
      connection2.send(closeConnectionInfo(connectionInfo2));
   }
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:61,代码来源:BrokerTest.java

示例15: addMessageInterceptorForQueue

import org.apache.activemq.command.ActiveMQDestination; //导入方法依赖的package包/类
MessageInterceptor addMessageInterceptorForQueue(String destinationName, MessageInterceptor messageInterceptor) {
    ActiveMQDestination activeMQDestination = ActiveMQDestination.createDestination(destinationName, ActiveMQDestination.QUEUE_TYPE);
    interceptorMap.put(activeMQDestination, messageInterceptor);
    return messageInterceptor;
}
 
开发者ID:DiamondLightSource,项目名称:daq-eclipse,代码行数:6,代码来源:MessageInterceptorFilter.java


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