當前位置: 首頁>>代碼示例>>Java>>正文


Java Queue類代碼示例

本文整理匯總了Java中org.springframework.amqp.core.Queue的典型用法代碼示例。如果您正苦於以下問題:Java Queue類的具體用法?Java Queue怎麽用?Java Queue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Queue類屬於org.springframework.amqp.core包,在下文中一共展示了Queue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: declareQueue

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
@Override
public void declareQueue() throws IOException {

    RabbitAdmin rabbitAdmin = rabbitAdmin();

    try {
        rabbitAdmin.declareQueue(new Queue("demo2",false,false,false));
    }catch (Exception e){
        try {
            if (406 == ((AMQImpl.Channel.Close) ((ShutdownSignalException)e.getCause().getCause()).getReason()).getReplyCode()) {
                rabbitAdmin.deleteQueue("demo2");
                declareQueue();
            }
        }catch (Exception e1){
        }
        log.error("e 's value : {}", e);
    }


}
 
開發者ID:laidu,項目名稱:java-learn,代碼行數:21,代碼來源:SpringClientDemo.java

示例2: registerListenerEndpoint

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
private void registerListenerEndpoint(RabbitListenerEndpointRegistrar aRegistrar, Queue aQueue, Exchange aExchange, int aConcurrency, Object aDelegate, String aMethodName) {
  admin(connectionFactory).declareQueue(aQueue);
  admin(connectionFactory).declareBinding(BindingBuilder.bind(aQueue)
                                                        .to(aExchange)
                                                        .with(aQueue.getName())
                                                        .noargs());
  
  MessageListenerAdapter messageListener = new MessageListenerAdapter(aDelegate);
  messageListener.setMessageConverter(jacksonAmqpMessageConverter(objectMapper));
  messageListener.setDefaultListenerMethod(aMethodName);

  SimpleRabbitListenerEndpoint endpoint = new SimpleRabbitListenerEndpoint();
  endpoint.setId(aQueue.getName()+"Endpoint");
  endpoint.setQueueNames(aQueue.getName());
  endpoint.setMessageListener(messageListener);

  aRegistrar.registerEndpoint(endpoint,createContainerFactory(aConcurrency));
}
 
開發者ID:creactiviti,項目名稱:piper,代碼行數:19,代碼來源:AmqpMessengerConfiguration.java

示例3: testMetrics

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
@Test
public void testMetrics()
{
    rabbitQueueMetrics.addQueue(generateQueue("test.queue"));

    propertiesManager.request(EasyMock.anyObject(Queue.class));
    PowerMock.expectLastCall().andAnswer(() ->
    {
        RabbitQueueProperties properties = new RabbitQueueProperties();
        properties.setMessageCount(5432);
        properties.setConsumerCount(2);
        return properties;
    });

    PowerMock.replayAll();
    List<Metric<?>> metrics = new ArrayList<>(rabbitQueueMetrics.metrics());
    PowerMock.verifyAll();

    Assert.assertEquals(2, metrics.size());
    Assert.assertEquals("rabbit.queue.test_queue.currentMessageCount", metrics.get(0).getName());
    Assert.assertEquals(5432, metrics.get(0).getValue());
    Assert.assertEquals("rabbit.queue.test_queue.currentConsumerCount", metrics.get(1).getName());
    Assert.assertEquals(2, metrics.get(1).getValue());
}
 
開發者ID:julian-eggers,項目名稱:spring-rabbitmq-actuator,代碼行數:25,代碼來源:RabbitQueueMetricsTest.java

示例4: testDoHealthCheckSingleQueueCheckMetricException

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
@Test
public void testDoHealthCheckSingleQueueCheckMetricException() throws Exception
{
    Queue queue = generateQueue("test");
    healthIndicator.addQueueCheck(queue, 10000, 2);

    propertiesManager.request(queue);
    PowerMock.expectLastCall().andThrow(new RuntimeException());

    PowerMock.replayAll();
    Builder builder = new Builder(Status.OUT_OF_SERVICE);
    healthIndicator.doHealthCheck(builder);
    PowerMock.verifyAll();

    Health health = builder.build();
    Assert.assertEquals(Status.DOWN, health.getStatus());
    Assert.assertNull(health.getDetails().get("test"));
}
 
