This commit is contained in:
Phillip Webb
2013-10-08 21:17:39 -07:00
parent b772f7c2e4
commit af0d08c998
14 changed files with 151 additions and 147 deletions

View File

@@ -33,7 +33,7 @@ public class SampleAmqpSimpleApplication {
@Autowired
private AmqpTemplate amqpTemplate;
@Autowired
private ConnectionFactory connectionFactory;
@@ -49,7 +49,8 @@ public class SampleAmqpSimpleApplication {
@Bean
public SimpleMessageListenerContainer container() {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(
this.connectionFactory);
Object listener = new Object() {
@SuppressWarnings("unused")
public void handleMessage(String foo) {
@@ -62,7 +63,6 @@ public class SampleAmqpSimpleApplication {
return container;
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleAmqpSimpleApplication.class, args);
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.sample.amqp;
import javax.annotation.PostConstruct;
@@ -15,15 +31,15 @@ public class Sender {
@Autowired
private AmqpAdmin amqpAdmin;
@PostConstruct
public void setUpQueue() {
amqpAdmin.declareQueue(new Queue("foo"));
this.amqpAdmin.declareQueue(new Queue("foo"));
}
@Scheduled(fixedDelay=1000L)
@Scheduled(fixedDelay = 1000L)
public void send() {
rabbitTemplate.convertAndSend("foo","hello");
this.rabbitTemplate.convertAndSend("foo", "hello");
}
}