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


Java QueueChannel.receive方法代码示例

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


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

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testSendPojoReceivePojoWithStreamListenerDefaultContentType()
		throws Exception {
	StreamListenerMessageHandler handler = this.buildStreamListener(
			AbstractBinderTests.class, "echoStation", Station.class);

	Binder binder = getBinder();

	BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());

	DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);

	BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());

	DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);

	Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0a",
			getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());

	Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0a",
			getDestinationNameDelimiter()), "test-1", moduleInputChannel, consumerBindingProperties.getConsumer());

	Station station = new Station();
	Message<?> message = MessageBuilder.withPayload(station).build();
	moduleInputChannel.subscribe(handler);
	moduleOutputChannel.send(message);

	QueueChannel replyChannel = (QueueChannel) handler.getOutputChannel();

	Message<?> replyMessage = replyChannel.receive(5000);
	assertTrue(replyMessage.getPayload() instanceof Station);
	producerBinding.unbind();
	consumerBinding.unbind();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:36,代码来源:AbstractBinderTests.java

示例4: testSendPojoReceivePojoKryoWithStreamListener

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testSendPojoReceivePojoKryoWithStreamListener() throws Exception {
	StreamListenerMessageHandler handler = this.buildStreamListener(
			AbstractBinderTests.class, "echoStation", Station.class);

	Binder binder = getBinder();

	BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());

	DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);

	BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());

	DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);

	Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0b",
			getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());

	Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0b",
			getDestinationNameDelimiter()), "test-2", moduleInputChannel, consumerBindingProperties.getConsumer());

	Station station = new Station();
	Message<?> message = MessageBuilder.withPayload(station).setHeader(
			MessageHeaders.CONTENT_TYPE, MessageConverterUtils.X_JAVA_OBJECT).build();
	moduleInputChannel.subscribe(handler);
	moduleOutputChannel.send(message);

	QueueChannel replyChannel = (QueueChannel) handler.getOutputChannel();

	Message<?> replyMessage = replyChannel.receive(5000);
	assertTrue(replyMessage.getPayload() instanceof Station);
	producerBinding.unbind();
	consumerBinding.unbind();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:36,代码来源:AbstractBinderTests.java

示例5: testSendJsonReceivePojoWithStreamListener

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testSendJsonReceivePojoWithStreamListener() throws Exception {
	StreamListenerMessageHandler handler = this.buildStreamListener(
			AbstractBinderTests.class, "echoStation", Station.class);
	Binder binder = getBinder();

	BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());

	DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);

	BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());

	DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);

	Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0d",
			getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());

	Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0d",
			getDestinationNameDelimiter()), "test-4", moduleInputChannel, consumerBindingProperties.getConsumer());

	String value = "{\"readings\":[{\"stationid\":\"fgh\","
			+ "\"customerid\":\"12345\",\"timestamp\":null},{\"stationid\":\"hjk\",\"customerid\":\"222\",\"timestamp\":null}]}";

	Message<?> message = MessageBuilder.withPayload(value)
			.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
			.build();
	moduleInputChannel.subscribe(handler);
	moduleOutputChannel.send(message);

	QueueChannel channel = (QueueChannel) handler.getOutputChannel();

	Message<Station> reply = (Message<Station>) channel.receive(5000);

	assertNotNull(reply);
	assertTrue(reply.getPayload() instanceof Station);
	producerBinding.unbind();
	consumerBinding.unbind();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:40,代码来源:AbstractBinderTests.java

示例6: testSendJsonReceiveJsonWithStreamListener

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testSendJsonReceiveJsonWithStreamListener() throws Exception {
	StreamListenerMessageHandler handler = this.buildStreamListener(
			AbstractBinderTests.class, "echoStationString", String.class);
	Binder binder = getBinder();

	BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());

	DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);

	BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());

	DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);

	Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0e",
			getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());

	Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0e",
			getDestinationNameDelimiter()), "test-5", moduleInputChannel, consumerBindingProperties.getConsumer());

	String value = "{\"readings\":[{\"stationid\":\"fgh\","
			+ "\"customerid\":\"12345\",\"timestamp\":null},{\"stationid\":\"hjk\",\"customerid\":\"222\",\"timestamp\":null}]}";

	Message<?> message = MessageBuilder.withPayload(value)
			.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
			.build();
	moduleInputChannel.subscribe(handler);
	moduleOutputChannel.send(message);

	QueueChannel channel = (QueueChannel) handler.getOutputChannel();

	Message<String> reply = (Message<String>) channel.receive(5000);

	assertNotNull(reply);
	assertTrue(reply.getPayload() instanceof String);
	producerBinding.unbind();
	consumerBinding.unbind();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:40,代码来源:AbstractBinderTests.java

