Commit Graph

10321 Commits

Author SHA1 Message Date
Gary Russell
7fae571c2d Changes for compatibility with Spring Kafka 2.3
Also remove test for bad partition in DSL tests - the send now gives an error
about the topic not being present in metadata instead of "not in range".

Use sync for publishing in DSL tests, to fail fast.
2020-06-25 11:28:58 -04:00
Artem Bilan
daedfb9210 Upgrade dependencies and fix issues 2020-06-25 11:28:58 -04:00
Gary Russell
e5b861dcea Remove unnecessary throws Exception clause 2020-06-25 11:28:57 -04:00
Gary Russell
1873e9ae41 GH-211: MessageSource acks; fix concurrency
Fixes https://github.com/spring-projects/spring-integration-kafka/issues/211

Use `ConcurrentHashMap` with synchronized set values to avoid concurrency issues
when acks are processed on multiple threads.
2020-06-25 11:28:57 -04:00
Gary Russell
759e0e236d Nullable fixes 2020-06-25 11:28:57 -04:00
Gary Russell
19c3c4607f Fix TODOs in outbound channel adapter
- always use `successChannel` for metadata
- unwrap `ExecutionException`
2020-06-25 11:28:57 -04:00
Artem Bilan
f29bd3e322 GH-212: Add ConsumerSeekAware impl to Inbounds (#213)
* GH-212: Add ConsumerSeekAware impl to Inbounds

Fixes spring-projects/spring-integration-kafka#212

**Cherry-pick to 3.0.x**

* GH-212: Add ConsumerSeekAware impl to Inbounds

Fixes spring-projects/spring-integration-kafka#212

* Introduce a new `IntegrationKafkaHeaders.CONSUMER_SEEK_CALLBACK`
header to be populated to messages for sending to the channel
* Populate that header from the `KafkaInboundGateway` and
`KafkaMessageDrivenChannelAdapter` into the message from the
`seekCallBack` property if `ListenerContainer` is single-threaded or
from the `ThreadLocal<ConsumerSeekAware.ConsumerSeekCallback>` otherwise;
and only if newly introduced `setAdditionalHeaders` is `true`
* Populate `seekCallBack` property or `ThreadLocal<?>` from the
`registerSeekCallback()` implementation from the internal listeners
* Add `setOnPartitionsAssignedSeekCallback(BiConsumer)` and
`setOnIdleSeekCallback(BiConsumer)` options to react for the appropriate
event from the underlying container and perform appropriate seek management
* Add new options to the DSL classes and cover them with tests, including
check for new `IntegrationKafkaHeaders.CONSUMER_SEEK_CALLBACK` header

**Cherry-pick to 3.0.x**

* Address PR comments: remove unnecessary API

* *Polishing `setOnPartitionsAssignedSeekCallback()` JavaDocs
*Close producers in the `KafkaProducerMessageHandlerTests`
2020-06-25 11:28:57 -04:00
Gary Russell
bedc0c8fdc GH-209: Upgrade to kafka-clients 2.0.0
Fixes https://github.com/spring-projects/spring-integration-kafka/issues/209

* README Polishing
2020-06-25 11:28:56 -04:00
Artem Bilan
0c1cfbc977 Upgrade to SI-5.1 M1, SK-2.2 M1
* Fixes according the upgrades
* Polishing some code style
2020-06-25 11:28:56 -04:00
Gary Russell
8decbe7810 GH-204: DSL Register container as bean if needed
Fixes https://github.com/spring-projects/spring-integration-kafka/issues/204

When an external container is provided to the DSL, register it as a bean
if it is not already a bean.

Polishing id from PR comments; add gateway support too.

* Polishing JavaDocs and omissions in the test-case
2020-06-25 11:28:56 -04:00
Artem Bilan
e296d66a4b Kotlin compatibility: hide recursive generics
Related to https://jira.spring.io/browse/INT-4458

**Cherry-pick to 3.0.x**
2020-06-25 11:28:56 -04:00
Gary Russell
1e006c9de7 Fix imports 2020-06-25 11:28:55 -04:00
Gary Russell
c807ed5335 Fix typo in warning log. 2020-06-25 11:28:55 -04:00
Artem Bilan
1be6a6a3fa Start version 3.1 for compatibility with SK-2.2 2020-06-25 11:28:55 -04:00
Gary Russell
fc3f33671b GH-198: Support pause/resume on inbound adapter
Resolves https://github.com/spring-projects/spring-integration-kafka/issues/198

You can now pause/resume the consumer.

Any records previously fetched will be processed before the pause takes effect.
The listener container requires an `idleEventInterval`, a resume will take effect
on the next `ListenerContainerIdleEvent`.

* Delegate Pausable methods to listener container

Requires https://github.com/spring-projects/spring-kafka/pull/584

* Polishing
2020-06-25 11:28:55 -04:00
Gary Russell
d13551e6c3 Revert "GH-198: Support pause/resume on inbound adapter"
This reverts commit 7befa83ba87058540f624ec1bf33fcabf054f3b5.

Temporary revert; pushed to 3.0.3
2020-06-25 11:28:55 -04:00
Gary Russell
17ea7dace7 GH-198: Support pause/resume on inbound adapter
Resolves https://github.com/spring-projects/spring-integration-kafka/issues/198

You can now pause/resume the consumer.

Any records previously fetched will be processed before the pause takes effect.
The listener container requires an `idleEventInterval`, a resume will take effect
on the next `ListenerContainerIdleEvent`.

* Delegate Pausable methods to listener container

Requires https://github.com/spring-projects/spring-kafka/pull/584

* Polishing
2020-06-25 11:28:54 -04:00
Gary Russell
7b7bcf1014 Fix Race in InboundGatewayTests
The debug log indicates that the reply was successfully sent but never
received. My working theory is that the reply consumer got the reply
during the `poll()` to force the subscription.

Start the consumers before the replies are sent.

I will also add code to `KafkaEmbedded` to seek to beginning all topics
if necessary.
2020-06-25 11:28:54 -04:00
Gary Russell
98a7c4241d Trace logging for InboundGatewayTests 2020-06-25 11:28:54 -04:00
Gary Russell
accd2d9088 Debug logging for InboundGatewayTests 2020-06-25 11:28:54 -04:00
Gary Russell
bd774de5c0 Support transaction initiation in ob endpoints
* Use template.isTransactional()
2020-06-25 11:28:54 -04:00
Gary Russell
2b292f2a7d GH-161: Implement Gateways
Resolves https://github.com/spring-projects/spring-integration-kafka/issues/161

Initial commit - outbound

TODO: inbound, DSL, XML, Docs

Fix reply topic.

Polishing - don't leak internal headers; don't propagate outbound headers (topic etc.).

Polishing

Validate reply topic and partition against replying template.

DSL

Checkstyle fixes.

Add inbound gateway.

Inbound DSL

Polishing - PR comments.

Polishing - PR comments

More polishing

Increase test timeouts.

Increase test timeouts.

* Code style polishing
* Fix `KafkaInboundGatewaySpec.getComponentsToRegister()` to `get()`
on Specs
* Remove `getContainer()` in the `KafkaMessageListenerContainerSpec` in
favor of `get()` in the `IntegrationComponentSpec`
2020-06-25 11:28:53 -04:00
Mark
86d8373084 Polish synchronization in KafkaMessageSource
* Remove volatile from running flag

As running is always accessed through `KafkaMessageSource` monitor use existing `synchronized` to guard access to it.
Also move setting `running=true` from consumerMonitor in `createConsumer()` method to `doReceive()` as it's guarded by needed lock

* Extract common stopping consumer logic
2020-06-25 11:28:53 -04:00
Gary Russell
a997740c29 More Lifecycle Polishing
- `null` the consumer on `stop()`
- set `running` to true on first receive if needed
2020-06-25 11:28:53 -04:00
Gary Russell
28b4dd814c Remove pause/resumer; add Lifecycle
Pause/resume was too chatty - user can avoid a rebalance with `max.poll.interval.ms`.

Implement `Lifecyle` and `close()` the consumer on `stop()`.
2020-06-25 11:28:53 -04:00
Gary Russell
d738447005 GH-189: MessageSource - remove seek after poll
Fixes https://github.com/spring-projects/spring-integration-kafka/issues/189

If the DKCFactory is being used, force the `max.poll.records` property to 1.
Otherwise, throw an `IllegalArgumentException`.
2020-06-25 11:28:53 -04:00
Gary Russell
23bc29958c GH-184: Polishing - user rebalance listener
Needed by the SCST Kafka Binder

* GH-184: Polishing - add raw header option
2020-06-25 11:28:52 -04:00
Gary Russell
b44dab40fa GH-184: Add Polled MessageSource
Resolves https://github.com/spring-projects/spring-integration-kafka/issues/184

Polishing - changes in core

Pause/Resume; Add integration tests

Synchronize all consumer operations on the consumer, to support noAutoAck()

Polishing - PR Comments

More polishing

Major rework - see commit comment

- only fetch one record at a time (warn log and seek if max.poll.records incorrect)
- when an application has multiple outstanding records,
 - track records; apply commits in the right order, deferring if necessary
 - when requeued, mark later offsets as rolled back to prevent commits
- Support transactions
 - start/end transactions
 - provide access to the producer

Fix transaction synchronization

- if there is an existing Kafka transaction, participate in it
- if not, bind a new transactional resource to the thread - allows a KafkaTemplate to
  participate by utilizing the producer factory message header
- if there is an existing non-kafka transaction, sync the kafka transaction with it

Check for KafkaMessageHeaders when building the message.

Polishing - PR Comments

Simplify AckInfo

Remove internal transaction support - the user can start a transacion before calling receive
and send offsets to the transaction using a KafkaTemplate.

Polishing

* Simple polishing according IDEA warnings
* Upgrade to Gradle 4.4.1
* Some upgrades and dependencies polishing
2020-06-25 11:28:52 -04:00
Gary Russell
29973e525d GH-185: Add deliveryAttempts header with retry
Resolves: https://github.com/spring-projects/spring-integration-kafka/issues/185

When a `RetryTemplate` is wired into the message-driven adapter, add
and increment an `AtomicInteger`-valued header.

See https://jira.spring.io/browse/INT-4369

* Actualize Copyright in the affected classes
2020-06-25 11:28:52 -04:00
Gary Russell
fb9dd91644 Fix test case for previous commit 2020-06-25 11:28:52 -04:00
Gary Russell
0580252f7a Polishing - PR Comments 2020-06-25 11:28:51 -04:00
Gary Russell
b65f59cd67 GH-180: Add headerMapper() to DSL
Fixes https://github.com/spring-projects/spring-integration-kafka/issues/180
2020-06-25 11:28:51 -04:00
Gary Russell
7aa04d3224 GH-175: XML Support for Error Handling
Resolves spring-projects/spring-integration-kafka#175

__cherry-pick to 2.3.x__
2020-06-25 11:28:51 -04:00
Gary Russell
857980349e GH-172: Add Success and Failure Message Channels
Resolves https://github.com/spring-projects/spring-integration-kafka/issues/172

Use `ErrorMessageStrategy` to build an error message in the event of a failure.

Update to SI 4.3.12.

Polishing - PR Comments - Use standard outputChannel (if configured) for success.

Polishing - PR Comments

Javadoc Polishing

* Polishing `@since` in JavaDocs

* Upgrade to Checkstyle 8.1, SI-5.0.B-S
* Adjust `RequireThis` rule and fix vulnerabilities

# Conflicts:
#	build.gradle
#	src/test/java/org/springframework/integration/kafka/outbound/KafkaProducerMessageHandlerTests.java
2020-06-25 11:28:51 -04:00
Gary Russell
37ffd4e2e9 GH-170: Add Support for Kafka Headers
Resolves https://github.com/spring-projects/spring-integration-kafka/issues/170
2020-06-25 11:28:51 -04:00
Artem Bilan
8d15b9582a Upgrade to SK 2.0 M3, Gradle 4.0.1 2020-06-25 11:28:50 -04:00
Gary Russell
c219a43c58 SCSt-913: Add Support for Enhanced Error Handling
- bind input message, raw record to retry context
- support recover without retry (recover after a single shot)

Change RecoveryCallback from <Void> to <Object>

Actually <? extends Object> for backwards compatibility.

Changes needed for the latest updates to Spring Integration

Now that the 4.3.10.BS artifacts are in artifactory.

Suppress Deprecation Warnings

checkstyle and PR Comments

Javadocs and TL.remove()

Fix Attributes Logic

Polishing - PR Comments - Enhanced error message for conversion errors.

Make errorChannel and retryTemplate mutually exclusive

Fix TL.remove with retry.

* Polishing `build.gradle` before merging

Fix TL.remove with retry.

Remove mavenLocal()

Conflicts:
	build.gradle
	src/main/java/org/springframework/integration/kafka/inbound/KafkaMessageDrivenChannelAdapter.java

* Use `KafkaHeaders.RAW_DATA`
* Use `ErrorMesage` directly
* Adapt DSL test to use `ErrorMessageSendingRecoverer`
2020-06-25 11:28:50 -04:00
Artem Bilan
8d18799ca8 Adapt Java DSL to the latest SI
* Add ability to specify `id` for `MessageListenerContainer` and
`KafkaTemplate` beans configured internally and exposed as beans
by the DSL

checkstyle
2020-06-25 11:28:50 -04:00
Gary Russell
ee6b3f87b3 GH-164: Spring Kafka 2.0.0 Compatibility
Resolves: https://github.com/spring-projects/spring-integration-kafka/issues/164

Also gradle 3.5.

Requires https://github.com/spring-projects/spring-kafka/pull/296

Fix javadocs

More javadoc polishing

Updates for new Consumer header

* Simple polishing
2020-06-25 11:28:50 -04:00
Gary Russell
69e533f338 Compatibility with Latest 2.0.0.BUILD-SNAPSHOT
Removed methods.
2020-06-25 11:28:50 -04:00
Biju Kunjummen
9e047e7703 GH-158: Add record timestamp support
Fixes spring-projects/spring-integration-kafka#158

Fixing build - replaced a call to removed API in spring-kafka project

Support for timestamp expression in SI schema and SI DSL

* Polishing according PR comments
2020-06-25 11:28:49 -04:00
Gary Russell
328e9cdb57 Update to Spring Kafka 2.0.0
Revert assertJ to the Cairo version; an issue with 3.5.2 needs to be investigated.
2020-06-25 11:28:49 -04:00
Artem Bilan
87561e565f Move XSD to 3.0 version
* Upgrade to Gradle 3.2
* Increase timeout in the `KafkaTests`
2020-06-25 11:28:49 -04:00
Artem Bilan
598eb7f80e Upgrade to SI-5.0 & Port Kafka Java DSL
* Upgrade all the dependencies
* Upgrade to Gradle 3.1 (experimental)
* Make Java 8 as minimal
* Decrease test logging level to `warn`
* Document Java DSL support and some other polishing in the `README.adoc`
2020-06-25 11:28:49 -04:00
Artem Bilan
696376c728 Downgrade to AssertJ 2.5 for Boot compatibility
See https://github.com/spring-projects/spring-kafka/issues/196
2020-06-25 11:28:48 -04:00
Artem Bilan
8cd471532d GH-145 send-timeout(-expression) and XSD for them
Fixes GH-145 (https://github.com/spring-projects/spring-integration-kafka/issues/145)
2020-06-25 11:28:48 -04:00
Gary Russell
171dc9832a GH-147: Add Payload Type to Message Driven Adapter
Resolves: #147

Send Conversion Errors to the Error Channel
2020-06-25 11:28:48 -04:00
Gary Russell
2c1b77c8fa Fix Schema Indentation 2020-06-25 11:28:48 -04:00
Gary Russell
adfd6ee49e GH-143: Add sync to XML Namespace
Resolves: https://github.com/spring-projects/spring-integration-kafka/issues/143
2020-06-25 11:28:48 -04:00
Gary Russell
cbfc6b0e73 GH-141: Support Batch Payloads
Resolves: https://github.com/spring-projects/spring-integration-kafka/issues/141

Enum Javadocs

Polishing - PR Comments
2020-06-25 11:28:47 -04:00