Commit Graph

10262 Commits

Author SHA1 Message Date
Gary Russell
f9adcbd3ec GH-112: Use s-k-test Utilities
Resolves #112
2020-06-25 11:28:45 -04:00
Artem Bilan
a9456330ad Remove KafkaProducerMH.enableHeaderRouting
Since the latest Spring Kafka introduces `RECEIVED_` headers on the receiving adapter,
we don't have clashes any more with the `kafka_topic`, `kafka_partition`  headers on the producing adapter

Since we are in the `2.0` code line it is safe to just remove the `enableHeaderRouting` even if it is a breaking change.

Doc Polishing
2020-06-25 11:28:45 -04:00
Gary Russell
93e81f74c8 Add CheckStyle, travis; Fix Outbound, Add Tests
Polishing - PR Comments

Regenerate Gradle `wrapper`
2020-06-25 11:28:45 -04:00
Gary Russell
a030be3d7e Use spring-kafka in s-i-kafka
Update to s-i 1.0.0.M1

Polishing

Fix Readme
2020-06-25 11:28:45 -04:00
Artem Bilan
49e533410c INTEXT-220: Add WindowingOffsetManager
JIRA: https://jira.spring.io/browse/INTEXT-220

Add `WindowingOffsetManagerTests`

Rework `WindowingOffsetManager` to be "resettable" on `flush()`.

* `flush()` `WindowingOffsetManager` on each `getOffset()`, `resetOffsets()` and `deleteOffset()`.
Exactly for the `RingBufferProcessor` processor completion to allow to have the access to "real" offset with those operations over `delegate`.

* Since Reactor's `Stream` isn't restartable create an new instance recursively from the `onComplete()`
2020-06-25 11:28:44 -04:00
Artem Bilan
a98aba36c7 INTEXT-216: KafkaProducerContext.beanName as null
JIRA: https://jira.spring.io/browse/INTEXT-216

Having the default value for the `NamedComponent` contract (`beanName`)
 doesn't allow us to override (generate) the unique bean name for the component.

 Clean up `KafkaProducerContext.beanName` to `null` by default.

**Cherry-pick to 1.3.x**
2020-06-25 11:28:44 -04:00
Gary Russell
d3e724d134 INTEXT-213: Outbound Adapter: Add RH Advice Chain
JIRA: https://jira.spring.io/browse/INTEXT-213

s/1.4/2.0/
2020-06-25 11:28:44 -04:00
Artem Bilan
5a25a9bd09 GH-96: Catch NPE from ClientUtils
Fixes: https://github.com/spring-projects/spring-integration-kafka/issues/96
2020-06-25 11:28:44 -04:00
Björn Häuser
079fa03563 Javadoc: Use the correct value "EarliestTime"
-2 is the value for "OffsetRequest#EarliestTime"
2020-06-25 11:28:43 -04:00
Artem Bilan
9208f74347 Fix deprecation warning 2020-06-25 11:28:43 -04:00
Marius Bogoevici
d6a3b343aa GH-70 Allow the client to discover new brokers
Fixes https://github.com/spring-projects/spring-integration-kafka/issues/70

* Refactor the message listener container to finish tasks on broker connection failure
and spawn new ones whenever a new broker is discovered;
* Add an explicit disconnect operation on the ConnectionFactory to release the connection
on failure;
* Other improvements and test refactorings;

Optimize the fetch logic

Add test for recognizing new brokers

Formatting

Formatting and refactoring

Test improvements, polishing
2020-06-25 11:28:43 -04:00
Marius Bogoevici
4ff25fd894 Prevent Delay on Container Shutdown
Prevent the KafkaMessageListenerContainer from blocking during shutdown

If the RingBufferProcessor used by the KafkaMessageListenerContainer blocks during
processing, it may be prevented from handling the onConsume() notfication which is
the shutdown indicator. Thus, the stopping of the component may be effectively
delayed.

To solve this, the processing task of the RingBufferProcessor is wrapped in a
cancelable task that is managed by one of the container components, and canceled
on shutdown, allowing for the interruption of the processing thread. Subsequently,
all messages cached by the ringbuffer are discarded, without being processed or
acknowdledged.

Additionally, an option for acknowledging processed messages on success only is
added. This allows the component to run continuously and advance even in the case
of sporadic errors, but to resume from the last successfully processed message.

Polishing
2020-06-25 11:28:43 -04:00
Marius Bogoevici
d6f895977a Add header routing setting to KafkaOutboundChannelAdapter
Addressing PR comments