示例7: main

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "unchecked", "rawtypes" })
public static void main(String[] args) {
	ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
	rootLogger.setLevel(Level.toLevel("info"));
	
	final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(CONFIG, Consumer.class);
	ctx.start();

	final QueueChannel channel = ctx.getBean("inputFromKafka", QueueChannel.class);
	Message msg;		
	while((msg = channel.receive()) != null) {
		HashMap map = (HashMap)msg.getPayload();
		Set<Map.Entry> set = map.entrySet();
		for (Map.Entry entry : set) {
			String topic = (String)entry.getKey();
			System.out.println("Topic:" + topic);
			ConcurrentHashMap<Integer,List<byte[]>> messages = (ConcurrentHashMap<Integer,List<byte[]>>)entry.getValue();
			Collection<List<byte[]>> values = messages.values();
			for (Iterator<List<byte[]>> iterator = values.iterator(); iterator.hasNext();) {
				List<byte[]> list = iterator.next();
				for (byte[] object : list) {
					String message = new String(object);
					System.out.println("\tMessage: " + message);
				}
				
			}
		
		}
		
	}
	
	try {
		Thread.sleep(100000);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
	ctx.close();
}
 
开发者ID:smallnest,项目名称:spring-kafka-demo,代码行数:39,代码来源:Consumer.java

示例8: testDlqWithNativeDecodingOnConsumerButMissingSerializerOnDlqProducer

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testDlqWithNativeDecodingOnConsumerButMissingSerializerOnDlqProducer() throws Exception {
	Binder binder = getBinder();
	ExtendedProducerProperties<KafkaProducerProperties> producerProperties = createProducerProperties();
	//Native serialization for producer
	producerProperties.setUseNativeEncoding(true);
	Map<String, String> producerConfig = new HashMap<>();
	producerConfig.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
	producerProperties.getExtension().setConfiguration(producerConfig);
	BindingProperties outputBindingProperties = createProducerBindingProperties(
			producerProperties);
	DirectChannel moduleOutputChannel = createBindableChannel("output",
			outputBindingProperties);

	ExtendedConsumerProperties<KafkaConsumerProperties> consumerProperties = createConsumerProperties();
	//Native Deserialization for consumer
	consumerProperties.setUseNativeDecoding(true);

	Map<String, String> consumerConfig = new HashMap<>();
	consumerConfig.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");

	//No Dlq producer properties set on the consumer with a native serializer. This should cause an error for DLQ sending.

	consumerProperties.getExtension().setConfiguration(consumerConfig);
	consumerProperties.getExtension().setEnableDlq(true);

	DirectChannel moduleInputChannel = createBindableChannel("input", createConsumerBindingProperties(consumerProperties));

	Binding<MessageChannel> producerBinding = binder.bindProducer("foo.bar",
			moduleOutputChannel, outputBindingProperties.getProducer());
	Binding<MessageChannel> consumerBinding = binder.bindConsumer("foo.bar",
			"testDlqWithNativeEncoding-2", moduleInputChannel, consumerProperties);

	// Let the consumer actually bind to the producer before sending a msg
	binderBindUnbindLatency();

	FailingInvocationCountingMessageHandler handler = new FailingInvocationCountingMessageHandler();
	moduleInputChannel.subscribe(handler);

	//Consumer for the DLQ destination
	QueueChannel dlqChannel = new QueueChannel();
	ExtendedConsumerProperties<KafkaConsumerProperties> dlqConsumerProperties = createConsumerProperties();
	dlqConsumerProperties.setMaxAttempts(1);

	Binding<MessageChannel> dlqConsumerBinding = binder.bindConsumer(
			"error.foo.bar." + "testDlqWithNativeEncoding-2", null, dlqChannel, dlqConsumerProperties);
	binderBindUnbindLatency();

	Message<?> message = org.springframework.integration.support.MessageBuilder.withPayload("foo")
			.build();

	moduleOutputChannel.send(message);

	Message<?> receivedMessage = dlqChannel.receive(5000);
	//Ensure that we didn't receive anything on DLQ because of serializer config missing
	//on dlq producer while native Decoding is enabled.
	assertThat(receivedMessage).isNull();

	binderBindUnbindLatency();

	dlqConsumerBinding.unbind();

	producerBinding.unbind();
	consumerBinding.unbind();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:67,代码来源:KafkaBinderTests.java

示例9: testBatchingAndCompression

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testBatchingAndCompression() throws Exception {
	RabbitTestBinder binder = getBinder();
	ExtendedProducerProperties<RabbitProducerProperties> producerProperties = createProducerProperties();
	producerProperties.getExtension().setDeliveryMode(MessageDeliveryMode.NON_PERSISTENT);
	producerProperties.getExtension().setBatchingEnabled(true);
	producerProperties.getExtension().setBatchSize(2);
	producerProperties.getExtension().setBatchBufferLimit(100000);
	producerProperties.getExtension().setBatchTimeout(30000);
	producerProperties.getExtension().setCompress(true);
	producerProperties.setRequiredGroups("default");

	DirectChannel output = createBindableChannel("output", createProducerBindingProperties(producerProperties));
	output.setBeanName("batchingProducer");
	Binding<MessageChannel> producerBinding = binder.bindProducer("batching.0", output, producerProperties);

	Log logger = spy(TestUtils.getPropertyValue(binder, "binder.compressingPostProcessor.logger", Log.class));
	new DirectFieldAccessor(TestUtils.getPropertyValue(binder, "binder.compressingPostProcessor"))
			.setPropertyValue("logger", logger);
	when(logger.isTraceEnabled()).thenReturn(true);

	assertThat(TestUtils.getPropertyValue(binder, "binder.compressingPostProcessor.level"))
			.isEqualTo(Deflater.BEST_SPEED);

	output.send(new GenericMessage<>("foo".getBytes()));
	output.send(new GenericMessage<>("bar".getBytes()));

	Object out = spyOn("batching.0.default").receive(false);
	assertThat(out).isInstanceOf(byte[].class);
	assertThat(new String((byte[]) out)).isEqualTo("\u0000\u0000\u0000\u0003foo\u0000\u0000\u0000\u0003bar");

	ArgumentCaptor<Object> captor = ArgumentCaptor.forClass(Object.class);
	verify(logger).trace(captor.capture());
	assertThat(captor.getValue().toString()).contains(("Compressed 14 to "));

	QueueChannel input = new QueueChannel();
	input.setBeanName("batchingConsumer");
	Binding<MessageChannel> consumerBinding = binder.bindConsumer("batching.0", "test", input,
			createConsumerProperties());

	output.send(new GenericMessage<>("foo".getBytes()));
	output.send(new GenericMessage<>("bar".getBytes()));

	Message<byte[]> in = (Message<byte[]>) input.receive(10000);
	assertThat(in).isNotNull();
	assertThat(new String(in.getPayload())).isEqualTo("foo");
	in = (Message<byte[]>) input.receive(10000);
	assertThat(in).isNotNull();
	assertThat(new String(in.getPayload())).isEqualTo("bar");
	assertThat(in.getHeaders().get(AmqpHeaders.DELIVERY_MODE)).isNull();

	producerBinding.unbind();
	consumerBinding.unbind();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-rabbit,代码行数:56,代码来源:RabbitBinderTests.java

示例10: testSendPojoReceivePojoWithStreamListener

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testSendPojoReceivePojoWithStreamListener() throws Exception {
	StreamListenerMessageHandler handler = this.buildStreamListener(
			AbstractBinderTests.class, "echoStation", Station.class);
	Binder binder = getBinder();

	BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());

	DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);

	BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());

	DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);

	Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0f",
			getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());

	Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0f",
			getDestinationNameDelimiter()), "test-6", moduleInputChannel, consumerBindingProperties.getConsumer());

	Readings r1 = new Readings();
	r1.setCustomerid("123");
	r1.setStationid("XYZ");
	Readings r2 = new Readings();
	r2.setCustomerid("546");
	r2.setStationid("ABC");
	Station station = new Station();
	station.setReadings(Arrays.asList(r1, r2));
	Message<?> message = MessageBuilder.withPayload(station)
			.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
			.build();
	moduleInputChannel.subscribe(handler);
	moduleOutputChannel.send(message);

	QueueChannel channel = (QueueChannel) handler.getOutputChannel();

	Message<Station> reply = (Message<Station>) channel.receive(5000);

	assertNotNull(reply);
	assertTrue(reply.getPayload() instanceof Station);
	producerBinding.unbind();
	consumerBinding.unbind();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:45,代码来源:AbstractBinderTests.java

