use of org.springframework.amqp.core.Queue in project tutorials by eugenp.
the class BroadcastConfig method topicBindings.
@Bean
public List<Declarable> topicBindings() {
Queue topicQueue1 = new Queue(topicQueue1Name, false);
Queue topicQueue2 = new Queue(topicQueue2Name, false);
TopicExchange topicExchange = new TopicExchange(topicExchangeName);
return Arrays.asList(topicQueue1, topicQueue2, topicExchange, BindingBuilder.bind(topicQueue1).to(topicExchange).with("*.important.*"), BindingBuilder.bind(topicQueue2).to(topicExchange).with("user.#"));
}
use of org.springframework.amqp.core.Queue in project spring-integration by spring-projects.
the class AmqpMessageSourceIntegrationTests method before.
@Before
public void before() {
RabbitAdmin admin = new RabbitAdmin(this.config.connectionFactory());
Queue queue = QueueBuilder.nonDurable(QUEUE_WITH_DLQ).autoDelete().withArgument("x-dead-letter-exchange", "").withArgument("x-dead-letter-routing-key", DLQ).build();
admin.declareQueue(queue);
this.context.start();
}
use of org.springframework.amqp.core.Queue in project spring-integration by spring-projects.
the class PollableAmqpChannel method onInit.
@Override
protected void onInit() throws Exception {
AmqpTemplate amqpTemplate = getAmqpTemplate();
if (this.queue == null) {
if (getAdmin() == null && amqpTemplate instanceof RabbitTemplate) {
ConnectionFactory connectionFactory = ((RabbitTemplate) amqpTemplate).getConnectionFactory();
setAdmin(new RabbitAdmin(connectionFactory));
setConnectionFactory(connectionFactory);
}
Assert.notNull(getAdmin(), "If no queueName is configured explicitly, an AmqpAdmin instance must be provided, " + "or the AmqpTemplate must be a RabbitTemplate since the Queue needs to be declared.");
this.queue = new Queue(this.channelName);
}
super.onInit();
}
use of org.springframework.amqp.core.Queue in project microservices by pwillhan.
the class RabbitAdminExample method main.
public static void main(String[] args) {
CachingConnectionFactory factory = new CachingConnectionFactory("localhost");
RabbitAdmin admin = new RabbitAdmin(factory);
Queue queue = new Queue("test-queue");
admin.declareQueue(queue);
TopicExchange exchange = new TopicExchange("sample-topic-exchange");
admin.declareExchange(exchange);
admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("sample-key"));
factory.destroy();
}
use of org.springframework.amqp.core.Queue in project spring-integration by spring-projects.
the class ChannelTests method channelDeclarationTests.
/*
* Verify queue is declared if not present and not declared if it is already present.
*/
@Test
public void channelDeclarationTests() {
RabbitAdmin admin = new RabbitAdmin(this.connectionFactory);
admin.deleteQueue("implicit");
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(this.connectionFactory);
container.setAutoStartup(false);
AmqpTemplate amqpTemplate = mock(AmqpTemplate.class);
PointToPointSubscribableAmqpChannel channel = new PointToPointSubscribableAmqpChannel("implicit", container, amqpTemplate);
channel.setBeanFactory(mock(BeanFactory.class));
channel.afterPropertiesSet();
channel.onCreate(null);
assertNotNull(admin.getQueueProperties("implicit"));
admin.deleteQueue("explicit");
channel.setQueueName("explicit");
channel.afterPropertiesSet();
channel.onCreate(null);
assertNotNull(admin.getQueueProperties("explicit"));
admin.deleteQueue("explicit");
// verify no declaration if exists with non-standard props
admin.declareQueue(new Queue("explicit", false));
channel.afterPropertiesSet();
channel.onCreate(null);
assertNotNull(admin.getQueueProperties("explicit"));
admin.deleteQueue("explicit");
}
Aggregations