開發者ID:julian-eggers,項目名稱:spring-rabbitmq-actuator,代碼行數:19,代碼來源:RabbitQueueCheckHealthIndicatorTest.java

示例5: testRequest

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
@Test
public void testRequest()
{
    Queue queue = new Queue("test");
    queue.setAdminsThatShouldDeclare(rabbitAdmin);

    rabbitAdmin.getQueueProperties("test");
    PowerMock.expectLastCall().andAnswer(() ->
    {
        Properties properties = new Properties();
        properties.setProperty("QUEUE_CONSUMER_COUNT", "2");
        properties.setProperty("QUEUE_MESSAGE_COUNT", "234");
        return properties;
    });

    PowerMock.replayAll();
    RabbitQueueProperties queueProperties = propertiesManager.request(queue);
    PowerMock.verifyAll();

    Assert.assertEquals(2, queueProperties.getConsumerCount());
    Assert.assertEquals(234, queueProperties.getMessageCount());
}
 
開發者ID:julian-eggers,項目名稱:spring-rabbitmq-actuator,代碼行數:23,代碼來源:RabbitQueuePropertiesManagerTest.java

示例6: ticketServiceRequestQueue

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
/**
 * This returns the request queue for the Ticketing Service
 *
 * @return The request queue for Ticketing Service messages.
 * @since 0.1
 */
   
@Bean
Queue ticketServiceRequestQueue()
{
    return new Queue(QUEUE_TICKET_REQUEST);
}
 
開發者ID:dellemc-symphony,項目名稱:ticketing-service-paqx-parent-sample,代碼行數:13,代碼來源:TicketingServiceRabbitConfig.java

示例7: zhihuUserDataQueue

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
/**
 * 配置知乎用戶資料隊列 bean
 * 
 * @param rabbitAdmin
 * @return
 */
@Bean
public Queue zhihuUserDataQueue(@Autowired RabbitAdmin rabbitAdmin) {

	// 創建知乎用戶資料隊列對象
	Queue ubdQueue = new Queue("zhuhu.user.queue");

	// 聲明知乎用戶資料隊列
	rabbitAdmin.declareQueue(ubdQueue);

	// 返回知乎用戶資料隊列
	return ubdQueue;
}
 
開發者ID:sdc1234,項目名稱:zhihu-spider,代碼行數:19,代碼來源:RabbitmqConfiguration.java

示例8: userBehaviorDataQueue

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
/**
 * 配置知乎問題隊列 bean
 * 
 * @param rabbitAdmin
 * @return
 */
@Bean
public Queue userBehaviorDataQueue(@Autowired RabbitAdmin rabbitAdmin) {

	// 創建知乎問題隊列對象
	Queue ubdQueue = new Queue("zhuhu.question.queue");

	// 聲明知乎問題隊列
	rabbitAdmin.declareQueue(ubdQueue);

	// 返回知乎問題隊列
	return ubdQueue;
}
 
開發者ID:sdc1234,項目名稱:zhihu-spider,代碼行數:19,代碼來源:RabbitmqConfiguration.java

示例9: getMessageListenerContainer

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
@Bean
public SimpleMessageListenerContainer getMessageListenerContainer(final ConnectionFactory connectionFactory,
                                                                  final Queue commandDrainQueue,
                                                                  final MessageListenerAdapter messageListener) {

    final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(commandDrainQueue);
    container.setMessageListener(messageListener);

    return container;
}
 
開發者ID:sem2nawara,項目名稱:acme-solution,代碼行數:12,代碼來源:RabbitTestConfigurer.java

示例10: RabbitQueueMetrics

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
public RabbitQueueMetrics(List<Queue> queues)
{
    for (Queue queue : queues)
    {
        addQueue(queue);
    }
}
 
開發者ID:julian-eggers,項目名稱:spring-rabbitmq-actuator,代碼行數:8,代碼來源:RabbitQueueMetrics.java