示例11: main

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
/**
 * Load the Spring Integration Application Context
 *
 * @param args - command line arguments
 * @throws InterruptedException
 */
public static void main(final String... args) throws InterruptedException {

	System.out.println("\n========================================================="
					+ "\n    Welcome to the Spring Batch Integration              "
					+ "\n          Payments Import Sample                         "
					+ "\n                                                         "
					+ "\n    For more information please visit:                   "
					+ "\n    http://www.spring.io/spring-batch                    "
					+ "\n                                                         "
					+ "\n=========================================================" );

	final ConfigurableApplicationContext context = SpringApplication.run(CommonConfig.class);

	final JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);

	SpringIntegrationUtils.displayDirectories(context);

	System.out.println("\n========================================================="
					+ "\n                                                         "
					+ "\n    Waiting for Job execution to finish.                 "
					+ "\n                                                         "
					+ "\n=========================================================" );

	final QueueChannel completeApplicationChannel =
			context.getBean("completeApplication", QueueChannel.class);

	@SuppressWarnings("unchecked")
	final Message<JobExecution> jobExecutionMessage = (Message<JobExecution>) completeApplicationChannel.receive();
	final JobExecution jobExecution = jobExecutionMessage.getPayload();
	final ExitStatus exitStatus = jobExecution.getExitStatus();
	final int count = jdbcTemplate.queryForObject("select count(*) from payments", Integer.class);

	System.out.println(String.format("\nDONE!!\nexitStatus: %s; # of payments imported: %s",
			exitStatus.getExitCode(), count));

	final StubJavaMailSender mailSender = context.getBean(StubJavaMailSender.class);
	final List<SimpleMailMessage> emails = mailSender.getSentSimpleMailMessages();
	final int numberOfSentNotifications = emails.size();

	System.out.println(String.format("Sent '%s' notifications:", numberOfSentNotifications));

	int counter = 1;
	for (SimpleMailMessage mailMessage : emails) {
		System.out.println(String.format("#%s Subject: '%s', Message: '%s'.",
				counter, mailMessage.getText(), mailMessage.getText()));
		counter++;
	}

	System.exit(0);

}
 
