AMQP-143: from->bind

This commit is contained in:
Dave Syer
2011-04-18 09:41:48 +01:00
parent 3a54f8e4c6
commit 70f2597930
5 changed files with 13 additions and 14 deletions

View File

@@ -29,11 +29,10 @@ import org.springframework.util.Assert;
*/
public final class BindingBuilder {
public static ExchangeConfigurer from(Queue queue) {
public static ExchangeConfigurer bind(Queue queue) {
return new ExchangeConfigurer(queue);
}
public static class ExchangeConfigurer {
private final Queue queue;

View File

@@ -27,25 +27,25 @@ public class BindingBuilderTests {
@Test
public void fanoutBinding() {
Binding binding = BindingBuilder.from(new Queue("q")).to(new FanoutExchange("f"));
Binding binding = BindingBuilder.bind(new Queue("q")).to(new FanoutExchange("f"));
assertNotNull(binding);
}
@Test
public void directBinding() {
Binding binding = BindingBuilder.from(new Queue("q")).to(new DirectExchange("d")).with("r");
Binding binding = BindingBuilder.bind(new Queue("q")).to(new DirectExchange("d")).with("r");
assertNotNull(binding);
}
@Test
public void directBindingWithQueueName() {
Binding binding = BindingBuilder.from(new Queue("q")).to(new DirectExchange("d")).withQueueName();
Binding binding = BindingBuilder.bind(new Queue("q")).to(new DirectExchange("d")).withQueueName();
assertNotNull(binding);
}
@Test
public void topicBinding() {
Binding binding = BindingBuilder.from(new Queue("q")).to(new TopicExchange("t")).with("r");
Binding binding = BindingBuilder.bind(new Queue("q")).to(new TopicExchange("t")).with("r");
assertNotNull(binding);
}

View File

@@ -40,7 +40,7 @@ public class RabbitBindingIntegrationTests {
admin.declareExchange(exchange);
template.setExchange(exchange.getName());
admin.declareBinding(BindingBuilder.from(queue).to(exchange).with("*.end"));
admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("*.end"));
template.execute(new ChannelCallback<Void>() {
public Void doInRabbit(Channel channel) throws Exception {
@@ -79,7 +79,7 @@ public class RabbitBindingIntegrationTests {
final TopicExchange exchange = new TopicExchange("topic");
admin.declareExchange(exchange);
admin.declareBinding(BindingBuilder.from(queue).to(exchange).with("*.end"));
admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("*.end"));
template.execute(new ChannelCallback<Void>() {
public Void doInRabbit(Channel channel) throws Exception {
@@ -119,7 +119,7 @@ public class RabbitBindingIntegrationTests {
admin.declareExchange(exchange);
template.setExchange(exchange.getName());
admin.declareBinding(BindingBuilder.from(queue).to(exchange).with("*.end"));
admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("*.end"));
final RabbitTemplate template = new RabbitTemplate(new CachingConnectionFactory());
template.setExchange(exchange.getName());
@@ -156,7 +156,7 @@ public class RabbitBindingIntegrationTests {
admin.declareExchange(exchange);
template.setExchange(exchange.getName());
admin.declareBinding(BindingBuilder.from(queue).to(exchange).with("*.end"));
admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("*.end"));
template.execute(new ChannelCallback<Void>() {
public Void doInRabbit(Channel channel) throws Exception {
@@ -208,7 +208,7 @@ public class RabbitBindingIntegrationTests {
admin.declareExchange(exchange);
template.setExchange(exchange.getName());
admin.declareBinding(BindingBuilder.from(queue).to(exchange));
admin.declareBinding(BindingBuilder.bind(queue).to(exchange));
template.execute(new ChannelCallback<Void>() {
public Void doInRabbit(Channel channel) throws Exception {

View File

@@ -179,7 +179,7 @@
<para>We also provide a <classname>BindingBuilder</classname> to
facilitate a "fluent API" style.</para>
<programlisting language="java"><![CDATA[Binding b = BindingBuilder.from(someQueue).to(someTopicExchange).with("foo.*");]]></programlisting>
<programlisting language="java"><![CDATA[Binding b = BindingBuilder.bind(someQueue).to(someTopicExchange).with("foo.*");]]></programlisting>
<note>
<para>The BindingBuilder class is shown above for clarity, but this
@@ -813,7 +813,7 @@ public class RabbitClientConfiguration extends AbstractStockAppRabbitConfigurati
*/
@Bean
public Binding marketDataBinding() {
return BindingBuilder.from(
return BindingBuilder.bind(
marketDataQueue()).to(marketDataExchange()).with(marketDataRoutingKey);
}

View File

@@ -313,7 +313,7 @@ private String marketDataRoutingKey;
@Bean
public Binding marketDataBinding() {
return BindingBuilder.from(
return BindingBuilder.bind(
marketDataQueue()).to(marketDataExchange()).with(marketDataRoutingKey);
}]]></programlisting>