• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MessageProducer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createConsumerEndpoint

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Override
protected MessageProducer createConsumerEndpoint(ConsumerDestination destination, String group, ConsumerProperties properties)
		throws Exception {
	ErrorMessageStrategy errorMessageStrategy = new DefaultErrorMessageStrategy();
	SubscribableChannel siBinderInputChannel = ((SpringIntegrationConsumerDestination)destination).getChannel();

	IntegrationMessageListeningContainer messageListenerContainer = new IntegrationMessageListeningContainer();
	IntegrationBinderInboundChannelAdapter adapter = new IntegrationBinderInboundChannelAdapter(messageListenerContainer);

	String groupName = StringUtils.hasText(group) ? group : "anonymous";
	ErrorInfrastructure errorInfrastructure = registerErrorInfrastructure(destination, groupName, properties);
	if (properties.getMaxAttempts() > 1) {
		adapter.setRetryTemplate(buildRetryTemplate(properties));
		adapter.setRecoveryCallback(errorInfrastructure.getRecoverer());
	}
	else {
		adapter.setErrorMessageStrategy(errorMessageStrategy);
		adapter.setErrorChannel(errorInfrastructure.getErrorChannel());
	}

	siBinderInputChannel.subscribe(messageListenerContainer);

	return adapter;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:25,代码来源:SpringIntegrationChannelBinder.java


示例2: createConsumerEndpoint

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Override
protected MessageProducer createConsumerEndpoint(ConsumerDestination destination, String group,
		ExtendedConsumerProperties<PubSubConsumerProperties> properties) throws Exception {

	String consumerName = group == null
			? destination.getName() : destination.getName() + "-" + group;

	this.provisioningProvider.provisionConsumerDestination(
			consumerName, group, properties);

	return new PubSubInboundChannelAdapter(this.pubSubTemplate, destination.getName());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-gcp,代码行数:13,代码来源:PubSubMessageChannelBinder.java


示例3: inbound

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Bean
public MessageProducer inbound() {
    MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter(mqttServerUrl, "teger", "temp-stream");
    adapter.setCompletionTimeout(5000);
    adapter.setConverter(mqttMessageConverter);
    adapter.setQos(0);
    adapter.setOutputChannel(mqttInputChannel());
    return adapter;
}
 
开发者ID:efwe,项目名称:teger,代码行数:10,代码来源:MessageConfig.java


示例4: createMqttClient

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
/**
 * Create a MQTT connection to the broker
 *
 * @param messageHandler
 * @param topics
 * @return
 */
public MessageProducer createMqttClient(String[] topics) {
    MqttPahoMessageDrivenChannelAdapter adapter = new MqttPahoMessageDrivenChannelAdapter("raptor" + (System.currentTimeMillis() + Math.random()), mqttClientFactory, topics);
    adapter.setCompletionTimeout(5000);
    adapter.setConverter(new DefaultPahoMessageConverter());
    adapter.setQos(2);
    adapter.setRecoveryInterval(2500);
    adapter.setOutputChannel(mqttInputChannel);

    return adapter;
}
 
开发者ID:raptorbox,项目名称:raptor,代码行数:18,代码来源:BaseApplication.java


示例5: createConsumerEndpoint

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Override
protected MessageProducer createConsumerEndpoint(String name, String group,
		Subscription destination,
		ExtendedConsumerProperties<PubSubConsumerProperties> properties) {

	return new PubSubMessageListener(resourceManager, destination);

}
 
开发者ID:viniciusccarvalho,项目名称:spring-cloud-stream-binder-pubsub,代码行数:9,代码来源:PubSubMessageChannelBinder.java


示例6: inbound

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Bean
public MessageProducer inbound() {
    MqttPahoMessageDrivenChannelAdapter adapter =
        new MqttPahoMessageDrivenChannelAdapter(environment.getProperty("mqtt.address"),
            "SpringBoot:" + UUID.randomUUID().toString().substring(0, 5),
            environment.getProperty("mqtt.topic"));
    adapter.setCompletionTimeout(5000);
    adapter.setConverter(new DefaultPahoMessageConverter());
    adapter.setQos(1);
    adapter.setOutputChannel(mqttInputChannel());
    return adapter;
}
 
开发者ID:clive-jevons,项目名称:mqtt-elasticsearch-forwarding,代码行数:13,代码来源:MqttInputChannelAdapter.java


示例7: twitterStream

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Bean
public MessageProducer twitterStream(TwitterTemplate twitterTemplate) {
	TwitterStreamMessageProducer messageProducer =
			new TwitterStreamMessageProducer(twitterTemplate, twitterStreamProperties);
	messageProducer.setOutputChannel(source.output());
	return messageProducer;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:8,代码来源:TwitterstreamSourceConfiguration.java


示例8: inboundAdapterConfig

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Test
public void inboundAdapterConfig() {

	final MessageProducer producer = context.getBean("sqsInbound",
			MessageProducer.class);
	checkMessageMarshallerRef(getSqsExecutor(producer, "sqsExecutor"));
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:8,代码来源:SqsMessageMarshallerTests.java


示例9: inboundAdapterConfig

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Test
public void inboundAdapterConfig() {

	final MessageProducer producer = context.getBean("snsInbound",
			MessageProducer.class);
	checkMessageMarshallerRef(getSnsExecutor(producer, "snsExecutor"));
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:8,代码来源:SnsMessageMarshallerTests.java


示例10: createConsumerEndpoint

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Override
protected MessageProducer createConsumerEndpoint(ConsumerDestination destination, String group,
		ExtendedConsumerProperties<KinesisConsumerProperties> properties) {

	KinesisConsumerProperties kinesisConsumerProperties = properties.getExtension();

	Set<KinesisShardOffset> shardOffsets = null;

	String shardIteratorType = kinesisConsumerProperties.getShardIteratorType();

	KinesisShardOffset kinesisShardOffset = KinesisShardOffset.latest();

	if (StringUtils.hasText(shardIteratorType)) {
		String[] typeValue = shardIteratorType.split(":", 2);
		ShardIteratorType iteratorType = ShardIteratorType.valueOf(typeValue[0]);
		kinesisShardOffset = new KinesisShardOffset(iteratorType);
		if (typeValue.length > 1) {
			if (ShardIteratorType.AT_TIMESTAMP.equals(iteratorType)) {
				kinesisShardOffset.setTimestamp(new Date(Long.parseLong(typeValue[1])));
			}
			else {
				kinesisShardOffset.setSequenceNumber(typeValue[1]);
			}
		}
	}

	if (properties.getInstanceCount() > 1) {
		shardOffsets = new HashSet<>();
		KinesisConsumerDestination kinesisConsumerDestination = (KinesisConsumerDestination) destination;
		List<Shard> shards = kinesisConsumerDestination.getShards();
		for (int i = 0; i < shards.size(); i++) {
			// divide shards across instances
			if ((i % properties.getInstanceCount()) == properties.getInstanceIndex()) {
				KinesisShardOffset shardOffset = new KinesisShardOffset(kinesisShardOffset);
				shardOffset.setStream(destination.getName());
				shardOffset.setShard(shards.get(i).getShardId());
				shardOffsets.add(shardOffset);
			}
		}
	}

	KinesisMessageDrivenChannelAdapter adapter;

	if (shardOffsets == null) {
		adapter = new KinesisMessageDrivenChannelAdapter(this.amazonKinesis, destination.getName());
	}
	else {
		adapter = new KinesisMessageDrivenChannelAdapter(this.amazonKinesis,
				shardOffsets.toArray(new KinesisShardOffset[shardOffsets.size()]));
	}

	boolean anonymous = !StringUtils.hasText(group);
	String consumerGroup = anonymous ? "anonymous." + UUID.randomUUID().toString() : group;
	adapter.setConsumerGroup(consumerGroup);

	adapter.setStreamInitialSequence(
			anonymous || StringUtils.hasText(shardIteratorType)
					? kinesisShardOffset
					: KinesisShardOffset.trimHorizon());

	adapter.setListenerMode(kinesisConsumerProperties.getListenerMode());
	adapter.setCheckpointMode(kinesisConsumerProperties.getCheckpointMode());
	adapter.setRecordsLimit(kinesisConsumerProperties.getRecordsLimit());
	adapter.setIdleBetweenPolls(kinesisConsumerProperties.getIdleBetweenPolls());
	adapter.setConsumerBackoff(kinesisConsumerProperties.getConsumerBackoff());

	if (this.checkpointStore != null) {
		adapter.setCheckpointStore(this.checkpointStore);
	}
	adapter.setConcurrency(properties.getConcurrency());
	adapter.setStartTimeout(kinesisConsumerProperties.getStartTimeout());
	adapter.setDescribeStreamBackoff(this.configurationProperties.getDescribeStreamBackoff());
	adapter.setDescribeStreamRetries(this.configurationProperties.getDescribeStreamRetries());

	// Deffer byte[] conversion to the ReceivingHandler
	adapter.setConverter(null);

	return adapter;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-aws-kinesis,代码行数:80,代码来源:KinesisMessageChannelBinder.java


示例11: mqttClient

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Bean
public MessageProducer mqttClient() {
    return createMqttClient(new String[]{String.format(Topics.DEVICE, "+")});
}
 
开发者ID:raptorbox,项目名称:raptor,代码行数:5,代码来源:Application.java


示例12: createConsumerEndpoint

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Override
protected MessageProducer createConsumerEndpoint(ConsumerDestination consumerDestination, String group,
		ExtendedConsumerProperties<RabbitConsumerProperties> properties) {
	Assert.state(!HeaderMode.embeddedHeaders.equals(properties.getHeaderMode()),
			"the RabbitMQ binder does not support embedded headers since RabbitMQ supports headers natively");
	String destination = consumerDestination.getName();
	SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(
			this.connectionFactory);
	listenerContainer.setAcknowledgeMode(properties.getExtension().getAcknowledgeMode());
	listenerContainer.setChannelTransacted(properties.getExtension().isTransacted());
	listenerContainer.setDefaultRequeueRejected(properties.getExtension().isRequeueRejected());
	int concurrency = properties.getConcurrency();
	concurrency = concurrency > 0 ? concurrency : 1;
	listenerContainer.setConcurrentConsumers(concurrency);
	int maxConcurrency = properties.getExtension().getMaxConcurrency();
	if (maxConcurrency > concurrency) {
		listenerContainer.setMaxConcurrentConsumers(maxConcurrency);
	}
	listenerContainer.setPrefetchCount(properties.getExtension().getPrefetch());
	listenerContainer.setRecoveryInterval(properties.getExtension().getRecoveryInterval());
	listenerContainer.setTxSize(properties.getExtension().getTxSize());
	listenerContainer.setTaskExecutor(new SimpleAsyncTaskExecutor(consumerDestination.getName() + "-"));
	listenerContainer.setQueueNames(consumerDestination.getName());
	listenerContainer.setAfterReceivePostProcessors(this.decompressingPostProcessor);
	listenerContainer.setMessagePropertiesConverter(
			RabbitMessageChannelBinder.inboundMessagePropertiesConverter);
	listenerContainer.setExclusive(properties.getExtension().isExclusive());
	listenerContainer.setMissingQueuesFatal(properties.getExtension().getMissingQueuesFatal());
	if (properties.getExtension().getQueueDeclarationRetries() != null) {
		listenerContainer.setDeclarationRetries(properties.getExtension().getQueueDeclarationRetries());
	}
	if (properties.getExtension().getFailedDeclarationRetryInterval() != null) {
		listenerContainer.setFailedDeclarationRetryInterval(
				properties.getExtension().getFailedDeclarationRetryInterval());
	}
	listenerContainer.afterPropertiesSet();

	AmqpInboundChannelAdapter adapter = new AmqpInboundChannelAdapter(listenerContainer);
	adapter.setBeanFactory(this.getBeanFactory());
	adapter.setBeanName("inbound." + destination);
	DefaultAmqpHeaderMapper mapper = DefaultAmqpHeaderMapper.inboundMapper();
	mapper.setRequestHeaderNames(properties.getExtension().getHeaderPatterns());
	adapter.setHeaderMapper(mapper);
	ErrorInfrastructure errorInfrastructure = registerErrorInfrastructure(consumerDestination, group, properties);
	if (properties.getMaxAttempts() > 1) {
		adapter.setRetryTemplate(buildRetryTemplate(properties));
		if (properties.getExtension().isRepublishToDlq()) {
			adapter.setRecoveryCallback(errorInfrastructure.getRecoverer());
		}
	}
	else {
		adapter.setErrorMessageStrategy(errorMessageStrategy);
		adapter.setErrorChannel(errorInfrastructure.getErrorChannel());
	}
	return adapter;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:57,代码来源:RabbitMessageChannelBinder.java


示例13: testEndpointLifecycle

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Test
public void testEndpointLifecycle() throws Exception {
	AbstractMessageChannelBinder<ConsumerProperties, ProducerProperties, ProvisioningProvider<ConsumerProperties, ProducerProperties>> binder =
			context.getBean(AbstractMessageChannelBinder.class);

	ConsumerProperties consumerProperties = new ConsumerProperties();
	consumerProperties.setMaxAttempts(1); // to force error infrastructure creation

	Binding<MessageChannel> consumerBinding = binder.bindConsumer("foo", "fooGroup", new DirectChannel(), consumerProperties);
	DirectFieldAccessor consumerBindingAccessor = new DirectFieldAccessor(consumerBinding);
	MessageProducer messageProducer = (MessageProducer) consumerBindingAccessor.getPropertyValue("lifecycle");
	assertTrue(((Lifecycle)messageProducer).isRunning());
	assertNotNull(messageProducer.getOutputChannel());

	SubscribableChannel errorChannel = (SubscribableChannel) consumerBindingAccessor.getPropertyValue("lifecycle.errorChannel");
	assertThat(errorChannel).isNotNull();
	Set<MessageHandler> handlers = TestUtils.getPropertyValue(errorChannel, "dispatcher.handlers", Set.class);
	assertThat(handlers.size()).isEqualTo(2);
	Iterator<MessageHandler> iterator = handlers.iterator();
	assertThat(iterator.next()).isInstanceOf(BridgeHandler.class);
	assertThat(iterator.next()).isInstanceOf(LastSubscriberMessageHandler.class);
	assertThat(context.containsBean("foo.fooGroup.errors")).isTrue();
	assertThat(context.containsBean("foo.fooGroup.errors.recoverer")).isTrue();
	assertThat(context.containsBean("foo.fooGroup.errors.handler")).isTrue();
	assertThat(context.containsBean("foo.fooGroup.errors.bridge")).isTrue();
	consumerBinding.unbind();
	assertThat(context.containsBean("foo.fooGroup.errors")).isFalse();
	assertThat(context.containsBean("foo.fooGroup.errors.recoverer")).isFalse();
	assertThat(context.containsBean("foo.fooGroup.errors.handler")).isFalse();
	assertThat(context.containsBean("foo.fooGroup.errors.bridge")).isFalse();

	assertFalse(((Lifecycle) messageProducer).isRunning());

	ProducerProperties producerProps = new ProducerProperties();
	producerProps.setErrorChannelEnabled(true);
	Binding<MessageChannel> producerBinding = binder.bindProducer("bar", new DirectChannel(), producerProps);
	assertThat(context.containsBean("bar.errors")).isTrue();
	assertThat(context.containsBean("bar.errors.bridge")).isTrue();
	producerBinding.unbind();
	assertThat(context.containsBean("bar.errors")).isFalse();
	assertThat(context.containsBean("bar.errors.bridge")).isFalse();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:43,代码来源:AbstractMessageChannelBinderTests.java


示例14: inboundAdapterPermissions

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Test
public void inboundAdapterPermissions() {
	MessageProducer producer = context.getBean("sqs-inbound",
			MessageProducer.class);
	assertThat(producer, is(notNullValue()));

	final SqsExecutor executor = TestUtils.getPropertyValue(producer,
			"sqsExecutor", SqsExecutor.class);
	assertThat(executor, is(notNullValue()));

	@SuppressWarnings("unchecked")
	Set<Permission> permissions = (Set<Permission>) TestUtils
			.getPropertyValue(executor, "permissions");
	assertThat("permissions is not null", permissions, is(notNullValue()));
	assertThat("all permissions loaded", permissions.size(), is(equalTo(2)));

	Set<String> labels = new HashSet<String>();
	Map<String, Set<String>> labelActionMap = new HashMap<String, Set<String>>();
	Map<String, Set<String>> labelAccountMap = new HashMap<String, Set<String>>();

	for (Permission p : permissions) {
		labels.add(p.getLabel());
		assertThat("actions are not null", p.getActions(),
				is(notNullValue()));
		assertThat("awsAccounts are not null", p.getAwsAccountIds(),
				is(notNullValue()));
		labelActionMap.put(p.getLabel(), p.getActions());
		labelAccountMap.put(p.getLabel(), p.getAwsAccountIds());
	}

	assertThat("All labels found", labels,
			containsInAnyOrder("label1", "label2"));
	assertThat("All label1 actions loaded", labelActionMap.get("label1"),
			containsInAnyOrder("SendMessage", "GetQueueUrl"));
	assertThat("All label2 actions loaded", labelActionMap.get("label2"),
			containsInAnyOrder("ReceiveMessage"));
	assertThat("All label1 accounts loaded", labelAccountMap.get("label1"),
			containsInAnyOrder("12345", "23456", "34567"));
	assertThat("All label2 accounts loaded", labelAccountMap.get("label2"),
			containsInAnyOrder("45678"));
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:42,代码来源:SqsPermissionsParserTests.java


示例15: inboundAdapterPermissions

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
@Test
public void inboundAdapterPermissions() {
	MessageProducer producer = context.getBean("sns-inbound",
			MessageProducer.class);
	assertThat(producer, is(notNullValue()));

	final SnsExecutor executor = TestUtils.getPropertyValue(producer,
			"snsExecutor", SnsExecutor.class);
	assertThat("snsExecutor is not null", executor, is(notNullValue()));

	@SuppressWarnings("unchecked")
	Set<Permission> permissions = (Set<Permission>) TestUtils
			.getPropertyValue(executor, "permissions");
	assertThat("permissions is not null", permissions, is(notNullValue()));
	assertThat("all permissions loaded", permissions.size(), is(equalTo(2)));

	Set<String> labels = new HashSet<String>();
	Map<String, Set<String>> labelActionMap = new HashMap<String, Set<String>>();
	Map<String, Set<String>> labelAccountMap = new HashMap<String, Set<String>>();

	for (Permission p : permissions) {
		labels.add(p.getLabel());
		assertThat("actions are not null", p.getActions(),
				is(notNullValue()));
		assertThat("awsAccounts are not null", p.getAwsAccountIds(),
				is(notNullValue()));
		labelActionMap.put(p.getLabel(), p.getActions());
		labelAccountMap.put(p.getLabel(), p.getAwsAccountIds());
	}

	assertThat("All labels found", labels,
			containsInAnyOrder("label1", "label2"));
	assertThat("All label1 actions loaded", labelActionMap.get("label1"),
			containsInAnyOrder("Publish", "Receive"));
	assertThat("All label2 actions loaded", labelActionMap.get("label2"),
			containsInAnyOrder("GetTopicAttributes"));
	assertThat("All label1 accounts loaded", labelAccountMap.get("label1"),
			containsInAnyOrder("123456", "234567", "345678"));
	assertThat("All label2 accounts loaded", labelAccountMap.get("label2"),
			containsInAnyOrder("456789"));
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:42,代码来源:SnsPermissionsParserTests.java


示例16: setUp

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
public void setUp(String name, Class<?> cls, String consumerId) {
	context = new ClassPathXmlApplicationContext(name, cls);
	producer = this.context.getBean(consumerId, MessageProducer.class);
	messageMarshaller = new JsonMessageMarshaller();
}
 
开发者ID:3pillarlabs,项目名称:spring-integration-aws,代码行数:6,代码来源:SnsInboundChannelAdapterParserTests.java


示例17: createConsumerEndpoint

import org.springframework.integration.core.MessageProducer; //导入依赖的package包/类
/**
 * Creates {@link MessageProducer} that receives data from the consumer destination.
 * will be started and stopped by the binder.
 *
 * @param group the consumer group
 * @param destination reference to the consumer destination
 * @param properties the consumer properties
 * @return the consumer endpoint.
 */
protected abstract MessageProducer createConsumerEndpoint(ConsumerDestination destination, String group,
		C properties) throws Exception;
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:12,代码来源:AbstractMessageChannelBinder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IBaseResource类代码示例发布时间:2022-05-22
下一篇:
Java BlobProperties类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap