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


Java IntegrationContextUtils类代码示例

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


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

示例1: RedisTestBinder

import org.springframework.integration.context.IntegrationContextUtils; //导入依赖的package包/类
public RedisTestBinder(RedisConnectionFactory connectionFactory) {
	RedisMessageChannelBinder binder = new RedisMessageChannelBinder(connectionFactory);
	GenericApplicationContext context = new GenericApplicationContext();
	context.getBeanFactory().registerSingleton(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME,
			new DefaultMessageBuilderFactory());
	DefaultHeaderChannelRegistry channelRegistry = new DefaultHeaderChannelRegistry();
	channelRegistry.setReaperDelay(Long.MAX_VALUE);
	ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
	taskScheduler.afterPropertiesSet();
	channelRegistry.setTaskScheduler(taskScheduler);
	context.getBeanFactory().registerSingleton(
			IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME,
			channelRegistry);
	context.refresh();
	binder.setApplicationContext(context);
	binder.setCodec(new PojoCodec());
	setBinder(binder);
	template = new StringRedisTemplate(connectionFactory);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-redis,代码行数:20,代码来源:RedisTestBinder.java

示例2: PubSubTestBinder

import org.springframework.integration.context.IntegrationContextUtils; //导入依赖的package包/类
public PubSubTestBinder(PubSub pubSub){
	this.pubSub = pubSub;
	PubSubMessageChannelBinder binder = new PubSubMessageChannelBinder(new PubSubResourceManager(pubSub));
	GenericApplicationContext context = new GenericApplicationContext();
	ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
	scheduler.setPoolSize(1);
	scheduler.afterPropertiesSet();
	context.getBeanFactory().registerSingleton(IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME, scheduler);
	context.refresh();
	binder.setApplicationContext(context);
	binder.setCodec(new PojoCodec());
	this.setBinder(binder);

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

示例3: testErrorChannelIsBoundWithCorrectContentTypeConverter

import org.springframework.integration.context.IntegrationContextUtils; //导入依赖的package包/类
@Test
public void testErrorChannelIsBoundWithCorrectContentTypeConverter() {
	final AtomicBoolean received = new AtomicBoolean(false);
	ConfigurableApplicationContext applicationContext = SpringApplication.run(TestProcessor.class,
			"--spring.cloud.stream.bindings.error.destination=foo",
			"--spring.cloud.stream.bindings.error.content-type=application/json",
			"--server.port=0");

	MessageChannel errorChannel = applicationContext.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME,
			MessageChannel.class);
	MessageChannel errorBridgeChannel = applicationContext.getBean(BindingServiceConfiguration.ERROR_BRIDGE_CHANNEL,
			MessageChannel.class);

	((SubscribableChannel)errorBridgeChannel).subscribe(new MessageHandler() {
		@Override
		public void handleMessage(Message<?> message) throws MessagingException {
			assertThat(new String((byte[])message.getPayload())).isEqualTo("{\"foo\":\"bar\"}");
			received.set(true);
		}
	});

	Foo foo = new Foo();
	foo.setFoo("bar");

	errorChannel.send(new GenericMessage<>(foo));
	assertThat(received.get()).isTrue();
	applicationContext.close();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:29,代码来源:ErrorBindingTests.java

示例4: testErrorChannelForExceptionWhenContentTypeIsSet

import org.springframework.integration.context.IntegrationContextUtils; //导入依赖的package包/类
@Test
public void testErrorChannelForExceptionWhenContentTypeIsSet() {
	final AtomicBoolean received = new AtomicBoolean(false);
	ConfigurableApplicationContext applicationContext = SpringApplication.run(TestProcessor.class,
			"--spring.cloud.stream.bindings.error.destination=foo",
			"--spring.cloud.stream.bindings.error.content-type=application/json",
			"--server.port=0");

	MessageChannel errorChannel = applicationContext.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME,
			MessageChannel.class);
	MessageChannel errorBridgeChannel = applicationContext.getBean(BindingServiceConfiguration.ERROR_BRIDGE_CHANNEL,
			MessageChannel.class);

	((SubscribableChannel)errorBridgeChannel).subscribe(new MessageHandler() {
		@Override
		public void handleMessage(Message<?> message) throws MessagingException {
			String payload = new String((byte[]) message.getPayload());
			assertThat(payload.contains("cause")).isTrue();
			assertThat(payload.contains("stackTrace")).isTrue();
			assertThat(payload.contains("throwing exception")).isTrue();
			received.set(true);
		}
	});

	errorChannel.send(new GenericMessage<>(new Exception("throwing exception")));
	assertThat(received.get()).isTrue();
	applicationContext.close();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:29,代码来源:ErrorBindingTests.java

示例5: testErrors

import org.springframework.integration.context.IntegrationContextUtils; //导入依赖的package包/类
@Test
public void testErrors() {
	SpringIntegrationChannelBinder binder = createBinder();
	DefaultPollableMessageSource pollableSource = new DefaultPollableMessageSource();
	pollableSource.addInterceptor(new ChannelInterceptorAdapter() {

		@Override
		public Message<?> preSend(Message<?> message, MessageChannel channel) {
			return MessageBuilder.withPayload(((String) message.getPayload()).toUpperCase())
					.copyHeaders(message.getHeaders())
					.build();
		}

	});
	ExtendedConsumerProperties<Object> properties = new ExtendedConsumerProperties<>(null);
	properties.setMaxAttempts(2);
	properties.setBackOffInitialInterval(0);
	binder.bindPollableConsumer("foo", "bar", pollableSource, properties);
	final CountDownLatch latch = new CountDownLatch(1);
	this.context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME, SubscribableChannel.class).subscribe(m -> {
		latch.countDown();
	});
	final AtomicInteger count = new AtomicInteger();
	assertThat(pollableSource.poll(received -> {
		count.incrementAndGet();
		throw new RuntimeException("test recoverer");
	})).isTrue();
	assertThat(count.get()).isEqualTo(2);
	Message<?> lastError = binder.getLastError();
	assertThat(lastError).isNotNull();
	assertThat(((Exception) lastError.getPayload()).getCause().getMessage()).isEqualTo("test recoverer");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:33,代码来源:PollableConsumerTests.java

示例6: testErrorsNoRetry

import org.springframework.integration.context.IntegrationContextUtils; //导入依赖的package包/类
@Test
public void testErrorsNoRetry() {
	SpringIntegrationChannelBinder binder = createBinder();
	DefaultPollableMessageSource pollableSource = new DefaultPollableMessageSource();
	pollableSource.addInterceptor(new ChannelInterceptorAdapter() {

		@Override
		public Message<?> preSend(Message<?> message, MessageChannel channel) {
			return MessageBuilder.withPayload(((String) message.getPayload()).toUpperCase())
					.copyHeaders(message.getHeaders())
					.build();
		}

	});
	ExtendedConsumerProperties<Object> properties = new ExtendedConsumerProperties<>(null);
	properties.setMaxAttempts(1);
	binder.bindPollableConsumer("foo", "bar", pollableSource, properties);
	final CountDownLatch latch = new CountDownLatch(1);
	this.context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME, SubscribableChannel.class).subscribe(m -> {
		latch.countDown();
	});
	final AtomicInteger count = new AtomicInteger();
	assertThat(pollableSource.poll(received -> {
		count.incrementAndGet();
		throw new RuntimeException("test recoverer");
	})).isTrue();
	assertThat(count.get()).isEqualTo(1);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:29,代码来源:PollableConsumerTests.java

示例7: createBinder

import org.springframework.integration.context.IntegrationContextUtils; //导入依赖的package包/类
private SpringIntegrationChannelBinder createBinder() {
	SpringIntegrationProvisioner provisioningProvider = new SpringIntegrationProvisioner();
	SpringIntegrationChannelBinder binder = new SpringIntegrationChannelBinder(provisioningProvider);
	this.context.registerBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME, PublishSubscribeChannel.class);
	this.context.refresh();
	binder.setApplicationContext(this.context);
	return binder;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:9,代码来源:PollableConsumerTests.java

示例8: configurableCompositeMessageConverter

import org.springframework.integration.context.IntegrationContextUtils; //导入依赖的package包/类
@Bean(name = IntegrationContextUtils.ARGUMENT_RESOLVER_MESSAGE_CONVERTER_BEAN_NAME)
public ConfigurableCompositeMessageConverter configurableCompositeMessageConverter(CompositeMessageConverterFactory factory){
	return new ConfigurableCompositeMessageConverter(factory.getMessageConverterForAllRegistered().getConverters());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:5,代码来源:ContentTypeConfiguration.java


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