本文整理汇总了Java中org.springframework.amqp.core.TopicExchange类的典型用法代码示例。如果您正苦于以下问题:Java TopicExchange类的具体用法?Java TopicExchange怎么用?Java TopicExchange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TopicExchange类属于org.springframework.amqp.core包,在下文中一共展示了TopicExchange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRabbitMQAMQPProtocol
import org.springframework.amqp.core.TopicExchange; //导入依赖的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: CapabilityRegistryIntegration
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
/**
* Constructor
* @param capabilityRegistryBindingManager
* @param ticketServiceRequestExchange
* @param ticketServiceResponseExchange
* @param consumerContextConfig
* @param capabilityRegistryControlProducer
*/
@Autowired
public CapabilityRegistryIntegration(final ICapabilityRegistryBindingManager capabilityRegistryBindingManager,
final TopicExchange ticketServiceRequestExchange, final TopicExchange ticketServiceResponseExchange,
final IConsumerContextConfig consumerContextConfig,
final IAmqpCapabilityRegistryControlProducer capabilityRegistryControlProducer) {
notNull(capabilityRegistryBindingManager, "capabilityRegistryBindingManager cannot be null");
notNull(consumerContextConfig, "consumerContextConfig cannot be null");
notNull(capabilityRegistryControlProducer, "capabilityRegistryControlProducer cannot be null");
notNull(ticketServiceRequestExchange, "ticketServiceRequestExchange cannot be null");
notNull(ticketServiceResponseExchange, "ticketServiceResponseExchange cannot be null");
this.capabilityRegistryBindingManager = capabilityRegistryBindingManager;
this.consumerContextConfig = consumerContextConfig;
this.capabilityRegistryControlProducer = capabilityRegistryControlProducer;
this.ticketServiceRequestExchange = ticketServiceRequestExchange;
this.ticketServiceResponseExchange = ticketServiceResponseExchange;
}
开发者ID:dellemc-symphony,项目名称:ticketing-service-paqx-parent-sample,代码行数:27,代码来源:CapabilityRegistryIntegration.java
示例3: init
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@PostConstruct
private void init() {
log.info("Initialization of RabbitConfiguration");
emsConnectionFactory = new CachingConnectionFactory();
((CachingConnectionFactory) emsConnectionFactory).setHost(brokerIp);
((CachingConnectionFactory) emsConnectionFactory).setPort(rabbitPort);
((CachingConnectionFactory) emsConnectionFactory).setUsername(emsRabbitUsername);
((CachingConnectionFactory) emsConnectionFactory).setPassword(emsRabbitPassword);
rabbitAdmin = new RabbitAdmin(emsConnectionFactory);
TopicExchange topicExchange = new TopicExchange("openbaton-exchange");
rabbitAdmin.declareExchange(topicExchange);
log.info("exchange declared");
queueName_emsRegistrator = "ems." + vnfmHelper.getVnfmEndpoint() + ".register";
rabbitAdmin.declareQueue(new Queue(queueName_emsRegistrator, durable, exclusive, autodelete));
}
示例4: declareExchange
import org.springframework.amqp.core.TopicExchange; //导入依赖的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);
}
示例5: schedulingRunner
import org.springframework.amqp.core.TopicExchange; //导入依赖的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: commandExchange
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@Bean
public TopicExchange commandExchange() {
log.info("Creating a durable topic exchange for the command bus with name: {" + this.exchange +
"} and auto-delete is: {" + this.deletable + "}");
return new TopicExchange(this.exchange, true, this.deletable);
}
示例7: testRoutingKeyExpression
import org.springframework.amqp.core.TopicExchange; //导入依赖的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: binding
import org.springframework.amqp.core.TopicExchange; //导入依赖的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;
}
示例9: init
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@PostConstruct
private void init() {
log.info("Initialization of RabbitConfiguration");
rabbitAdmin = new RabbitAdmin(connectionFactory);
TopicExchange topicExchange = new TopicExchange("openbaton-exchange");
rabbitAdmin.declareExchange(topicExchange);
log.info("exchange declared");
}
示例10: init
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@PostConstruct
private void init() throws IOException {
log.info("Initialization of VnfmSpringHelperRabbit");
rabbitAdmin = new RabbitAdmin(connectionFactory);
rabbitAdmin.declareExchange(new TopicExchange("openbaton-exchange"));
rabbitAdmin.declareQueue(
new Queue(RabbitConfiguration.queueName_vnfmRegister, true, exclusive, autodelete));
rabbitAdmin.declareBinding(
new Binding(
RabbitConfiguration.queueName_vnfmRegister,
Binding.DestinationType.QUEUE,
"openbaton-exchange",
RabbitConfiguration.queueName_vnfmRegister,
null));
}
示例11: exchangeTest
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
/**
*
* @param connectionFactory injected by Spring
* @param listenerAdapter injected by Spring
* @return
*/
// @Bean
// SimpleMessageListenerContainer container(ConnectionFactory connectionFactory,
// MessageListenerAdapter listenerAdapterTest) {
// SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
// container.setConnectionFactory(connectionFactory);
// container.setQueueNames(queueTestName);
// container.setMessageListener(listenerAdapterTest);
// return container;
// }
@Bean
TopicExchange exchangeTest() {
return new TopicExchange(exchangeTestName, false, true);
}
示例12: binding
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@Bean
public List<Binding> binding(TopicExchange exchange, List<Queue> queues) {
Map<String, String> queueMap = rabbitmqProperties.getQueues().entrySet().stream()
.map(Map.Entry::getValue)
.collect(Collectors.toMap(RabbitMQ::getBindingQueueName, RabbitMQ::getBindingRoutingKey));
return queues.stream()
.map(queue -> BindingBuilder.bind(queue).to(exchange).with(queueMap.get(queue.getName())))
.collect(Collectors.toList());
}
示例13: topicExchange
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@Bean
TopicExchange topicExchange() {
return new TopicExchange(X_TOPIC_LOGS);
}
示例14: exchange
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@Bean
TopicExchange exchange() {
return new TopicExchange("notifications");
}
示例15: binding
import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@Bean
Binding binding(Queue queue, TopicExchange exchange) {
return BindingBuilder.bind(queue).to(exchange).with(queueName);
}