当前位置: 首页>>代码示例>>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;未经允许,请勿转载。