Simple polishing
2020-06-25 11:28:43 -04:00
Artem Bilan
ba96e7ce71 GH-84, GH-69 Improve Partitioner deprecation note
Fixes GH-84 (https://github.com/spring-projects/spring-integration-kafka/issues/84)
Fixes GH-69 (https://github.com/spring-projects/spring-integration-kafka/issues/69)

* The deprecation for the `partitioner` option hasn't mentioned the `partition-id` (`partition-id-expression`) option.
* Add built-in conversion for the `String <-> byte[]` to avoid serialization for Strings
* Expose `charset` option to configure `String <-> byte[]` conversion.
* Fix `deprecation` message for the `KafkaConsumerContextParser`

Extract `StringBytesConverter`
2020-06-25 11:28:42 -04:00
Artem Bilan
0f756cc1ec INTEXT-139: Deprecate High Level Consumer Adapter
JIRA: https://jira.spring.io/browse/INTEXT-139

Revert removal for test and deprecate them
2020-06-25 11:28:42 -04:00
Artem Bilan
28aca5332e INTEXT-206: Don't create extra consumers
JIRA: https://jira.spring.io/browse/INTEXT-206

The previous logic in the `ConcurrentMessageListenerDispatcher` create exactly `consumers`
number of `QueueingMessageListenerInvoker`, although we use only the `partitions.size()`.

Fix the logic to the `this.consumers = Math.min(partitions.size(), consumers);` to create maximum
consumers according to the partitions count.
2020-06-25 11:28:42 -04:00
Marius Bogoevici
464ca70aa6 Add Support for ProducerListener
Introduces the concept of ProducerListener, that can be injected in a ProducerContext and receive notifications when a message has been acknowledged or rejected.

While the Kafka API currently supports providing a Callback, it requires the creation of a distinct instance for receiving contextual information about the message that has been sent or rejected. This allows the use of the Callback mechanism with an injectable ProducerListener strategy.

Polishing and Callback Integration Test
2020-06-25 11:28:42 -04:00
Chris Lemper
d8a1115f1f Kafka native offset implementation
Fixes #79 (https://github.com/spring-projects/spring-integration-kafka/pull/79)

Adds an implementation for offset management based on Kafka's own offset management support

Update copyright and use fill name in author tag.

Refactoring the native offset manager

Remove unused imports

Polishing
2020-06-25 11:28:42 -04:00
Artem Bilan
b6be2a33e7 Move XSD to the proper directory 2020-06-25 11:28:41 -04:00
Marius Bogoevici
b67fa489cb Adding a deprecated setter for KafkaProducerMessageHandler.setPartitionExpression() for backwards compatibility 2020-06-25 11:28:41 -04:00
Abhijith Prabhakar
32715799d9 Issue#67: fixing custom paritioner issue 2020-06-25 11:28:41 -04:00
Marius Bogoevici
fd93f91a78 Ignore broker bounce tests 2020-06-25 11:28:41 -04:00
Marius Bogoevici
3a5c2ffd77 Add test for producer key and payload cast 2020-06-25 11:28:40 -04:00
Gamal
21600a275d convertPayloadIfNecessary change to use Value Class Type
convertPayloadIfNecessary is using getProducerMetadata().getKeyClassType() when it should use getProducerMetadata().getValueClassType()
2020-06-25 11:28:40 -04:00
Marius Bogoevici
9b49e9a673 Deprecated Connection#getLeaders() - simplify DefaultConnectionFactory tests 2020-06-25 11:28:40 -04:00
Marius Bogoevici
9ddc4e6d12 Check if leader election is complete during tests 2020-06-25 11:28:40 -04:00
Marius Bogoevici
108197cffd Temporarily ignore bounce tests due to strain on CI environment 2020-06-25 11:28:40 -04:00
Martin Dam
bdb46760ad Support for sending messages synchronously to the Kafka broker.
Adds two fields to the producer-configuration that allows to set the send mode (async or sync) and an optional timeout in sync mode. Default behavior is async.
This allows for an upstream application to verify that the message have been handed off to Kafka following the delivery options specified, and not just residing in memory at the producer.
2020-06-25 11:28:39 -04:00
Artem Bilan
0065950830 GH-60: Get rid of HashCodeBuilder usage
Fixes #60 (https://github.com/spring-projects/spring-integration-kafka/issues/60)

* Upgrade to Gradle 2.5 and other dependencies
2020-06-25 11:28:39 -04:00
Artem Bilan
c1e1166895 Fix OutboundTests for required BeanFactory 2020-06-25 11:28:39 -04:00
Gary Russell
31439da037 Add High Level Consumer Integration Test
http://stackoverflow.com/questions/31668330/how-to-extract-the-data-from-a-kafka-inbound-message-with-spring/31681294#31681294

Polishing
2020-06-25 11:28:39 -04:00
Marius Bogoevici
c7f009f544 INTEXT-180: Fix ListenerContainer fetch pool size
JIRI: https://jira.spring.io/browse/INTEXT-180
2020-06-25 11:28:39 -04:00
Justin Walsh
19a27d7759 Fixed schema documentation for zookeeper-connect element 2020-06-25 11:28:38 -04:00
Artem Bilan
7695964e64 INTEXT-175: Fix IEC population
JIRA: https://jira.spring.io/browse/INTEXT-175

Since `IntegrationEvaluationContextAware` infrastructure had had wrong design and has been deprecated in the SI-4.2, change its usage to the proper way according to the SI-core recipes.

Tested against Spring IO-2.0.
2020-06-25 11:28:38 -04:00
Marius Bogoevici
b77f621c51 INTEXT-175 Replace onInit() check for IntegrationEvaluationContext
- replace the `onInit()` check for an `IntegrationEvaluationContext` with a getter
2020-06-25 11:28:38 -04:00
Marius Bogoevici
0956c0ad5a INTEXT-172 Make potentially long-running tasks SchedulingAwareRunnable 2020-06-25 11:28:38 -04:00
Marius Bogoevici
3cb57e96eb INTEXT-170 Use a custom MessageHeaders class
- revert to using a custom KafkaMessageHeaders class directly;
- avoid the use of MutableMessageHeaders and the subsequent assignment of ids and timestamps within a GenericMessageTemplate
2020-06-25 11:28:38 -04:00
Marius Bogoevici
35be1cb4fb QueueingMessageListenerInvoker fixes
- create latch before initiating shutdown;
- do not set latch to null inside onComplete();
- synchronize start and stop;
2020-06-25 11:28:37 -04:00
Marius Bogoevici
d0c0adc5bb Check that the queueSize is a positive integer 2020-06-25 11:28:37 -04:00
Gary Russell
1b28a7b863 INTEXT-169: Ensure queueSize is a Power of 2
JIRA: https://jira.spring.io/browse/INTEXT-169

Error from lmax is too far removed from configuration.
2020-06-25 11:28:37 -04:00
Marius Bogoevici
d475a79d83 Do not refresh metadata eagerly: 2020-06-25 11:28:37 -04:00
Marius Bogoevici
38856ee984 Add Reactor based ringbuffer
restart support

blocking stop

Test fixes

Ensure that an executor can be set externally

Polishing according PR comments
2020-06-25 11:28:36 -04:00
Marius Bogoevici
d8df11c2aa INTEXT-168 Upgrade to Kafka 0.8.2.1
JIRA: https://jira.spring.io/browse/INTEXT-168

- Replace producers with the new producer API
- Change KafkaProducerContext and ProducerConfiguration to match the new Producer's behaviour (i.e. providing partition as argument)
- support using the `partitionId` message header for targetting specific partitions;
- allow using a SpEL expression for partitioning;
- remove configurations that do not apply anymore, i.e. async (new producer is always async), batch size as message count, etc.
- add new configuration options wherever necessary;
- tweak schema - allow reuse of Encoders and Partitioners if available;

TODO: Add missing unit tests;

Fixes and polishing
2020-06-25 11:28:36 -04:00
Marius Bogoevici
fbe2975ed4 INTEXT-165 Recovery when cluster inaccessible
JIRA: https://jira.spring.io/browse/INTEXT-165

- retry fetching metadata until either successful or container stopped;
- do not stop the fetch task on connection errors, and handle it as a case when all partitions have moved;
- test broker stopped case + test enhancements for supporting broker restart;

Unused imports

Removed sysout calls from framework code

Reduced socket timeout, to improve timing on failover tests
2020-06-25 11:28:36 -04:00
Kevin Mooney
df652634a5 Fix expected type for listener-container attr 2020-06-25 11:28:36 -04:00
Marius Bogoevici
790d899953 INTEXT-159 DefaultConnectionFactory thread safety
- protect creation of connections with the lock as well, ensuring that it doesn't clash with refreshMetadata();
2020-06-25 11:28:36 -04:00
Marius Bogoevici
1e6e7b9bbf INTEXT 156-157
JIRA: https://jira.spring.io/browse/INTEXT-156
https://jira.spring.io/browse/INTEXT-157

- `KafkaMessageListenerContainer#stop()` returns only after the container has been effectively stopped, i.e. no more messages are dispatched to the listeners;
- add a configurable timeout property to prevent the previous operation from blocking indefinitely;
- create separate XSDs for 1.0 and 1.1 schemas;

Corrections after review

- removed 1.0 schema
- removed time-sensitive tests

Corrections after review

- removed 1.0 schema
- removed time-sensitive tests
- removed unused logger in QueueingMessageListenerInvoker

Clear messages after stopping

Clear partitionsByBrokersMap

Polishing imports and properties order
2020-06-25 11:28:35 -04:00
Marius Bogoevici
3e6a796e85 Improve performance of header generation
Using a regular HashMap instead of GS Collections' regular map improves performance, as the latter is more expensive to create.

Cleanup - put  references back
2020-06-25 11:28:35 -04:00
Gary Russell
52d218988b INTEXT-154: Namespace Support for New Features
JIRA: https://jira.spring.io/browse/INTEXT-154, https://jira.spring.io/browse/INTEXT-138
2020-06-25 11:28:35 -04:00
Marius Bogoevici
3ade92ba14 INTEXT-152 Improve message generation strategy
JIRA: https://jira.spring.io/browse/INTEXT-152

- upgrade to Spring Integration 4.1 and Spring 4.1 for MessageHeaders subclassing support;
- by default, the KafkaMessageDrivenChannelAdapter will create an optimized version of KafkaMessage;
- add settings for avoiding expensive ID and timestamp generation by default, with the option of turning them on;
- add a setting for reverting to superclass MessageBuilderFactory where that is necessary;

* JavaDocs polishing
2020-06-25 11:28:35 -04:00