Commit Graph

10314 Commits

Author SHA1 Message Date
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
Gary Russell
0cf61af620 Update to s-k 1.1.0
Listener changes require a bump of the s-i-k version.

This is an initial commit - we will add support for new features (such as batch
payloads in future commits).

Polishing

* Upgrade to SI-4.3.x
* Use `Assert.instanceOf()`
2020-06-25 11:28:47 -04:00
Artem Bilan
8662c10232 Fix XSD type for partition-id
Even if target ``partitionId` value has to be `Integer`, we want to be able to configure the attribute via property-placeholder or Bean initialization SpEL

* Change `partition-id` XSD type from `integer` -> `string`
* Ensure that fix is correct with the test-case
2020-06-25 11:28:47 -04:00
Gary Russell
5bd2685a4d GH-135: Fix Schema
Fixes #135

Wrong type in `partition-id-expression`.
2020-06-25 11:28:47 -04:00
Gary Russell
a4ab7e54b1 GH-130: Support KafkaNull Payloads
Fixes #130

Requires spring-kafka 1.0.3.

Upgrade to `spring-kafka-1.0.3.RELEASE`
2020-06-25 11:28:47 -04:00
Artem Bilan
cda52fe966 GH-125: Introduce sync mode for KafkaProducerMH
Fixes: GH-125 (https://github.com/spring-projects/spring-integration-kafka/issues/125)

* Add `sync` mode for the `KafkaProducerMessageHandler` (`false` by default) to wait for result from the send `Future`
* Add `sendTimeout` do not block `Future.get()` forever
* Provide test-case based on the `MockProducer` to complete the record with an exception and verify that the `sync` mode works well
* Some dependencies upgrade

Wrap `Future.get()` `TimeoutException` into `MessageTimeoutException`

Fix whitespace after comma
2020-06-25 11:28:46 -04:00
Artem Bilan
69cded293f GH-124: Add Retry and Filter Option to MDAdapter
Fixes GH-124 (https://github.com/spring-projects/spring-integration-kafka/issues/124)

* Add `RecordFilterStrategy`, `ackDiscarded`, `retryTemplate`, `RecoveryCallback` and `filterInRetry` options into `KafkaMessageDrivenChannelAdapter`
* Wrap an internal `IntegrationMessageListener` into `FilteringAcknowledgingMessageListenerAdapter` and/or `RetryingAcknowledgingMessageListenerAdapter`
if those options are provided.
* The `filterInRetry` flag provides a logic to identify the wrapping order for those adapters.

Change `ContainerProperties` instance usage in the test-case from original to an internal in the `KafkaMessageListenerContainer`
That meets changes for the https://github.com/spring-projects/spring-kafka/issues/154
2020-06-25 11:28:46 -04:00
Gary Russell
490296c6b8 s-k 1.0.0.BUILD-SNAPSHOT Compatibility 2020-06-25 11:28:46 -04:00