-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle post-processing for payload consuming stream returning process…
- Loading branch information
1 parent
88148be
commit 6bc9865
Showing
5 changed files
with
133 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...ProducingAPublisherBuilderOfPayloadsAndConsumingIndividualPayloadWithProcessingError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.smallrye.reactive.messaging.beans; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.eclipse.microprofile.reactive.messaging.Acknowledgment; | ||
import org.eclipse.microprofile.reactive.messaging.Incoming; | ||
import org.eclipse.microprofile.reactive.messaging.Outgoing; | ||
import org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder; | ||
import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams; | ||
|
||
import io.reactivex.Flowable; | ||
|
||
@ApplicationScoped | ||
public class BeanProducingAPublisherBuilderOfPayloadsAndConsumingIndividualPayloadWithProcessingError { | ||
|
||
@Incoming("count") | ||
@Outgoing("sink") | ||
@Acknowledgment(Acknowledgment.Strategy.POST_PROCESSING) | ||
public PublisherBuilder<String> process(Integer payload) { | ||
if (payload > 5) { | ||
throw new IllegalArgumentException("boom"); | ||
} | ||
return ReactiveStreams.of(payload) | ||
.map(i -> i + 1) | ||
.flatMapRsPublisher(i -> Flowable.just(i, i)) | ||
.map(i -> Integer.toString(i)); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...ns/BeanProducingAPublisherOfPayloadsAndConsumingIndividualPayloadWithProcessingError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.smallrye.reactive.messaging.beans; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.eclipse.microprofile.reactive.messaging.Acknowledgment; | ||
import org.eclipse.microprofile.reactive.messaging.Incoming; | ||
import org.eclipse.microprofile.reactive.messaging.Outgoing; | ||
import org.eclipse.microprofile.reactive.streams.operators.ReactiveStreams; | ||
import org.reactivestreams.Publisher; | ||
|
||
import io.reactivex.Flowable; | ||
|
||
@ApplicationScoped | ||
public class BeanProducingAPublisherOfPayloadsAndConsumingIndividualPayloadWithProcessingError { | ||
|
||
@Incoming("count") | ||
@Outgoing("sink") | ||
@Acknowledgment(Acknowledgment.Strategy.POST_PROCESSING) | ||
public Publisher<String> process(Integer payload) { | ||
if (payload % 2 == 0) { | ||
throw new IllegalArgumentException("boom"); | ||
} | ||
return ReactiveStreams.of(payload) | ||
.map(i -> i + 1) | ||
.flatMapRsPublisher(i -> Flowable.just(i, i)) | ||
.map(i -> Integer.toString(i)) | ||
.buildRs(); | ||
} | ||
|
||
} |