开发者ID:ghillert,项目名称:spring-batch-integration-sample,代码行数:58,代码来源:Main.java

示例12: main

import org.springframework.integration.channel.QueueChannel; //导入方法依赖的package包/类
/**
 * Load the Spring Integration Application Context
 *
 * @param args - command line arguments
 * @throws InterruptedException
 */
public static void main(final String... args) throws InterruptedException {

	System.out.println("\n========================================================="
					+ "\n    Welcome to the Spring Batch Integration              "
					+ "\n          Payments Import Sample                         "
					+ "\n                                                         "
					+ "\n    For more information please visit:                   "
					+ "\n    http://www.spring.io/spring-batch                    "
					+ "\n                                                         "
					+ "\n=========================================================" );

	final AbstractApplicationContext context =
			new ClassPathXmlApplicationContext("classpath:META-INF/spring/batch-context.xml",
					"classpath:META-INF/spring/integration-context.xml");

	context.registerShutdownHook();

	final JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);

	SpringIntegrationUtils.displayDirectories(context);

	System.out.println("\n========================================================="
					+ "\n                                                         "
					+ "\n    Waiting for Job execution to finish.                 "
					+ "\n                                                         "
					+ "\n=========================================================" );

	final QueueChannel completeApplicationChannel =
			context.getBean("completeApplication", QueueChannel.class);

	@SuppressWarnings("unchecked")
	final Message<JobExecution> jobExecutionMessage = (Message<JobExecution>) completeApplicationChannel.receive();
	final JobExecution jobExecution = jobExecutionMessage.getPayload();
	final ExitStatus exitStatus = jobExecution.getExitStatus();
	final int count = jdbcTemplate.queryForObject("select count(*) from payments", Integer.class);

	System.out.println(String.format("\nDONE!!\nexitStatus: %s; # of payments imported: %s",
			exitStatus.getExitCode(), count));

	final StubJavaMailSender mailSender = context.getBean(StubJavaMailSender.class);
	final List<SimpleMailMessage> emails = mailSender.getSentSimpleMailMessages();
	final int numberOfSentNotifications = emails.size();

	System.out.println(String.format("Sent '%s' notifications:", numberOfSentNotifications));

	int counter = 1;
	for (SimpleMailMessage mailMessage : emails) {
		System.out.println(String.format("#%s Subject: '%s', Message: '%s'.",
				counter, mailMessage.getText(), mailMessage.getText()));
		counter++;
	}

	System.exit(0);

}
 
开发者ID:ghillert,项目名称:spring-batch-integration-sample,代码行数:62,代码来源:Main.java


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