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


Java MessageProducer类代码示例

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


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


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