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


Java QueueChannel.send方法代码示例

本文整理汇总了Java中org.springframework.integration.channel.QueueChannel.send方法的典型用法代码示例。如果您正苦于以下问题:Java QueueChannel.send方法的具体用法?Java QueueChannel.send怎么用?Java QueueChannel.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.integration.channel.QueueChannel的用法示例。


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

示例1: testConfigureOutputChannelWithBadContentType

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@Test
public void testConfigureOutputChannelWithBadContentType() {
	BindingServiceProperties props = new BindingServiceProperties();
	BindingProperties bindingProps = new BindingProperties();
	bindingProps.setContentType("application/json");
	props.setBindings(Collections.singletonMap("foo", bindingProps));
	CompositeMessageConverterFactory converterFactory = new CompositeMessageConverterFactory(
			Collections.<MessageConverter>emptyList(), null);
	MessageConverterConfigurer configurer = new MessageConverterConfigurer(props, converterFactory);
	QueueChannel out = new QueueChannel();
	configurer.configureOutputChannel(out, "foo");
	out.send(new GenericMessage<Foo>(new Foo(),
			Collections.<String, Object> singletonMap(MessageHeaders.CONTENT_TYPE, "bad/ct")));
	Message<?> received = out.receive(0);
	assertThat(received).isNotNull();
	assertThat(received.getPayload()).isInstanceOf(Foo.class);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:18,代码来源:MessageConverterConfigurerTests.java

示例2: testConfigureInputChannelWithLegacyContentType

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@Test
public void testConfigureInputChannelWithLegacyContentType() {
	BindingServiceProperties props = new BindingServiceProperties();
	BindingProperties bindingProps = new BindingProperties();
	bindingProps.setContentType("foo/bar");
	props.setBindings(Collections.singletonMap("foo", bindingProps));
	CompositeMessageConverterFactory converterFactory = new CompositeMessageConverterFactory(
			Collections.<MessageConverter>emptyList(), null);
	MessageConverterConfigurer configurer = new MessageConverterConfigurer(props, converterFactory);
	QueueChannel in = new QueueChannel();
	configurer.configureInputChannel(in, "foo");
	Foo foo = new Foo();
	in.send(
			MessageBuilder.withPayload(foo)
				.setHeader(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE, "application/json")
				.setHeader(BinderHeaders.SCST_VERSION, "1.x")
				.build());
	Message<?> received = in.receive(0);
	assertThat(received).isNotNull();
	assertThat(received.getPayload()).isEqualTo(foo);
	assertThat(received.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString()).isEqualTo("application/json");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:23,代码来源:MessageConverterConfigurerTests.java

示例3: testConfigureOutputChannelCannotConvert

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@Test
@Ignore
public void testConfigureOutputChannelCannotConvert() {
	BindingServiceProperties props = new BindingServiceProperties();
	BindingProperties bindingProps = new BindingProperties();
	bindingProps.setContentType("foo/bar");
	props.setBindings(Collections.singletonMap("foo", bindingProps));
	MessageConverter converter = new AbstractMessageConverter(new MimeType("foo", "bar")) {

		@Override
		protected boolean supports(Class<?> clazz) {
			return true;
		}

		@Override
		protected Object convertToInternal(Object payload, MessageHeaders headers, Object conversionHint) {
			return null;
		}

	};
	CompositeMessageConverterFactory converterFactory = new CompositeMessageConverterFactory(
			Collections.<MessageConverter>singletonList(converter), null);
	MessageConverterConfigurer configurer = new MessageConverterConfigurer(props, converterFactory);
	QueueChannel out = new QueueChannel();
	configurer.configureOutputChannel(out, "foo");
	try {
		out.send(new GenericMessage<Foo>(new Foo(),
				Collections.<String, Object> singletonMap(MessageHeaders.CONTENT_TYPE, "bad/ct")));
		fail("Expected MessageConversionException: " + out.receive(0));
	}
	catch (MessageConversionException e) {
		assertThat(e.getMessage()).endsWith("to the configured output type: 'foo/bar'");
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:35,代码来源:MessageConverterConfigurerTests.java


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