当前位置: 首页>>代码示例>>Java>>正文


Java TopicExchange类代码示例

本文整理汇总了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;
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:26,代码来源:CheckBrokerConnectionUtils.java

示例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));
}
 
开发者ID:openbaton,项目名称:generic-vnfm,代码行数:19,代码来源:EMSConfiguration.java

示例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);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:19,代码来源:ApplicationContextRabbitmqTest.java

示例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"));
      
    });
}
 
开发者ID:flowable,项目名称:flowable-examples,代码行数:15,代码来源:ProcessApplication.java

示例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);
}
 
开发者ID:sem2nawara,项目名称:acme-solution,代码行数:8,代码来源:RabbitConfigurer.java

示例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();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:37,代码来源:RabbitBinderTests.java

示例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;
}
 
开发者ID:abixen,项目名称:abixen-platform,代码行数:11,代码来源:PlatformRabbitMQConfiguration.java

示例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");
}
 
开发者ID:openbaton,项目名称:openbaton-libs,代码行数:9,代码来源:RabbitConfiguration.java

示例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));
}
 
开发者ID:openbaton,项目名称:openbaton-libs,代码行数:16,代码来源:VnfmSpringHelperRabbit.java

示例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);
}
 
开发者ID:the-james-burton,项目名称:the-turbine,代码行数:21,代码来源:AmqpSetup.java

示例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());
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:11,代码来源:RabbitMQConfig.java

示例13: topicExchange

import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@Bean
TopicExchange topicExchange() {
	return new TopicExchange(X_TOPIC_LOGS);
}
 
开发者ID:MikeQin,项目名称:spring-boot-vaadin-rabbitmq-pipeline-demo,代码行数:5,代码来源:AppConfig.java

示例14: exchange

import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@Bean
TopicExchange exchange() {
	return new TopicExchange("notifications");
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:5,代码来源:SenderSmsApplication.java

示例15: binding

import org.springframework.amqp.core.TopicExchange; //导入依赖的package包/类
@Bean
Binding binding(Queue queue, TopicExchange exchange) {
	return BindingBuilder.bind(queue).to(exchange).with(queueName);
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:5,代码来源:SenderSmsApplication.java


注:本文中的org.springframework.amqp.core.TopicExchange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。