• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DefaultBinding类的典型用法和代码示例

java 2次浏览

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

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

示例1: doRegisterConsumer

点赞 3

import org.springframework.cloud.stream.binder.DefaultBinding; //导入依赖的package包/类
private Binding<MessageChannel> doRegisterConsumer(String bindingName, String group, String channelName, MessageChannel moduleInputChannel,
		MessageProducerSupport adapter, final ConsumerProperties properties) {
	DirectChannel bridgeToModuleChannel = new DirectChannel();
	bridgeToModuleChannel.setBeanFactory(this.getBeanFactory());
	bridgeToModuleChannel.setBeanName(channelName + ".bridge");
	MessageChannel bridgeInputChannel = addRetryIfNeeded(channelName, bridgeToModuleChannel, properties);
	adapter.setOutputChannel(bridgeInputChannel);
	adapter.setBeanName("inbound." + channelName);
	adapter.afterPropertiesSet();
	DefaultBinding<MessageChannel> consumerBinding = new DefaultBinding<MessageChannel>(bindingName, group, moduleInputChannel, adapter) {

		@Override
		protected void afterUnbind() {
			String key = RedisMessageChannelBinder.CONSUMER_GROUPS_KEY_PREFIX + getName();
			RedisMessageChannelBinder.this.redisOperations.boundZSetOps(key).incrementScore(getGroup(), -1);
		}
	};
	ReceivingHandler convertingBridge = new ReceivingHandler(properties);
	convertingBridge.setOutputChannel(moduleInputChannel);
	convertingBridge.setBeanName(channelName + ".bridge.handler");
	convertingBridge.afterPropertiesSet();
	bridgeToModuleChannel.subscribe(convertingBridge);
	this.redisOperations.boundZSetOps(CONSUMER_GROUPS_KEY_PREFIX + bindingName).incrementScore(group, 1);
	adapter.start();
	return consumerBinding;
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-stream-binder-redis,
代码行数:27,
代码来源:RedisMessageChannelBinder.java

示例2: doRegisterProducer

点赞 3

import org.springframework.cloud.stream.binder.DefaultBinding; //导入依赖的package包/类
private Binding<MessageChannel> doRegisterProducer(final String name, MessageChannel moduleOutputChannel,
		ProducerProperties properties) {
	Assert.isInstanceOf(SubscribableChannel.class, moduleOutputChannel);
	MessageHandler handler = new SendingHandler(name, properties);
	EventDrivenConsumer consumer = new EventDrivenConsumer((SubscribableChannel) moduleOutputChannel, handler);
	consumer.setBeanFactory(this.getBeanFactory());
	consumer.setBeanName("outbound." + name);
	consumer.afterPropertiesSet();
	DefaultBinding<MessageChannel> producerBinding =
			new DefaultBinding<>(name, null, moduleOutputChannel, consumer);
	String[] requiredGroups = properties.getRequiredGroups();
	if (!ObjectUtils.isEmpty(requiredGroups)) {
		for (String group : requiredGroups) {
			this.redisOperations.boundZSetOps(CONSUMER_GROUPS_KEY_PREFIX + name).incrementScore(group, 1);
		}
	}
	consumer.start();
	return producerBinding;
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-stream-binder-redis,
代码行数:20,
代码来源:RedisMessageChannelBinder.java

示例3: doBindConsumer

点赞 2

import org.springframework.cloud.stream.binder.DefaultBinding; //导入依赖的package包/类
@Override
protected Binding<KStream<Object, Object>> doBindConsumer(String name, String group,
														KStream<Object, Object> inputTarget, ExtendedConsumerProperties<KStreamConsumerProperties> properties) {

	ExtendedConsumerProperties<KafkaConsumerProperties> extendedConsumerProperties = new ExtendedConsumerProperties<KafkaConsumerProperties>(
			new KafkaConsumerProperties());
	this.kafkaTopicProvisioner.provisionConsumerDestination(name, group, extendedConsumerProperties);
	return new DefaultBinding<>(name, group, inputTarget, null);
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-stream-binder-kafka,
代码行数:10,
代码来源:KStreamBinder.java

示例4: doBindConsumer

点赞 2

import org.springframework.cloud.stream.binder.DefaultBinding; //导入依赖的package包/类
@Override
protected Binding<MessageChannel> doBindConsumer(String name, String group, MessageChannel inputChannel, ConsumerProperties properties) {
	ConsulInboundMessageProducer messageProducer = new ConsulInboundMessageProducer(this.eventService);
	messageProducer.setOutputChannel(inputChannel);
	messageProducer.setBeanFactory(this.getBeanFactory());
	messageProducer.afterPropertiesSet();
	messageProducer.start();

	return new DefaultBinding<>(name, group, inputChannel, messageProducer);
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-consul,
代码行数:11,
代码来源:ConsulBinder.java

示例5: doBindProducer

点赞 2

import org.springframework.cloud.stream.binder.DefaultBinding; //导入依赖的package包/类
@Override
protected Binding<MessageChannel> doBindProducer(String name, MessageChannel channel, ProducerProperties properties) {
	Assert.isInstanceOf(SubscribableChannel.class, channel);

	logger.debug("Binding Consul client to eventName " + name);
	ConsulSendingHandler sendingHandler = new ConsulSendingHandler(this.eventService.getConsulClient(), name);

	EventDrivenConsumer consumer = new EventDrivenConsumer((SubscribableChannel) channel, sendingHandler);
	consumer.setBeanFactory(getBeanFactory());
	consumer.setBeanName(String.format(BEAN_NAME_TEMPLATE, name));
	consumer.afterPropertiesSet();
	consumer.start();

	return new DefaultBinding<>(name, null, channel, consumer);
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-consul,
代码行数:16,
代码来源:ConsulBinder.java

示例6: doBindProducer

点赞 2

import org.springframework.cloud.stream.binder.DefaultBinding; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected Binding<KStream<Object, Object>> doBindProducer(String name, KStream<Object, Object> outboundBindTarget,
														ExtendedProducerProperties<KStreamProducerProperties> properties) {
	ExtendedProducerProperties<KafkaProducerProperties> extendedProducerProperties = new ExtendedProducerProperties<KafkaProducerProperties>(
			new KafkaProducerProperties());
	this.kafkaTopicProvisioner.provisionProducerDestination(name, extendedProducerProperties);
	outboundBindTarget = outboundBindTarget
			.map((k, v) -> KeyValue.pair(k, ((Message<Object>) v).getPayload()));

	Serde<?> keySerde = Serdes.ByteArray();
	Serde<?> valueSerde = Serdes.ByteArray();
	if (properties.isUseNativeEncoding()) {
		outboundBindTarget.to(name, Produced.with((Serde<Object>) keySerde, (Serde<Object>) valueSerde));
	}
	else {
		try {
			if (StringUtils.hasText(properties.getExtension().getKeySerde())) {
				keySerde = Utils.newInstance(properties.getExtension().getKeySerde(), Serde.class);
				if (keySerde instanceof Configurable) {
					((Configurable) keySerde).configure(streamsConfig.originals());
				}
			}
			else {
				keySerde = this.binderConfigurationProperties.getConfiguration().containsKey("key.serde") ?
						Utils.newInstance(this.binderConfigurationProperties.getConfiguration().get("key.serde"), Serde.class) : Serdes.ByteArray();
			}

			if (StringUtils.hasText(properties.getExtension().getValueSerde())) {
				valueSerde = Utils.newInstance(properties.getExtension().getValueSerde(), Serde.class);
				if (valueSerde instanceof Configurable) {
					((Configurable) valueSerde).configure(streamsConfig.originals());
				}
			}
			outboundBindTarget.to(name, Produced.with((Serde<Object>) keySerde, (Serde<Object>) valueSerde));
		} catch (ClassNotFoundException e) {
			throw new IllegalStateException("Serde class not found: ", e);
		}
	}
	return new DefaultBinding<>(name, null, outboundBindTarget, null);
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-stream-binder-kafka,
代码行数:42,
代码来源:KStreamBinder.java

示例7: toBinding

点赞 2

import org.springframework.cloud.stream.binder.DefaultBinding; //导入依赖的package包/类
private DefaultBinding<MessageChannel> toBinding(String name, MessageChannel channel, EventDrivenConsumer consumer) {
    return new DefaultBinding<>(name, null, channel, consumer);
}
 

开发者ID:jmnarloch,
项目名称:hermes-spring-cloud-starter-stream,
代码行数:4,
代码来源:HermesClientBinder.java

示例8: doBindConsumer

点赞 2

import org.springframework.cloud.stream.binder.DefaultBinding; //导入依赖的package包/类
@Override
protected Binding<MessageChannel> doBindConsumer(String name, String group,
		MessageChannel inputTarget, ConsumerProperties properties) {
	controller.bind(name, group, inputTarget);
	return new DefaultBinding<MessageChannel>(name, group, inputTarget, null);
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-function,
代码行数:7,
代码来源:ServletMessageChannelBinder.java

示例9: doBindProducer

点赞 2

import org.springframework.cloud.stream.binder.DefaultBinding; //导入依赖的package包/类
@Override
protected Binding<MessageChannel> doBindProducer(String name,
		MessageChannel outboundBindTarget, ProducerProperties properties) {
	controller.subscribe(name, (SubscribableChannel) outboundBindTarget);
	return new DefaultBinding<MessageChannel>(name, null, outboundBindTarget, null);
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-function,
代码行数:7,
代码来源:ServletMessageChannelBinder.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)