示例11: request

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
public RabbitQueueProperties request(Queue queue)
{
    RabbitAdmin rabbitAdmin = validateRabbitAdmin(queue);
    Properties queueProperties = rabbitAdmin.getQueueProperties(queue.getName());

    if (queueProperties == null)
    {
        throw new RuntimeException("Failed to fetch queue-properties (Queue: " + queue.getName() + ")");
    }

    RabbitQueueProperties properties = new RabbitQueueProperties();
    properties.setConsumerCount(Integer.parseInt(queueProperties.get("QUEUE_CONSUMER_COUNT").toString()));
    properties.setMessageCount(Integer.parseInt(queueProperties.get("QUEUE_MESSAGE_COUNT").toString()));
    return properties;
}
 
開發者ID:julian-eggers,項目名稱:spring-rabbitmq-actuator,代碼行數:16,代碼來源:RabbitQueuePropertiesManager.java

示例12: validateRabbitAdmin

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
private RabbitAdmin validateRabbitAdmin(Queue queue)
{
    Assert.notEmpty(queue.getDeclaringAdmins(), "At least one RabbitAdmin must be declared (Queue: " + queue.getName() + ")");
    Object object = queue.getDeclaringAdmins().iterator().next();
    Assert.isInstanceOf(RabbitAdmin.class, object, "DeclaringAdmin must be a RabbitAdmin (Queue: " + queue.getName() + ")");
    return (RabbitAdmin) object;
}
 
開發者ID:julian-eggers,項目名稱:spring-rabbitmq-actuator,代碼行數:8,代碼來源:RabbitQueuePropertiesManager.java

示例13: QueueCheck

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
public QueueCheck(Queue queue, int maxMessageCount, int minConsumerCount)
{
    this.queue = queue;
    this.maxMessageCount = maxMessageCount;
    this.minConsumerCount = minConsumerCount;
    validateRabbitAdmin(queue);
}
 
開發者ID:julian-eggers,項目名稱:spring-rabbitmq-actuator,代碼行數:8,代碼來源:QueueCheck.java

示例14: validateRabbitAdmin

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
private void validateRabbitAdmin(Queue queue)
{
    Assert.notEmpty(queue.getDeclaringAdmins(), "At least one RabbitAdmin must be declared (Queue: " + queue.getName() + ")");
    Object object = queue.getDeclaringAdmins().iterator().next();
    Assert.isInstanceOf(RabbitAdmin.class, object, "DeclaringAdmin must be a RabbitAdmin (Queue: " + queue.getName() + ")");
    this.rabbitAdmin = (RabbitAdmin) object;
}
 
開發者ID:julian-eggers,項目名稱:spring-rabbitmq-actuator,代碼行數:8,代碼來源:QueueCheck.java

示例15: testMetricsWithThreshold

import org.springframework.amqp.core.Queue; //導入依賴的package包/類
@Test
public void testMetricsWithThreshold()
{
    rabbitQueueMetrics.addQueue(generateQueue("test.queue"), 10000, 5);

    propertiesManager.request(EasyMock.anyObject(Queue.class));
    PowerMock.expectLastCall().andAnswer(() ->
    {
        RabbitQueueProperties properties = new RabbitQueueProperties();
        properties.setMessageCount(5432);
        properties.setConsumerCount(2);
        return properties;
    });

    PowerMock.replayAll();
    List<Metric<?>> metrics = new ArrayList<>(rabbitQueueMetrics.metrics());
    PowerMock.verifyAll();

    Assert.assertEquals(4, metrics.size());
    Assert.assertEquals("rabbit.queue.test_queue.currentMessageCount", metrics.get(0).getName());
    Assert.assertEquals(5432, metrics.get(0).getValue());
    Assert.assertEquals("rabbit.queue.test_queue.currentConsumerCount", metrics.get(1).getName());
    Assert.assertEquals(2, metrics.get(1).getValue());
    Assert.assertEquals("rabbit.queue.test_queue.maxMessageCount", metrics.get(2).getName());
    Assert.assertEquals(10000, metrics.get(2).getValue());
    Assert.assertEquals("rabbit.queue.test_queue.minConsumerCount", metrics.get(3).getName());
    Assert.assertEquals(5, metrics.get(3).getValue());
}
 
開發者ID:julian-eggers,項目名稱:spring-rabbitmq-actuator,代碼行數:29,代碼來源:RabbitQueueMetricsTest.java


注:本文中的org.springframework.amqp.core.Queue類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。