org.springframework.integration.expression.ValueExpression Java Examples

The following examples show how to use org.springframework.integration.expression.ValueExpression. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmazonS3SinkConfiguration.java    From spring-cloud-stream-app-starters with Apache License 2.0 6 votes vote down vote up
@Bean
@ServiceActivator(inputChannel = Sink.INPUT)
public MessageHandler amazonS3MessageHandler(AmazonS3 amazonS3, ResourceIdResolver resourceIdResolver,
		AmazonS3SinkProperties s3SinkProperties) {
	S3MessageHandler s3MessageHandler;
	if (s3SinkProperties.getBucket() != null) {
		s3MessageHandler = new S3MessageHandler(amazonS3, s3SinkProperties.getBucket());
	}
	else {
		s3MessageHandler = new S3MessageHandler(amazonS3, s3SinkProperties.getBucketExpression());
	}
	s3MessageHandler.setResourceIdResolver(resourceIdResolver);
	s3MessageHandler.setKeyExpression(s3SinkProperties.getKeyExpression());
	if (s3SinkProperties.getAcl() != null) {
		s3MessageHandler.setObjectAclExpression(new ValueExpression<>(s3SinkProperties.getAcl()));
	}
	else {
		s3MessageHandler.setObjectAclExpression(s3SinkProperties.getAclExpression());
	}
	s3MessageHandler.setUploadMetadataProvider(this.uploadMetadataProvider);
	s3MessageHandler.setProgressListener(this.s3ProgressListener);
	return s3MessageHandler;
}
 
Example #2
Source File: GcsMessageHandlerTests.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Bean
@ServiceActivator(inputChannel = "siGcsTestChannel")
public MessageHandler outboundAdapter(Storage gcs) {
	GcsMessageHandler adapter = new GcsMessageHandler(new GcsSessionFactory(gcs));
	adapter.setRemoteDirectoryExpression(new ValueExpression<>("testGcsBucket"));

	return adapter;
}
 
Example #3
Source File: PubSubMessageHandlerTests.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Test
public void testTopicExpression() {
	Expression expected = new ValueExpression<>("topic");

	this.adapter.setTopicExpression(expected);

	assertThat(this.adapter.getTopicExpression()).isEqualTo(expected);
}
 
Example #4
Source File: RabbitBinderTests.java    From spring-cloud-stream-binder-rabbit with Apache License 2.0 4 votes vote down vote up
@Test
public void testRoutingKeyExpressionPartitionedAndDelay() throws Exception {
	RabbitTestBinder binder = getBinder();
	ExtendedProducerProperties<RabbitProducerProperties> producerProperties = createProducerProperties();
	producerProperties.getExtension().setRoutingKeyExpression(
			spelExpressionParser.parseExpression("#root.getPayload().field"));
	// requires delayed message exchange plugin; tested locally
	// producerProperties.getExtension().setDelayedExchange(true);
	producerProperties.getExtension()
			.setDelayExpression(spelExpressionParser.parseExpression("1000"));
	producerProperties.setPartitionKeyExpression(new ValueExpression<>(0));

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

	RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource());
	Queue queue = new AnonymousQueue();
	TopicExchange exchange = new TopicExchange("rkep");
	org.springframework.amqp.core.Binding binding = BindingBuilder.bind(queue)
			.to(exchange).with("rkepTest-0");
	admin.declareQueue(queue);
	admin.declareBinding(binding);

	output.addInterceptor(new ChannelInterceptor() {

		@Override
		public Message<?> preSend(Message<?> message, MessageChannel channel) {
			assertThat(message.getHeaders()
					.get(RabbitExpressionEvaluatingInterceptor.ROUTING_KEY_HEADER))
							.isEqualTo("rkepTest");
			assertThat(message.getHeaders()
					.get(RabbitExpressionEvaluatingInterceptor.DELAY_HEADER))
							.isEqualTo(1000);
			return message;
		}

	});

	output.send(new GenericMessage<>(new Pojo("rkepTest")));

	Object out = spyOn(queue.getName()).receive(false);
	assertThat(out).isInstanceOf(byte[].class);
	assertThat(new String((byte[]) out, StandardCharsets.UTF_8))
			.isEqualTo("{\"field\":\"rkepTest\"}");

	producerBinding.unbind();
}
 
Example #5
Source File: PubSubMessageHandler.java    From spring-cloud-gcp with Apache License 2.0 2 votes vote down vote up
/**
 * Set the timeout in milliseconds for a synchronous publish call to Google Cloud Pub/Sub.
 * @param timeoutMillis timeout in milliseconds
 */
public void setPublishTimeout(long timeoutMillis) {
	setPublishTimeoutExpression(new ValueExpression<>(timeoutMillis));
}
 
Example #6
Source File: BigQueryFileMessageHandler.java    From spring-cloud-gcp with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the handler's {@link FormatOptions} which describe the type/format of data files being
 * loaded. This overwrites any previous settings made by {@link #setFormatOptionsExpression}.
 * @param formatOptions the format of the data file being loaded
 */
public void setFormatOptions(FormatOptions formatOptions) {
	Assert.notNull(formatOptions, "Format options must not be null.");
	this.formatOptionsExpression = new ValueExpression<>(formatOptions);
}