-
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.
- Loading branch information
1 parent
836cdb1
commit ec38d90
Showing
37 changed files
with
130 additions
and
128 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
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
5 changes: 2 additions & 3 deletions
5
examples/amqp-quickstart/src/main/java/acme/BeanUsingAnEmitter.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
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
4 changes: 2 additions & 2 deletions
4
...ts/src/main/java/io/smallrye/reactive/messaging/example/eventclouds/MyCloudEventSink.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
36 changes: 19 additions & 17 deletions
36
.../src/main/java/io/smallrye/reactive/messaging/example/eventclouds/MyCloudEventSource.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 |
---|---|---|
@@ -1,32 +1,34 @@ | ||
package io.smallrye.reactive.messaging.example.eventclouds; | ||
|
||
import io.reactivex.Flowable; | ||
import io.reactivex.schedulers.Schedulers; | ||
import io.smallrye.reactive.messaging.cloudevents.CloudEventMessage; | ||
import io.smallrye.reactive.messaging.cloudevents.CloudEventMessageBuilder; | ||
import org.eclipse.microprofile.reactive.messaging.Outgoing; | ||
import org.reactivestreams.Publisher; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import java.net.URI; | ||
import java.time.ZonedDateTime; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import org.eclipse.microprofile.reactive.messaging.Outgoing; | ||
import org.reactivestreams.Publisher; | ||
|
||
import io.reactivex.Flowable; | ||
import io.reactivex.schedulers.Schedulers; | ||
import io.smallrye.reactive.messaging.cloudevents.CloudEventMessage; | ||
import io.smallrye.reactive.messaging.cloudevents.CloudEventMessageBuilder; | ||
|
||
@ApplicationScoped | ||
public class MyCloudEventSource { | ||
|
||
@Outgoing("source") | ||
public Publisher<CloudEventMessage<String>> source() { | ||
return Flowable.interval(1, TimeUnit.SECONDS) | ||
.observeOn(Schedulers.computation()) | ||
.map(l -> new CloudEventMessageBuilder<String>() | ||
.withId(UUID.randomUUID().toString()) | ||
.withType("counter") | ||
.withSource(new URI("local://timer")) | ||
.withDataContentType("text/plain") | ||
.withTime(ZonedDateTime.now()) | ||
.withData(Long.toString(l)) | ||
.build()); | ||
.observeOn(Schedulers.computation()) | ||
.map(l -> new CloudEventMessageBuilder<String>() | ||
.withId(UUID.randomUUID().toString()) | ||
.withType("counter") | ||
.withSource(new URI("local://timer")) | ||
.withDataContentType("text/plain") | ||
.withTime(ZonedDateTime.now()) | ||
.withData(Long.toString(l)) | ||
.build()); | ||
} | ||
} |
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
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
6 changes: 2 additions & 4 deletions
6
examples/mqtt-quickstart/src/main/java/acme/BeanUsingAnEmitter.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
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
33 changes: 17 additions & 16 deletions
33
examples/mqtt-server-quickstart/src/main/java/acme/BeanUsingAnEmitter.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 |
---|---|---|
@@ -1,28 +1,29 @@ | ||
package acme; | ||
|
||
import org.eclipse.microprofile.reactive.messaging.Channel; | ||
import org.eclipse.microprofile.reactive.messaging.Emitter; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
|
||
import org.eclipse.microprofile.reactive.messaging.Channel; | ||
import org.eclipse.microprofile.reactive.messaging.Emitter; | ||
|
||
@ApplicationScoped | ||
public class BeanUsingAnEmitter { | ||
|
||
@Inject | ||
@Channel("test-messages") | ||
Emitter<String> emitter; | ||
@Inject | ||
@Channel("test-messages") | ||
Emitter<String> emitter; | ||
|
||
public void periodicallySendMqttMessage() { | ||
AtomicInteger counter = new AtomicInteger(); | ||
Executors.newSingleThreadScheduledExecutor() | ||
.scheduleAtFixedRate(() -> { | ||
emitter.send("Hello " + counter.getAndIncrement()); | ||
}, | ||
1, 1, TimeUnit.SECONDS); | ||
} | ||
public void periodicallySendMqttMessage() { | ||
AtomicInteger counter = new AtomicInteger(); | ||
Executors.newSingleThreadScheduledExecutor() | ||
.scheduleAtFixedRate(() -> { | ||
emitter.send("Hello " + counter.getAndIncrement()); | ||
}, | ||
1, 1, TimeUnit.SECONDS); | ||
} | ||
|
||
} |
Oops, something went wrong.