-1

First time using a Multi and I am doing something wrong. I want to use a SubmissionPublisher from java.util.concurrent. It implements the Flow.Publisher interface.

final SubmissionPublisher<String> subPub1 = new SubmissionPublisher<>();
final var m1 = Multi.createFrom().publisher(subPub1);

Multi.createFrom.publishers's signature says the argument needs to implement Flow.Publisher. However, I get a type error.

The method publisher(Publisher<T>) in the type MultiCreate is not applicable for the arguments (SubmissionPublisher<String>)

I've tried casting it two different ways:

final var m1 = Multi.createFrom().publisher((java.util.concurrent.Flow.Publisher<String>) subPub1);

and

final var m1 = Multi.createFrom().publisher((Publisher<String>) subPub1);

but I still get the error:

The method publisher(Publisher<T>) in the type MultiCreate is not applicable for the arguments (Flow.Publisher<String>)

Any insghts into what I am doing wrong?

  • Mutiny 1.x is based on Reactive Streams (predating Flow). Mutiny 2.x switches to Flow as base. Mutiny 2.x will be shipped with Quarkus 3.x; however, there are already usable releases. – Clement Jan 25 '23 at 07:27

1 Answers1

0

Maybe you can use org.reactivestreams.FlowAdapters;

var flowPublisher = new SubmissionPublisher<String>();
var multi = Multi.createFrom().publisher(FlowAdapters.toPublisher(flowPublisher));
Ertan D.
  • 822
  • 1
  • 6
  • 22