Skip to content

Commit

Permalink
Fix samples to accommodate changes to XSD
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Mar 24, 2011
1 parent dcab11a commit a0074a6
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 33 deletions.
Expand Up @@ -13,7 +13,7 @@ public class ConsumerConfiguration extends HelloWorldConfiguration {
public SimpleMessageListenerContainer listenerContainer() {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(connectionFactory());
container.setQueueName(this.helloWorldQueueName);
container.setQueueNames(this.helloWorldQueueName);
container.setMessageListener(new MessageListenerAdapter(new HelloWorldHandler()));
return container;
}
Expand Down
4 changes: 2 additions & 2 deletions stocks/src/main/resources/log4j.properties
Expand Up @@ -4,8 +4,8 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

#log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
log4j.appender.stdout.layout.ConversionPattern=%-5p [%40.40c{4}]: %m%n
log4j.appender.stdout.layout.ConversionPattern=%-5p %8t [%40.40c{4}]: %m%n

#log4j.category.org.springframework.amqp.rabbit=DEBUG
log4j.category.org.springframework.amqp.rabbit=DEBUG
log4j.category.org.springframework.beans.factory=INFO

14 changes: 7 additions & 7 deletions stocks/src/main/resources/servlet-config.xml
Expand Up @@ -18,31 +18,31 @@
<property name="defaultReplyToQueue" ref="tradeQueue" />
</bean>

<rabbit:queue name="tradeQueue" />
<rabbit:queue id="tradeQueue" />

<rabbit:queue name="marketDataQueue" />
<rabbit:queue id="marketDataQueue" />

<fanout-exchange name="broadcast.responses" xmlns="http://www.springframework.org/schema/rabbit">
<bindings>
<!-- Bind a fanout to an anonymous queue unique for this node, then all nodes in a cluster get the same response -->
<binding queue="tradeQueue" />
</bindings>
</fanout-exchange>

<topic-exchange name="app.stock.marketdata" xmlns="http://www.springframework.org/schema/rabbit">
<bindings>
<!-- Bind to anonymous queue for market data so all nodes configured this way get all quotes -->
<binding queue="marketDataQueue" pattern="${stocks.quote.pattern}" />
</bindings>
</topic-exchange>

<listener-container connection-factory="connectionFactory" message-converter="jsonMessageConverter"
xmlns="http://www.springframework.org/schema/rabbit">
<listener ref="quoteController" method="handleQuote" queue-names="marketDataQueue" />
<listener ref="quoteController" method="handleTrade" queue-names="tradeQueue" />
<listener ref="quoteController" method="handleQuote" queues="marketDataQueue" />
<listener ref="quoteController" method="handleTrade" queues="tradeQueue" />
</listener-container>

<rabbit:admin connection-factory="connectionFactory" />

<bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory" />
<rabbit:admin connection-factory="connectionFactory" auto-startup="true" />

<context:property-placeholder location="classpath:/client.properties" />

Expand Down
@@ -1,23 +1,21 @@
/*
* Copyright 2002-2010 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.
*
* 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.amqp.rabbit.stocks;

import javax.swing.JFrame;

import org.junit.After;
import org.junit.Test;

import org.springframework.amqp.rabbit.stocks.ui.StockController;
Expand All @@ -32,20 +30,29 @@
*/
public class Client {

private ConfigurableApplicationContext context;

public static void main(String[] args) {
new Client().run();
}

@Test
public void run() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("client-bootstrap-config.xml");
context = new ClassPathXmlApplicationContext("client-bootstrap-config.xml");
StockController controller = context.getBean(StockController.class);
JFrame f = new JFrame("Rabbit Stock Demo");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//TODO consider @Configurable
f.add(new StockPanel(controller));
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// TODO consider @Configurable
f.add(new StockPanel(controller));
f.pack();
f.setVisible(true);
}

@After
public void close() {
if (context != null) {
context.close();
}
}

}
Expand Up @@ -16,6 +16,7 @@

package org.springframework.amqp.rabbit.stocks;

import org.junit.After;
import org.junit.Test;

import org.springframework.context.support.ClassPathXmlApplicationContext;
Expand All @@ -27,13 +28,22 @@
*/
public class Server {

private ClassPathXmlApplicationContext context;

public static void main(String[] args) {
new Server().run();
}

@After
public void close() {
if (context != null) {
context.close();
}
}

@Test
public void run() {
new ClassPathXmlApplicationContext("server-bootstrap-config.xml");
context = new ClassPathXmlApplicationContext("server-bootstrap-config.xml");
}

}
Expand Up @@ -23,12 +23,21 @@ public class ServletConfigurationTests {

@Test
public void testContext() throws Exception {

ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext(
"classpath:/server-bootstrap-config.xml");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "classpath:/servlet-config.xml" }, parent);
context.close();
parent.close();

try {

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
new String[] { "classpath:/servlet-config.xml" }, parent);
context.close();

} finally {

parent.close();

}

}
}

0 comments on commit a0074a6

Please sign in to comment.