Commit Graph

84 Commits

Author SHA1 Message Date
Oleg Zhurakousky
7f52ffc184 Remove references to original content type 2019-09-30 14:57:35 -04:00
Oleg Zhurakousky
945821e417 Temporarily ignored functional tests pending further review
also, minor polishings
2019-07-25 16:56:39 +02:00
Oleg Zhurakousky
abab014f39 GH-1707 Removed all references to aggregator builder
- removed deprecations connected to InterceptableChannel
- minor polishing to get rid of IDE warnings

Resolves #1707
2019-06-12 21:47:16 +02:00
Oleg Zhurakousky
ee417f9d85 GH-1707 Initial removal of 2.0.0 deprecated classes and methods 2019-05-08 12:10:46 +02:00
Oleg Zhurakousky
b5a64eac14 Fixed URLs in licence headers and upgraded to s-c-build 2.1.4 2019-03-25 15:24:18 +01:00
Marcin Grzejszczak
a8cbf77794 Added checkstyle 2019-02-04 15:55:35 +01:00
Artem Bilan
460ba9cecb GH-1569: Fix binder-specific environment merging
Fixes spring-cloud/spring-cloud-stream#1569

When `inheritEnvironment = true` (default), some provided properties
(including `spring.main.sources`) are not populated into the target
binder's environment, since Spring Boot relies on the presence of
the `configurationProperties` properties source which is transferred
from the parent context

