本文整理匯總了Java中org.springframework.amqp.core.BindingBuilder類的典型用法代碼示例。如果您正苦於以下問題:Java BindingBuilder類的具體用法?Java BindingBuilder怎麽用?Java BindingBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BindingBuilder類屬於org.springframework.amqp.core包,在下文中一共展示了BindingBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkRabbitMQAMQPProtocol
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
public String checkRabbitMQAMQPProtocol(String messageAsString,
String url,
String user,
String password,
String vhost) throws Exception {
org.springframework.amqp.rabbit.connection.CachingConnectionFactory cf =
new org.springframework.amqp.rabbit.connection.CachingConnectionFactory();
URL formattedUrl = new URL("http://" + url);
cf.setHost(formattedUrl.getHost());
cf.setPort(formattedUrl.getPort());
cf.setUsername(user);
cf.setPassword(password);
cf.setVirtualHost(vhost);
RabbitAdmin admin = new RabbitAdmin(cf);
org.springframework.amqp.core.Queue queue = new org.springframework.amqp.core.Queue("myQueue");
admin.declareQueue(queue);
TopicExchange exchange = new TopicExchange("myExchange");
admin.declareExchange(exchange);
admin.declareBinding(
BindingBuilder.bind(queue).to(exchange).with("foo.*"));
RabbitTemplate template = new RabbitTemplate(cf);
template.convertAndSend("myExchange", "foo.bar", messageAsString);
String receivedMessage = template.receiveAndConvert("myQueue").toString();
return receivedMessage;
}
示例2: registerListenerEndpoint
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
private void registerListenerEndpoint(RabbitListenerEndpointRegistrar aRegistrar, Queue aQueue, Exchange aExchange, int aConcurrency, Object aDelegate, String aMethodName) {
admin(connectionFactory).declareQueue(aQueue);
admin(connectionFactory).declareBinding(BindingBuilder.bind(aQueue)
.to(aExchange)
.with(aQueue.getName())
.noargs());
MessageListenerAdapter messageListener = new MessageListenerAdapter(aDelegate);
messageListener.setMessageConverter(jacksonAmqpMessageConverter(objectMapper));
messageListener.setDefaultListenerMethod(aMethodName);
SimpleRabbitListenerEndpoint endpoint = new SimpleRabbitListenerEndpoint();
endpoint.setId(aQueue.getName()+"Endpoint");
endpoint.setQueueNames(aQueue.getName());
endpoint.setMessageListener(messageListener);
aRegistrar.registerEndpoint(endpoint,createContainerFactory(aConcurrency));
}
示例3: declareExchange
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Test
public void declareExchange() throws Exception {
RabbitAdmin bean = (RabbitAdmin) applicationContext
.getBean("rabbitAdmin");
//
String EXCHANGE_NAME = "TEST_EXCHANGE";
TopicExchange exchange = new TopicExchange(EXCHANGE_NAME);
bean.declareExchange(exchange);
//
String QUEUE_NAME = "TEST_EXCHANGE";
Queue queue = new Queue(QUEUE_NAME, false);
bean.declareQueue(queue);
//
// binding
Binding binding = BindingBuilder.bind(queue).to(exchange)
.with(QUEUE_NAME);
System.out.println(binding);
}
示例4: ticketServiceRequestQueueBinding
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Bean
public Binding ticketServiceRequestQueueBinding()
{
final StringBuilder builder = new StringBuilder();
builder.append(BINDING_TICKET_REQUEST);
String binding = builder.toString();
return BindingBuilder.bind(ticketServiceRequestQueue()).to(ticketServiceRequestExchange()).with(binding);
}
開發者ID:dellemc-symphony,項目名稱:ticketing-service-paqx-parent-sample,代碼行數:12,代碼來源:TicketingServiceRabbitConfig.java
示例5: schedulingRunner
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Bean
public CommandLineRunner schedulingRunner(final TaskExecutor executor, final AmqpAdmin amqpAdmin, final ProcessService processStarter) {
return args -> executor.execute(() -> {
// Init Rabbit exchange and queue
amqpAdmin.deleteExchange(EXCHANGE);
TopicExchange exchange = new TopicExchange(EXCHANGE);
amqpAdmin.declareExchange(exchange);
Queue queue = new Queue("flowable-history-jobs", true);
amqpAdmin.declareQueue(queue);
amqpAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("flowable-history-jobs"));
});
}
示例6: testConsumerPropertiesWithUserInfrastructureNoBind
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Test
public void testConsumerPropertiesWithUserInfrastructureNoBind() throws Exception {
RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource());
Queue queue = new Queue("propsUser1.infra");
admin.declareQueue(queue);
DirectExchange exchange = new DirectExchange("propsUser1");
admin.declareExchange(exchange);
admin.declareBinding(BindingBuilder.bind(queue).to(exchange).with("foo"));
RabbitTestBinder binder = getBinder();
ExtendedConsumerProperties<RabbitConsumerProperties> properties = createConsumerProperties();
properties.getExtension().setDeclareExchange(false);
properties.getExtension().setBindQueue(false);
Binding<MessageChannel> consumerBinding = binder.bindConsumer("propsUser1", "infra",
createBindableChannel("input", new BindingProperties()), properties);
Lifecycle endpoint = extractEndpoint(consumerBinding);
SimpleMessageListenerContainer container = TestUtils.getPropertyValue(endpoint, "messageListenerContainer",
SimpleMessageListenerContainer.class);
assertThat(TestUtils.getPropertyValue(container, "missingQueuesFatal", Boolean.class)).isFalse();
assertThat(container.isRunning()).isTrue();
consumerBinding.unbind();
assertThat(container.isRunning()).isFalse();
RabbitManagementTemplate rmt = new RabbitManagementTemplate();
List<org.springframework.amqp.core.Binding> bindings = rmt.getBindingsForExchange("/", exchange.getName());
assertThat(bindings.size()).isEqualTo(1);
}
示例7: testRoutingKeyExpression
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Test
public void testRoutingKeyExpression() throws Exception {
RabbitTestBinder binder = getBinder();
ExtendedProducerProperties<RabbitProducerProperties> producerProperties = createProducerProperties();
producerProperties.getExtension().setRoutingKeyExpression("payload.field");
DirectChannel output = createBindableChannel("output", createProducerBindingProperties(producerProperties));
output.setBeanName("rkeProducer");
Binding<MessageChannel> producerBinding = binder.bindProducer("rke", output, producerProperties);
RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource());
Queue queue = new AnonymousQueue();
TopicExchange exchange = new TopicExchange("rke");
org.springframework.amqp.core.Binding binding = BindingBuilder.bind(queue).to(exchange).with("rkeTest");
admin.declareQueue(queue);
admin.declareBinding(binding);
output.addInterceptor(new ChannelInterceptorAdapter() {
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
assertThat(message.getHeaders().get(RabbitExpressionEvaluatingInterceptor.ROUTING_KEY_HEADER))
.isEqualTo("rkeTest");
return message;
}
});
output.send(new GenericMessage<>(new Pojo("rkeTest")));
Object out = spyOn(queue.getName()).receive(false);
assertThat(out).isInstanceOf(byte[].class);
assertThat(new String((byte[]) out, StandardCharsets.UTF_8)).isEqualTo("{\"field\":\"rkeTest\"}");
producerBinding.unbind();
}
示例8: autoBindDLQ
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
/**
* If so requested, declare the DLX/DLQ and bind it. The DLQ is bound to the DLX with a routing key of the original
* queue name because we use default exchange routing by queue name for the original message.
* @param baseQueueName The base name for the queue (including the binder prefix, if any).
* @param routingKey The routing key for the queue.
* @param properties the properties.
*/
private void autoBindDLQ(final String baseQueueName, String routingKey, RabbitCommonProperties properties) {
boolean autoBindDlq = properties.isAutoBindDlq();
if (this.logger.isDebugEnabled()) {
this.logger.debug("autoBindDLQ=" + autoBindDlq
+ " for: " + baseQueueName);
}
if (autoBindDlq) {
String dlqName;
if (properties.getDeadLetterQueueName() == null) {
dlqName = constructDLQName(baseQueueName);
}
else {
dlqName = properties.getDeadLetterQueueName();
}
Queue dlq = new Queue(dlqName, true, false, false, queueArgs(dlqName, properties, true));
declareQueue(dlqName, dlq);
String dlxName = deadLetterExchangeName(properties);
final DirectExchange dlx = new DirectExchange(dlxName);
declareExchange(dlxName, dlx);
BindingBuilder.DirectExchangeRoutingKeyConfigurer bindingBuilder = BindingBuilder.bind(dlq).to(dlx);
Binding dlqBinding;
if (properties.getDeadLetterRoutingKey() == null) {
dlqBinding = bindingBuilder.with(routingKey);
}
else {
dlqBinding = bindingBuilder.with(properties.getDeadLetterRoutingKey());
}
declareBinding(dlqName, dlqBinding);
if (properties instanceof RabbitConsumerProperties &&
((RabbitConsumerProperties) properties).isRepublishToDlq()) {
/*
* Also bind with the base queue name when republishToDlq is used, which does not know about
* partitioning
*/
declareBinding(dlqName, BindingBuilder.bind(dlq).to(dlx).with(baseQueueName));
}
}
}
開發者ID:spring-cloud,項目名稱:spring-cloud-stream-binder-rabbit,代碼行數:46,代碼來源:RabbitExchangeQueueProvisioner.java
示例9: bindReplicationBroadcast
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Bean
public Binding bindReplicationBroadcast(Queue replicationQueue) {
return BindingBuilder
.bind(replicationQueue)
.to(new DirectExchange(replicationExchange))
.with(broadcastKey);
}
示例10: bindReplicationUnicast
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Bean
public Binding bindReplicationUnicast(Queue replicationQueue) {
return BindingBuilder
.bind(replicationQueue)
.to(new DirectExchange(replicationExchange))
.with(nodeId);
}
示例11: bindReplicationUnicast
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Bean
public Binding bindReplicationUnicast(Queue replicationQueue) {
return BindingBuilder
.bind(replicationQueue)
.to(new DirectExchange(replicationExchange))
.with(testNodeId);
}
示例12: bindingReplication
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Bean
public Binding bindingReplication(Queue replicationQueue, DirectExchange replicationExchange) {
return BindingBuilder
.bind(replicationQueue)
.to(replicationExchange)
.with(broadcastKey);
}
示例13: binding
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Bean
List<Binding> binding(TopicExchange exchange) {
List<Binding> bindings = new ArrayList<>();
queues().forEach(queue -> {
bindings.add(BindingBuilder.bind(queue).to(exchange).with(queue.getName()));
});
return bindings;
}
示例14: prepareQueues
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Bean
public InitializingBean prepareQueues(AmqpAdmin amqpAdmin) {
return () -> {
Queue queue = new Queue(NOTIFICATIONS, true);
DirectExchange exchange = new DirectExchange(NOTIFICATIONS);
Binding binding = BindingBuilder.bind(queue).to(exchange).with(NOTIFICATIONS);
amqpAdmin.declareQueue(queue);
amqpAdmin.declareExchange(exchange);
amqpAdmin.declareBinding(binding);
};
}
示例15: prepareQueues
import org.springframework.amqp.core.BindingBuilder; //導入依賴的package包/類
@Bean
public InitializingBean prepareQueues(AmqpAdmin amqpAdmin) {
return () -> {
Queue queue = new Queue(this.echoQueueAndExchangeName, true);
DirectExchange exchange = new DirectExchange(this.echoQueueAndExchangeName);
Binding binding = BindingBuilder.bind(queue).to(exchange)
.with(this.echoQueueAndExchangeName);
amqpAdmin.declareQueue(queue);
amqpAdmin.declareExchange(exchange);
amqpAdmin.declareBinding(binding);
};
}