Skip to content

Commit

Permalink
Update the Spring sample according to Mark Fisher's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
dpw committed Aug 8, 2011
1 parent e800014 commit 6037f75
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ public String home(Model model) {

@RequestMapping(value = "/publish", method=RequestMethod.POST)
public String publish(Model model, Message message) {
amqpTemplate.convertAndSend(message.getValue());
// Send a message to the "messages" queue
amqpTemplate.convertAndSend("messages", message.getValue());
model.addAttribute("published", true);
return home(model);
}

@RequestMapping(value = "/get", method=RequestMethod.POST)
public String get(Model model) {
String message = (String)amqpTemplate.receiveAndConvert();
// Receive a message from the "messages" queue
String message = (String)amqpTemplate.receiveAndConvert("messages");
if (message != null)
model.addAttribute("got", message);
else
Expand Down

This file was deleted.

21 changes: 19 additions & 2 deletions spring/src/main/webapp/WEB-INF/spring/servlet-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:cloud="http://schema.cloudfoundry.org/spring"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd
http://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.7.xsd">
<context:component-scan base-package="com.rabbitmq.cftutorial.simple"/>
<mvc:annotation-driven/>
</beans>

<!-- Obtain a connection to the RabbitMQ via cloudfoundry-runtime: -->
<cloud:rabbit-connection-factory id="connectionFactory"/>

<!-- Set up the AmqpTemplate/RabbitTemplate: -->
<rabbit:template connection-factory="connectionFactory"/>

<!-- Request that queues, exchanges and bindings be automatically
declared on the broker: -->
<rabbit:admin connection-factory="connectionFactory"/>

<!-- Declare the "messages" queue: -->
<rabbit:queue name="messages" durable="true"/>
</beans>

0 comments on commit 6037f75

Please sign in to comment.