Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.Queue


            } while (error && !endpoint.isStoppingOrStopped());
        }

        protected void declareAMQPEntities() {
            org.springframework.amqp.core.Exchange exchange = declareExchange();
            Queue queue = declareQueue();
            declareBinding(exchange, queue);
        }
View Full Code Here


                queueArguments.put(TTL_QUEUE_ARGUMENT, endpoint.getTimeToLive());
            if(endpoint.isHa() )
                queueArguments.put(HA_POLICY_ARGUMENT, "all");

            //Declare queue
            Queue queue = new Queue(this.endpoint.queueName, this.endpoint.durable, this.endpoint.exclusive, this.endpoint.autodelete, queueArguments);
            this.endpoint.getAmqpAdministration().declareQueue(queue);
            LOG.info("Declared queue {} for endpoint {}.", queue.getName(), endpoint);
            return queue;
        }
View Full Code Here

public class BigOperationWorker {

    public static void main(String[] args) {
        final ApplicationContext rabbitConfig = new AnnotationConfigApplicationContext(RabbitConfiguration.class);
        final ConnectionFactory rabbitConnectionFactory = rabbitConfig.getBean(ConnectionFactory.class);
        final Queue rabbitQueue = rabbitConfig.getBean(Queue.class);
        final MessageConverter messageConverter = new SimpleMessageConverter();

        // create a listener container, which is required for asynchronous message consumption.
        // AmqpTemplate cannot be used in this case
        final SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer();
        listenerContainer.setConnectionFactory(rabbitConnectionFactory);
        listenerContainer.setQueueNames(rabbitQueue.getName());

        // set the callback for message handling
        listenerContainer.setMessageListener(new MessageListener() {
            public void onMessage(Message message) {
                final BigOperation bigOp = (BigOperation) messageConverter.fromMessage(message);
View Full Code Here

    String queueName = accessor.getPrefix(this.defaultPrefix) + name;
    int partitionIndex = accessor.getPartitionIndex();
    if (partitionIndex >= 0) {
      queueName += "-" + partitionIndex;
    }
    Queue queue = new Queue(queueName);
    declareQueueIfNotPresent(queue);
    autoBindDLQ(name, accessor);
    doRegisterConsumer(name, moduleInputChannel, queue, accessor, false);
    bindExistingProducerDirectlyIfPossible(name, moduleInputChannel);
  }
View Full Code Here

    validateConsumerProperties(name, properties, SUPPORTED_PUBSUB_CONSUMER_PROPERTIES);
    String prefix = accessor.getPrefix(this.defaultPrefix);
    FanoutExchange exchange = new FanoutExchange(prefix + "topic." + name);
    declareExchangeIfNotPresent(exchange);
    String uniqueName = name + "." + UUID.randomUUID().toString();
    Queue queue = new Queue(prefix + uniqueName, false, true, true);
    declareQueueIfNotPresent(queue);
    org.springframework.amqp.core.Binding binding = BindingBuilder.bind(queue).to(exchange);
    this.rabbitAdmin.declareBinding(binding);
    // register with context so they will be redeclared after a connection failure
    this.autoDeclareContext.getBeanFactory().registerSingleton(queue.getName(), queue);
    String bindingBeanName = exchange.getName() + "." + queue.getName() + ".binding";
    if (!autoDeclareContext.containsBean(bindingBeanName)) {
      this.autoDeclareContext.getBeanFactory().registerSingleton(bindingBeanName, binding);
    }
    doRegisterConsumer(name, moduleInputChannel, queue, accessor, true);
    autoBindDLQ(uniqueName, accessor);
View Full Code Here

    String queueName = properties.getPrefix(this.defaultPrefix) + name;
    String partitionKeyExtractorClass = properties.getPartitionKeyExtractorClass();
    Expression partitionKeyExpression = properties.getPartitionKeyExpression();
    AmqpOutboundEndpoint queue = new AmqpOutboundEndpoint(rabbitTemplate);
    if (partitionKeyExpression == null && !StringUtils.hasText(partitionKeyExtractorClass)) {
      declareQueueIfNotPresent(new Queue(queueName));
      queue.setRoutingKey(queueName); // uses default exchange
    }
    else {
      queue.setRoutingKeyExpression(buildPartitionRoutingExpression(queueName));
      for (int i = 0; i < properties.getPartitionCount(); i++) {
        this.rabbitAdmin.declareQueue(new Queue(queueName + "-" + i));
      }
    }
    configureOutboundHandler(queue, properties);
    return queue;
  }
View Full Code Here

    queue.setBeanFactory(this.getBeanFactory());

    String replyQueueName = accessor.getPrefix(this.defaultPrefix) + name + ".replies."
        + this.getIdGenerator().generateId();
    this.doRegisterProducer(name, requests, queue, replyQueueName, accessor);
    Queue replyQueue = new Queue(replyQueueName, false, false, true); // auto-delete
    declareQueueIfNotPresent(replyQueue);
    // register with context so it will be redeclared after a connection failure
    this.autoDeclareContext.getBeanFactory().registerSingleton(replyQueueName, replyQueue);
    this.doRegisterConsumer(name, replies, replyQueue, accessor, false);
  }
View Full Code Here

    if (logger.isInfoEnabled()) {
      logger.info("binding replier: " + name);
    }
    validateConsumerProperties(name, properties, SUPPORTED_REPLYING_CONSUMER_PROPERTIES);
    RabbitPropertiesAccessor accessor = new RabbitPropertiesAccessor(properties);
    Queue requestQueue = new Queue(accessor.getPrefix(this.defaultPrefix) + name + ".requests");
    declareQueueIfNotPresent(requestQueue);
    this.doRegisterConsumer(name, requests, requestQueue, accessor, false);

    AmqpOutboundEndpoint replyQueue = new AmqpOutboundEndpoint(rabbitTemplate);
    replyQueue.setRoutingKeyExpression("headers['" + AmqpHeaders.REPLY_TO + "']");
View Full Code Here

   */
  private void autoBindDLQ(final String name, RabbitPropertiesAccessor properties) {
    if (properties.getAutoBindDLQ(this.defaultAutoBindDLQ)) {
      String prefix = properties.getPrefix(this.defaultPrefix);
      String dlqName = prefix + name + ".dlq";
      Queue dlq = new Queue(dlqName);
      declareQueueIfNotPresent(dlq);
      final String dlxName = properties.getPrefix(this.defaultPrefix) + "DLX";
      final DirectExchange dlx = new DirectExchange(dlxName);
      declareExchangeIfNotPresent(dlx);
      this.rabbitAdmin.declareBinding(BindingBuilder.bind(dlq).to(dlx).with(prefix + name));
View Full Code Here

  public void testAutoBindDLQ() throws Exception {
    // pre-declare the queue with dead-lettering, users can also use a policy
    RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource());
    Map<String, Object> args = new HashMap<String, Object>();
    args.put("x-dead-letter-exchange", "xdbustest.DLX");
    Queue queue = new Queue("xdbustest.dlqtest", true, false, false, args);
    admin.declareQueue(queue);

    MessageBus bus = getMessageBus();
    Properties properties = new Properties();
    properties.put("prefix", "xdbustest.");
View Full Code Here

TOP

Related Classes of org.springframework.amqp.core.Queue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.