* Remove `configurationProperties` from the `binderEnvironment` before
starting binder's application context
* Ensure that `spring.main.sources` is applied for the binder's
application context in the `BinderFactoryConfigurationTests`
* Fix `GreenfieldFunctionEnableBindingTests` for random HTTP port since
`8080` is too generic and clashes with build environment
* Fix `StreamListenerAnnotatedMethodArgumentsTests` for `Locale.US`
for proper assertion against validation message
* Mention `spring.profiles.active` configuration property for the
binder specific environment
2019-01-21 15:40:55 +01:00
Oleg Zhurakousky
f080ca6cb0 GH-1554 resetting propagateOriginalContentType flag to be true 2018-12-13 15:26:04 +01:00
Oleg Zhurakousky
07b9adb0dc GH-1554 Introduced flag to disable 1.3 content type propagation
Introduced `spring.cloud.stream.propagateOriginalContentType` boolean property  on BindingServiceProperties
Resolves #1554
2018-12-12 16:50:28 +01:00
Oleg Zhurakousky
777eec819e GH-1527 Added special handling for text/* CT
Added special handling for 'texrt/*' conternt-type where unless the input type is declared to be byte[], the payload will always be converted to String

Resolves #1527
2018-11-15 09:11:49 +01:00
Oleg Zhurakousky
28990fe995 GH-1425 Added support for type-aware channels
Resolves #1425
2018-10-23 13:36:13 +02:00
Oleg Zhurakousky
a9904ee202 added initail fixes for default properties merge 2018-10-05 13:30:11 -04:00
Oleg Zhurakousky
274a5a9676 Polishing previous commit
Resolves #1382
Resolves #1491
2018-10-03 08:55:48 -04:00
David Harrigan
125840ddeb Add (javax.)Validation Support for Stream Listener
This change allows StreamListener method arguments annotated with @Valid to be
validated against a registered Validator.

Resolves #1382

-=david=-
2018-10-03 08:39:42 -04:00
Soby Chacko
c85660fba2 Spring Boot 2.1 upgrade
* Removed MockBinderRegistryConfiguration
* Move necessary beans from `BindingServiceConfiguration` which is now auto configurable into
  `BinderFactoryConfiguration` that is invoked by `EnableBinding` in order to avoid certain
  cyclic dependency issues. The beans moved are binding target factories of type
  `MessageSourceBindingTargetFactory` and `SubscribableChannelBindingTargetFactory` and their dependencies.
  As a side effect, `ContentTypeConfiguration` is also brought back at the `EnableBinding` level through
  `BinderFactoryConfiguration`.
* Restore `ServerController`  bean in SchemaServerConfiguation as the removal of it
  earlier introduced  some connectivity issues with the schema registry server.
* Update copyrights
2018-08-14 13:42:02 +02:00
Artem Bilan
776fe5da77 Fix aggregated application behavior
* After moving some bunch of beans from the `@EnableBinding` to the
auto-configuration for proper conditional lifecycle we need to be sure
that all those support beans are registered for each child context as
it was before after parsing imports on the `@EnableBinding`.
This way add `search = SearchStrategy.CURRENT` for all the conditions
in the `BindingServiceConfiguration`
* Fix `TestSupportBinderConfiguration` to rely only on the `Binder`
instance created once in the parent level.
This way when we use an aggregated application, only the parent context
creates for us a `TestSupportBinder` and all the child contexts reuse it.
* Register `BinderFactory` only once in parent ctx
2018-08-10 11:37:14 -04:00
Soby Chacko
ae445e73ac Spring Boot 2.1 upgrade related changes
* Instead of redefining `BinderTypeRegistry` as a bean in several tests, properly use spring.binders
  to define mock binders and then choose a default binder in tests in case of multiple binders in
  same spring.binders file.
* Remove `BindingServiceConfiguration` in `EnableBinding` and introduce it as a proper
  Spring Boot autoconfiguration class. Added `BindingServiceConfiguration` to spring.factories.
* Move `BinderFactory` bean into `BindingServiceConfiguration` and add `ConditionalOnMissingBean`
  on it so that downstream users can define new `BinderFactory` beans as part of autoconfiguration.
* Remove `ConditionalOnMissingBean` from the `BinderTypeRegistry` bean in `BinderFactoryConfiguration`
  as we don't expect this bean to be overridden.
* Remove previously added property `spring.main.allow-bean-definition-overriding` in several tests.
* Since web/actuator is optional now, remove unncecessarily setting server.port to `0` in tests
* Ensure that `BindersHealthIndicatorAutoConfiguration` is autoconfigured after `BindingServiceConfiguration`
  so that it has a `BinderFactory` available.
* Remove redefining `ServerController` bean in `SchemaServerConfiguration` as this is already created through
  component scanning and causing the bean overriding exceptions.
* Tests cleanup and polishing.

Resolves #1429, #1430
2018-08-10 11:27:11 -04:00
Soby Chacko
cb105ab0ec Upgrade Spring Cloud Build to 2.1.0
This upgrades to Spring Boot 2.1.0
Fix tests where the beans need to get overridden
Minor cleaning up
Polishing

Resolves #1426
2018-08-07 19:47:13 +02:00
Oleg Zhurakousky
37ecae4ab7 GH-1412 Ensured SpelExpressionConverterConfiguration present in multi-binder
Ensured that SpelExpressionConverterConfiguration is always present in the AC regardless of single or multi-binder application configuration
Polishing

Resolves #1412
2018-07-09 19:54:55 -04:00
Soby Chacko
a82c906913 Remove error.destination property
Remove the ability to bind global error channel directly to a broker destination through error.destination property.
The preferred way to consume error messages in a brokder destination is through the binder specific DLQ mechanism.
Global error channel may still be consumed by a ServiceActivator or StreamListener, but it is not bound to a broker destination.

Remove the internal bridge channel from the global error channel that is used for content type conversion.
Remove tests associated with this feature.
Deprecate class `SingleBindingTargetBindable` as this is not used by the framework any longer.
Docs polishing.

Resolves #1398
Resolves #1401
Resolves #1269
2018-06-27 09:11:50 -04:00
Soby Chacko
ae74c21720 Fixing compiler warnings
Fixing unchecked and deprecation warnings
Polishing

Resolves #1318
2018-03-21 14:55:22 -04:00
Gary Russell
12bd608908 Fix more trailing whitespace (tabs) 2018-03-12 10:26:46 -04:00
Oleg Zhurakousky
0463f7939d GH-1175 Removed dependency on spring-boot-starter-web
- Removed spring-boot-starter-web dependency from the core
- Polished AggregateApplicationBuilder to ensure it thriows meaningful exception when web is enabled but 'spring-boot-starter-web' is not on the classpath
- fixed Aggregator tests to defualt to no-web
- added spring-boot-starter-web to schema projects

Resolves #1175
2018-02-09 10:39:52 -05:00
Oleg Zhurakousky
ee06a605d9 addressed PR comments 2018-02-03 07:33:27 -05:00
Oleg Zhurakousky
9672a5b4df Fixed double conversion issue
- removed custom conversion from In/Out interceptors delegating everything to the available  MessageConverters
- added initial version of content-type TCK to validate various content-type conversion scenarious
- added initial content-type conversion matrix to the WIKI https://github.com/spring-cloud/spring-cloud-stream/wiki/Content-type-conversion-matrix

Resolves #1130
Resolves #1071
2018-02-03 07:33:27 -05:00
Soby Chacko
c1749ca866 New abstraction for StreamListener method setup invoker.
StreamListenerMethodSetupOrchestrator is an API hook that allows
downstram binder implementations or applications to inject custom
strategies to alter the default StreamListener adapter method invocations.

This PR primarily focuses on allowing customizations on the oubound side.
For the inbound, StreamListenerMethodSetupOrchestrator interface provides
a default implementation.

Corresponding refactoring in StreamListenerAnnotationBeanPostProcessor.
By default StreamListenerAnnotationBeanPostProcessor will use the current
strategies used for invoking the StreamListener adapters. If beans are provided
for orchestration, they take precedence however.

Test changes.

Further polishing in StreamListenerAnnotationBeanPostProcessor.

Resolves #1177
Resolves #1179
2018-01-18 11:59:43 -05:00
Oleg Zhurakousky
80fee48b4a 1146 Fixed early initialization in StreamListenerAnnotationBeanPostProcessor
Removed autowiring from StreamListenerAnnotationBeanPostProcessor in favor of late-binding callbacks
Fixed tests

Resolves #1146
2017-12-13 11:14:45 -05:00
Oleg Zhurakousky
d0be34f7cb Refactored MessageConverterConfigurer
- Separated InboundContentTypeConvertingInterceptor and OutboundContentTypeConvertingInterceptor to isolate logic that needs to be performed by such interceptors for *inbound* and *outbound* messages.
- Documented their purpose via javadocs
- Moved InboundMessageConvertingInterceptor to TestSupportBinder (for now) to only support MessageCollector's 1.3 behavior
2017-11-14 10:12:43 -05:00
Soby Chacko
53df5f5747 Native endoding/decoding changes for interceptors
Fixes #1109

- Disable outbound content type interceptor when nativeEndoding is enabled on the producer
- Disable inbound content type interceptor when nativeDecoding is enabled on the consumer

- Add a new flag in ConsumerProperties for useNativeDecoding

- Apply ContentType interceptor before the InboundInterceptor to ensure
  that content type set on the channel is applied on the message if content type
  is missing on the Message.

- Add tests for verifying interceptors are not applied when native encoding/decoding is enabled
- Fix a kryo integration test
- Remove Inbound interceptor from MessageCollector when native encoding is enabled on the producer
- Polishing
2017-11-12 17:01:20 -05:00
Oleg Zhurakousky
4e69ead7b4 GH-1126 Fixed default app port in Tests
Ensured AggregateApplicationTests, AggregateWithMainTest and AggregationTest arn't using default 8080 port
2017-11-08 13:10:47 -05:00
Oleg Zhurakousky
a7fdf6dbb2 GH-1106 Addressed backward/forward contentType compatibility issues
Fixes #1106

- This PR builds on the previous PR with commit hash 6c259be6... (pr/1112)
- Added support in AbstractBinderTests to create bindable channel based on determining channel input type based on it's name (i.e., *input*)
- Added LegacyContentTypeHeaderInterceptor to TestSupportBinder to restor the previous behavior of MessageCollector for cases
  where Message's payload content type is a variant of 'text'.
- Restored tests that use MessageCollector to depend on proper payload type
- Added 'deserialize' routine back to MessageSerializationUtils
- Polished MessageConverterConfigurer.LegacyContentTypeHeaderInterceptor to remove conditional original-content-type header logic
- Removed default contentType from BindingProperties
- Restored tests that use MessageCollector to depend on proper payload type
- polishing
- fixed Kryo/Java serialization
- Fixed ser/de for "application/json" and contentType equals
- Fixed of ser/de of JSON strings to ensure that Strings are not re-quoted
- Fixed how we comparing contentTypes
- more polishing
- Fixed NPE in MessageSerializationUtils
- Make bindings and consumer groups in new tests added to AbstractBinderTests mutually exclusive
2017-11-07 11:21:13 -05:00
Soby Chacko
6c259be62b Legacy cotent-type changes for the consumer
- Remove binding config property `legacyContentTypeHeaderEnabled` that was
  introduced to enable legacy content type handling
- Enable LegacyContentTypeInterceptor in 2.0 always, but bypass any
  legacy content type handling if the message received is from
  a 2.0 producer by checking on the version header
- Introdce a new BinderHeader property for version
- Fix the LegacyContentType related tests
- Remove the check for originalContentType in ReceivingHandler when
  the payload received is a byte[]
- Remove unnecessary deserializePayloadIfNecessary calls in ReceivingHandler
- Remove deprecated deserializePayload methods in AbstractBinder
  and MessageSerializationUtils

Partly fixes #1106
Fixes #1110
2017-10-26 13:05:10 -04:00
Soby Chacko
08504952e6 Default interceptor for legacy contentType
Fixes #1057

Enable consumers to convert from originalContentType to contentType in the case of
legacy producers sending messages with originalContentType header.
By default, this conversion will not happen and only be acitvated by setting
`spring.cloud.stream.bindings.input.legacyContentTypeHeaderEnabled` to true.
2017-10-06 18:52:22 -04:00
Vinicius Carvalho
171f034a8c Content type redesign
Fixes #992, #1050, #1051, #1052

Adding custom jackson converter with some tests
Adds kryo message converter to replace codec
Checkstyle changes

Removing codec support
- Removed codec dependency from AbstractBinder
- MessageSerializationUtils is almost an empty shell for now, just to
  keep code compiling until we get EmbeddedHeaders interceptors
- Updated Kryo tests

Removing codec module from build
Added a new Annotation for custom converters '@StreamConverter'
Fixed some tests with new expected behavior
Moved broken tests to a temporary package to keep track of progress
Fixed KryoConverter to fail based on headers
Fixed a couple of more tests

Making converters strict to only convert their corresponding contentType
Bypassing conversion for ErrorMessages

* Configuring SI ConfigurableCompositeMessageConverter
 - Moved ContentType related beans into separate configuration
 - Configured SI ConfigurableCompositeMessageConverter to use same
   converters as Stream does (for ServiceActivator)
- TupleConverter should return byte[] as all other converters
- Fixed tests

* Fixes tests
 - Revert to Boot 2.0.0.M3. Snapshots breaking actuator
 - Checkstyle fixes
 - Disable JsonUnmarshalling as a catch all converter

Fixing Schema tests
Fixing Metrics tests
Fixing reactive tests
applying checkstyle fixes

 * Adding new content type tests
 - Fixed ContentTypeInterceptor misusage of default mimeType

Changing contentType doc section
Improving doc section
Last minute polish
Fixing BinderTests to use bytes to compare messages
Applied changes to Base Binders test to use the new contentType handling mechanism
PR review fixes

Renaming StreamConverter -> StreamMessageConverter
2017-10-05 10:35:51 -04:00
Janne Valkealahti
4f72a10bc6 Upgrade build to boot 2.x
- Pump up version to 2.0.0
- Some generic polish
- All changes around breakage with boot 2.x
- Some boot classes has been moved around
- You can't no longer have binding key ending with
  camelCase.
- New Binder now has illegal keys.
- Some changes to tests as we can directly do end-to-end
  testing with ENV_VAR_FORMAT as normal keys
- Spring data repo changes as now uses Optional
- Remove relaxed binder and its tests in favor of new Binder
- Some mockito api changes
- One Ingored test TextPlainToJsonConversionTest.testTextPlainToJsonConversionOnInput
- Relates to #935

Cache metric export properties

Add code formatting guidelines

Rearranged files
2017-10-05 10:31:09 -04:00
Soby Chacko
9fc51cb6e2 GH-1080: Fix StreamListener methods for proxies
Fix #1080

When class with `@StreamListener` method is proxied we end up
with the double target subscribers registration because we meet
the same method multiple times during `ReflectionUtils.doWithMethods()`

* Use `ReflectionUtils.getUniqueDeclaredMethods()` instead to extract
the list of method candidates

**Cherry-pick to 1.2.x**
2017-09-27 14:04:36 -04:00
Soby Chacko
22141a8dce GH-1028: error binding Content-Type negotiation
Fixes spring-cloud/spring-cloud-stream/#1028

Adding unit test to verify message conversion for error channel

Instead of directly binding on the error channel, use a bridge channel
and apply custom converters on that channel and then bind

Make corresponding test changes

renaming key used for error

Adding tests for exceptions on error channel when content type is set
2017-07-31 11:16:47 -04:00
Gary Russell
205d4579a4 GH-1010: @StreamListener: Fix Header Propagation
Fixes #1010

Propagate headers by default.

Add a `copyHeaders` property to `@StreamListener` to allow suppression of header propagation.

Honour header propagation settings
2017-07-18 13:50:54 -04:00
Marius Bogoevici
51deb128f0 Option to suppress header propagation with SI message handlers
Add `SpringIntegrationProperties` class with
`spring.cloud.stream.integration` prefix for managing
Spring Integration properties.

Add `spring.cloud.stream.integration.messageHandlerNotPropagatedHeaders`
for controlling headers propagated by reply producing handlers.

Fix #943

Remove SI version override
Cleanup

* Simple polishing according PR comments
2017-06-19 10:59:47 -04:00
Ilayaperumal Gopinathan
bd002e4aaf Add code formatting guidelines
Add 'eclipse' folder containing Eclipse code
formatter configuration and instructions how to use
 it.

Update rule for join_wrapped_lines

 - Set to `false`

Resolves #930

Update README

Address review comments
2017-05-15 13:03:45 -04:00
Marius Bogoevici
9ea4ff324c Convert byte[] via text/plain to String
Fix #898

When the payload is `byte[]` ensure that the
String is the String representation, not the
toString() conversion result.
2017-04-04 14:29:52 +05:30
Marius Bogoevici
7dd5e50f82 Leniently support treating input Strings as JSON
Fixes #871

* Only support conversion based on `text/plain` header if target type is String;
2017-03-29 09:17:23 -04:00
Ilayaperumal Gopinathan
ba18c01602 Avoid eager creation of bound target beans
- At StreamListenerBeanPostProcessor, avoid eager creation of inbound/outbound target beans whenever possible
  - Use `applicationContext.getType(targetName)` instead of `applicationContext.getBean(targetName)` which checks the type of target beans from bean factory instead of creating the bean eagerly.
  - For declarative method invocation, `applicationContext.getBean` is needed as it requires the actual bean as its argument

Resolves #767

Update the test

 - ignore bean definition not found exception when the bean definition doesn't exist
2017-03-24 16:12:30 -04:00
Ilayaperumal Gopinathan
8230a8b348 Fix StreamListener method with no explicit declarative method params
- Treat methods with Object arguments as 'handler' as opposed to 'declarative'
 - Add test

Resolves #844

Check object type to decide handler method
2017-03-13 14:13:27 -04:00
Gary Russell
bd1454bfff kGH-21: Add BinderHeaders.PARTITION_OVERRIDE
See spring-cloud/spring-cloud-stream-binder-kafka#109
See #851

Add Prefix to Partition Headers

originalContentType remains as-is for backwards-compatibility.

Enhance Javadoc
2017-03-10 13:38:18 -05:00
Ilayaperumal Gopinathan
f14d4d85c5 Add tests for PartitionInterceptor's preSend
- Check header updates with/without explicit 'partition' header in the message
2017-03-10 15:04:20 +05:30
Marius Bogoevici
a67fe02fd7 Handle @StreamListener properly as meta-annotation
Fix #841

* Use `AnnotatedElementUtils`
* Formatting for the additional test
2017-03-07 14:34:11 -05:00
David Turanski
ddce282147 Add failing test 2017-03-07 12:29:39 -05:00
Ilayaperumal Gopinathan
086895f6f8 Fix non self-contained aggregate application binding
- Remove conditionalOnMissingBean check on the necessary beans that are required for exernal bindings of the child application
 - Add test to verify

Resolves #816
2017-02-20 17:38:51 +05:30
Marius Bogoevici
076f0ac1cb Add Dispatching Capabilities to @StreamListener
`@StreamListener` has support for a `condition` parameter,
that contains a SpEL expression that is evaluated before the
method is invoked.

Fix #682

Move StreamListenerMessageHandler as a top level class

Use dispatching and add test

Refactor dispatching mechanism

Throw error when conditions are used in declarative mode

Make StreamListenerAnnotationBeanPostProcessor overridable

Remove unused field in test

Address some PR comments

Add placeholder resolution

Update how multiple matches work with return values

- Methods with return values are not allowed to specify conditions
- If multiple matches are detected (e.g. multiple methods without
  conditions, or a mix of methods with and without conditions)
  checks that all of them have no return value;
2017-02-17 13:47:43 -05:00