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


Java Exchange类代码示例

本文整理汇总了Java中org.springframework.amqp.core.Exchange的典型用法代码示例。如果您正苦于以下问题:Java Exchange类的具体用法?Java Exchange怎么用?Java Exchange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Exchange类属于org.springframework.amqp.core包,在下文中一共展示了Exchange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerListenerEndpoint

import org.springframework.amqp.core.Exchange; //导入依赖的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));
}
 
开发者ID:creactiviti,项目名称:piper,代码行数:19,代码来源:AmqpMessengerConfiguration.java

示例2: buildExchange

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
private Exchange buildExchange(RabbitCommonProperties properties, String exchangeName) {
	try {
		ExchangeBuilder builder = new ExchangeBuilder(exchangeName, properties.getExchangeType());
		builder.durable(properties.isExchangeDurable());
		if (properties.isExchangeAutoDelete()) {
			builder.autoDelete();
		}
		if (properties.isDelayedExchange()) {
			builder.delayed();
		}
		return builder.build();
	}
	catch (Exception e) {
		throw new ProvisioningException("Failed to create exchange object", e);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:17,代码来源:RabbitExchangeQueueProvisioner.java

示例3: destroy

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void destroy() throws Exception {
    if (deleted) {
        L.debug(R.getString("D-AMQP-INITIALIZER#0002"));
        Map<String, Exchange> exchanges = context.getBeansOfType(Exchange.class);
        for (Map.Entry<String, Exchange> exchange : exchanges.entrySet()) {
            Exchange e = exchange.getValue();
            L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0006"), Maps.hash("name", e.getName())));
            admin.deleteExchange(e.getName());
        }
        Map<String, Queue> queues = context.getBeansOfType(Queue.class);
        for (Map.Entry<String, Queue> queue : queues.entrySet()) {
            Queue q = queue.getValue();
            L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0007"), Maps.hash("name", q.getName())));
            admin.deleteQueue(q.getName());
        }
    } else {
        L.debug(R.getString("D-AMQP-INITIALIZER#0008"));
    }
}
 
开发者ID:ctc-g,项目名称:sinavi-jfw,代码行数:24,代码来源:RabbitMQInitializer.java

示例4: TicketingServiceProducerImpl

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
/**
 * Constructor
 * @param rabbitTemplate Rabbit Template
 * @param ticketServiceResponseExchange Event Exchange
 */
public TicketingServiceProducerImpl(final RabbitTemplate rabbitTemplate, final Exchange ticketServiceResponseExchange)
{
    this.ticketServiceResponseExchange = ticketServiceResponseExchange;
    this.rabbitTemplate = rabbitTemplate;
 
}
 
开发者ID:dellemc-symphony,项目名称:ticketing-service-paqx-parent-sample,代码行数:12,代码来源:TicketingServiceProducerImpl.java

示例5: tasksExchange

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
@Bean
Exchange tasksExchange () {
  return ExchangeBuilder.directExchange(Exchanges.TASKS)
                        .delayed()
                        .durable(true)
                        .build();
}
 
开发者ID:creactiviti,项目名称:piper,代码行数:8,代码来源:AmqpMessengerConfiguration.java

示例6: declareConsumerBindings

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
private Binding declareConsumerBindings(String name, ExtendedConsumerProperties<RabbitConsumerProperties> properties,
									Exchange exchange, boolean partitioned, Queue queue) {
	if (partitioned) {
		return partitionedBinding(name, exchange, queue, properties.getExtension(), properties.getInstanceIndex());
	}
	else {
		return notPartitionedBinding(exchange, queue, properties.getExtension());
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:10,代码来源:RabbitExchangeQueueProvisioner.java

示例7: call

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
@Override
public RabbitTemplate call() throws Exception {
    ConnectionFactory connectionFactory = connectionFactoryProvider.getObject();
    Assert.notNull(connectionFactory, "connectionFactory is null");

    if(exchangeFactory != null) {
        Exchange exchange = exchangeFactory.call();
        if(exchange != null) {
            RabbitAdmin admin = new RabbitAdmin(connectionFactory);
            admin.declareExchange(exchange);
        }
    }

    return new RabbitTemplate(connectionFactory);
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:16,代码来源:AmqpReporter.java

示例8: afterPropertiesSet

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void afterPropertiesSet() throws Exception {
    Args.checkNotNull(admin, R.getObject("E-AMQP-INITIALIZER#0001"));
    L.debug(R.getString("D-AMQP-INITIALIZER#0001"));
    Map<String, Exchange> exchanges = context.getBeansOfType(Exchange.class);
    for (Map.Entry<String, Exchange> exchange : exchanges.entrySet()) {
        Exchange e = exchange.getValue();
        L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0003"), Maps.hash("name", e.getName())));
        admin.declareExchange(e);
    }
    Map<String, Queue> queues = context.getBeansOfType(Queue.class);
    for (Map.Entry<String, Queue> queue : queues.entrySet()) {
        Queue q = queue.getValue();
        L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0004"), Maps.hash("name", q.getName())));
        admin.declareQueue(q);
    }
    Map<String, Binding> bindings = context.getBeansOfType(Binding.class);
    for (Map.Entry<String, Binding> binding : bindings.entrySet()) {
        Binding b = binding.getValue();
        L.debug(Strings.substitute(R.getString("D-AMQP-INITIALIZER#0005"), 
            Maps.hash("ename", b.getExchange())
                .map("qname", b.getDestination())
                .map("key", b.getRoutingKey())));
        admin.declareBinding(b);
    }
}
 
开发者ID:ctc-g,项目名称:sinavi-jfw,代码行数:30,代码来源:RabbitMQInitializer.java

示例9: QueueBinding

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
public QueueBinding(Exchange exchange, Queue queue, String routingKey) {
    super(queue.getName(), DestinationType.QUEUE, exchange.getName(), routingKey, Collections.<String, Object>emptyMap());
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:4,代码来源:QueueBinding.java

示例10: controlExchange

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
@Bean
Exchange controlExchange () {
  return ExchangeBuilder.fanoutExchange(Exchanges.CONTROL)
                        .durable(true)
                        .build();
}
 
开发者ID:creactiviti,项目名称:piper,代码行数:7,代码来源:AmqpMessengerConfiguration.java

示例11: testConsumerPropertiesWithUserInfrastructureCustomExchangeAndRK

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
@Test
	public void testConsumerPropertiesWithUserInfrastructureCustomExchangeAndRK() throws Exception {
		RabbitTestBinder binder = getBinder();
		ExtendedConsumerProperties<RabbitConsumerProperties> properties = createConsumerProperties();
		properties.getExtension().setExchangeType(ExchangeTypes.DIRECT);
		properties.getExtension().setBindingRoutingKey("foo");
		properties.getExtension().setQueueNameGroupOnly(true);
//		properties.getExtension().setDelayedExchange(true); // requires delayed message exchange plugin; tested locally

		String group = "infra";
		Binding<MessageChannel> consumerBinding = binder.bindConsumer("propsUser2", group,
				createBindableChannel("input", new BindingProperties()), properties);
		Lifecycle endpoint = extractEndpoint(consumerBinding);
		SimpleMessageListenerContainer container = TestUtils.getPropertyValue(endpoint, "messageListenerContainer",
				SimpleMessageListenerContainer.class);
		assertThat(container.isRunning()).isTrue();
		consumerBinding.unbind();
		assertThat(container.isRunning()).isFalse();
		assertThat(container.getQueueNames()[0]).isEqualTo(group);
		RabbitManagementTemplate rmt = new RabbitManagementTemplate();
		List<org.springframework.amqp.core.Binding> bindings = rmt.getBindingsForExchange("/", "propsUser2");
		int n = 0;
		while (n++ < 100 && bindings == null || bindings.size() < 1) {
			Thread.sleep(100);
			bindings = rmt.getBindingsForExchange("/", "propsUser2");
		}
		assertThat(bindings.size()).isEqualTo(1);
		assertThat(bindings.get(0).getExchange()).isEqualTo("propsUser2");
		assertThat(bindings.get(0).getDestination()).isEqualTo(group);
		assertThat(bindings.get(0).getRoutingKey()).isEqualTo("foo");

//		// TODO: AMQP-696
//		// Exchange exchange = rmt.getExchange("propsUser2");
//		ExchangeInfo ei = rmt.getClient().getExchange("/", "propsUser2"); // requires delayed message exchange plugin
//		assertThat(ei.getType()).isEqualTo("x-delayed-message");
//		assertThat(ei.getArguments().get("x-delayed-type")).isEqualTo("direct");

		Exchange exchange = rmt.getExchange("propsUser2");
		while (n++ < 100 && exchange == null) {
			Thread.sleep(100);
			exchange = rmt.getExchange("propsUser2");
		}
		assertThat(exchange).isInstanceOf(DirectExchange.class);
		assertThat(exchange.isDurable()).isEqualTo(true);
		assertThat(exchange.isAutoDelete()).isEqualTo(false);
	}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:47,代码来源:RabbitBinderTests.java

示例12: RabbitProducerDestination

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
RabbitProducerDestination(Exchange exchange, Binding binding) {
	Assert.notNull(exchange, "exchange must not be null");
	this.exchange = exchange;
	this.binding = binding;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:6,代码来源:RabbitExchangeQueueProvisioner.java

示例13: eventExchange

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
@Bean
Exchange eventExchange() {
  return new FanoutExchange(properties.getAmqp().getExchange().getEvent());
}
 
开发者ID:holisticon,项目名称:camunda-bpm-cloud,代码行数:5,代码来源:CamundaCloudAmqpAutoConfiguration.java

示例14: responseExchange

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
@Qualifier("response-exchange")
@Bean
protected Exchange responseExchange() {
    return new TopicExchange(messagingConfiguration.getResponseExchangeName(), true, false);
}
 
开发者ID:zeroDivisible,项目名称:spring-rabbitmq-example,代码行数:6,代码来源:AsyncResponseConfiguration.java

示例15: pongExchange

import org.springframework.amqp.core.Exchange; //导入依赖的package包/类
@Bean
public Exchange pongExchange() {
    return new TopicExchange("pong-exchange", true, false);
}
 
开发者ID:zeroDivisible,项目名称:spring-rabbitmq-example,代码行数:5,代码来源:PingConfiguration.java


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