org.eclipse.microprofile.reactive.messaging.Channel Java Examples

The following examples show how to use org.eclipse.microprofile.reactive.messaging.Channel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 6 votes vote down vote up
static Channel getChannelQualifier(InjectionPoint injectionPoint) {
    for (Annotation qualifier : injectionPoint.getQualifiers()) {
        if (qualifier.annotationType().equals(Channel.class)) {
            return (Channel) qualifier;
        }

        if (qualifier.annotationType().equals(io.smallrye.reactive.messaging.annotations.Channel.class)) {
            return new Channel() {

                @Override
                public Class<? extends Annotation> annotationType() {
                    return Channel.class;
                }

                @Override
                public String value() {
                    return ((io.smallrye.reactive.messaging.annotations.Channel) qualifier).value();
                }
            };
        }
    }
    return null;
}
 
Example #2
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
/**
 * Injects {@code Multi<Message<X>>} and {@code Multi<X>}. It also matches the injection of
 * {@code Publisher<Message<X>>} and {@code Publisher<X>}.
 *
 * @param injectionPoint the injection point
 * @param <T> the first generic parameter (either Message or X)
 * @return the Multi to be injected
 */
@Produces
@Channel("") // Stream name is ignored during type-safe resolution
<T> Multi<T> produceMulti(InjectionPoint injectionPoint) {
    Type first = getFirstParameter(injectionPoint.getType());
    if (TypeUtils.isAssignable(first, Message.class)) {
        return cast(Multi.createFrom().publisher(getPublisher(injectionPoint)));
    } else {
        return cast(Multi.createFrom().publisher(getPublisher(injectionPoint)).map(Message::getPayload));
    }
}
 
Example #3
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
/**
 * Injects {@code Flowable<Message<X>>} and {@code Flowable<X>}.
 *
 * @param injectionPoint the injection point
 * @param <T> the first generic parameter (either Message or X)
 * @return the flowable to be injected
 */
@Produces
@Typed(Flowable.class)
@Channel("") // Stream name is ignored during type-safe resolution
<T> Flowable<T> produceFlowable(InjectionPoint injectionPoint) {
    Type first = getFirstParameter(injectionPoint.getType());
    if (TypeUtils.isAssignable(first, Message.class)) {
        return cast(Flowable.fromPublisher(getPublisher(injectionPoint)));
    } else {
        return cast(Flowable.fromPublisher(getPublisher(injectionPoint))
                .map(Message::getPayload));
    }
}
 
Example #4
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
/**
 * Injects {@code PublisherBuilder<Message<X>>} and {@code PublisherBuilder<X>}
 *
 * @param injectionPoint the injection point
 * @param <T> the first generic parameter (either Message or X)
 * @return the PublisherBuilder to be injected
 */
@Produces
@Channel("") // Stream name is ignored during type-safe resolution
<T> PublisherBuilder<T> producePublisherBuilder(InjectionPoint injectionPoint) {
    Type first = getFirstParameter(injectionPoint.getType());
    if (TypeUtils.isAssignable(first, Message.class)) {
        return cast(ReactiveStreams.fromPublisher(getPublisher(injectionPoint)));
    } else {
        return cast(ReactiveStreams.fromPublisher(getPublisher(injectionPoint))
                .map(Message::getPayload));
    }
}
 
Example #5
Source File: SmallRyeReactiveMessagingProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
AdditionalBeanBuildItem beans() {
    // We add the connector and channel qualifiers to make them part of the index.
    return new AdditionalBeanBuildItem(SmallRyeReactiveMessagingLifecycle.class, Connector.class,
            Channel.class, io.smallrye.reactive.messaging.annotations.Channel.class,
            QuarkusWorkerPoolRegistry.class);
}
 
Example #6
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 5 votes vote down vote up
static String getChannelName(InjectionPoint injectionPoint) {
    for (Annotation qualifier : injectionPoint.getQualifiers()) {
        if (qualifier.annotationType().equals(Channel.class)) {
            return ((Channel) qualifier).value();
        }

        if (qualifier.annotationType().equals(io.smallrye.reactive.messaging.annotations.Channel.class)) {
            return ((io.smallrye.reactive.messaging.annotations.Channel) qualifier).value();
        }
    }
    throw ex.illegalStateForAnnotationNotFound("@Channel", injectionPoint);
}
 
Example #7
Source File: ChannelEmitterWithOverflowAndBroadcast.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Inject
public void setEmitter(@Channel("sink-1") @Broadcast Emitter<String> sink1,
        @Channel("sink-2") @Broadcast @OnOverflow(value = OnOverflow.Strategy.BUFFER, bufferSize = 4) Emitter<String> sink2) {
    this.emitterForSink1 = sink1;
    this.emitterForSink2 = sink2;
}
 
Example #8
Source File: ChannelEmitterWithOverflow.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Inject
public void setEmitter(@Channel("sink-1") Emitter<String> sink1,
        @Channel("sink-2") @OnOverflow(value = OnOverflow.Strategy.BUFFER, bufferSize = 4) Emitter<String> sink2) {
    this.emitterForSink1 = sink1;
    this.emitterForSink2 = sink2;
}
 
Example #9
Source File: BeanInjectedWithAPublisherBuilderOfPayloads.java    From microprofile-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAPublisherBuilderOfPayloads(@Channel("bonjour") PublisherBuilder<String> constructor) {
    this.constructor = constructor;
}
 
Example #10
Source File: BeanInjectedWithAPublisherOfMessages.java    From microprofile-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAPublisherOfMessages(@Channel("bonjour") Publisher<Message<String>> constructor) {
    this.constructor = constructor;
}
 
Example #11
Source File: BeanInjectedWithAPublisherOfPayloads.java    From microprofile-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAPublisherOfPayloads(@Channel("bonjour") Publisher<String> constructor) {
    this.constructor = constructor;
}
 
Example #12
Source File: BeanInjectedWithAPublisherBuilderOfMessages.java    From microprofile-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAPublisherBuilderOfMessages(@Channel("bonjour") PublisherBuilder<Message<String>> constructor) {
    this.constructor = constructor;
}
 
Example #13
Source File: BeanInjectedWithAMultiOfPayloads.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAMultiOfPayloads(@Channel("bonjour") Multi<String> constructor) {
    this.constructor = constructor;
}
 
Example #14
Source File: BeanInjectedWithAPublisherBuilderOfPayloads.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAPublisherBuilderOfPayloads(@Channel("bonjour") PublisherBuilder<String> constructor) {
    this.constructor = constructor;
}
 
Example #15
Source File: BeanInjectedWithAPublisherOfMessages.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAPublisherOfMessages(@Channel("bonjour") Publisher<Message<String>> constructor) {
    this.constructor = constructor;
}
 
Example #16
Source File: BeanInjectedWithAMultiOfMessages.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAMultiOfMessages(@Channel("bonjour") Multi<Message<String>> constructor) {
    this.constructor = constructor;
}
 
Example #17
Source File: BeanInjectedWithAFlowableOfMessages.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAFlowableOfMessages(@Channel("bonjour") Flowable<Message<String>> constructor) {
    this.constructor = constructor;
}
 
Example #18
Source File: BeanInjectedWithAFlowableOfPayloads.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAFlowableOfPayloads(@Channel("bonjour") Flowable<String> constructor) {
    this.constructor = constructor;
}
 
Example #19
Source File: BeanInjectedWithAPublisherOfPayloads.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAPublisherOfPayloads(@Channel("bonjour") Publisher<String> constructor) {
    this.constructor = constructor;
}
 
Example #20
Source File: BeanInjectedWithAPublisherBuilderOfMessages.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
@Inject
public BeanInjectedWithAPublisherBuilderOfMessages(
        @Channel("bonjour") PublisherBuilder<Message<String>> constructor) {
    this.constructor = constructor;
}
 
Example #21
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 3 votes vote down vote up
/**
 * Injects an {@link io.smallrye.reactive.messaging.annotations.Emitter} (deprecated) matching the channel name.
 *
 * @param injectionPoint the injection point
 * @param <T> the type
 * @return the legacy emitter
 * @deprecated Use the new {@link Emitter} and {@link Channel} instead
 */
@Produces
@io.smallrye.reactive.messaging.annotations.Channel("") // Stream name is ignored during type-safe resolution
<T> io.smallrye.reactive.messaging.annotations.Emitter<T> produceEmitterLegacy(
        InjectionPoint injectionPoint) {
    LegacyEmitterImpl emitter = new LegacyEmitterImpl(getEmitter(injectionPoint));
    return cast(emitter);
}
 
Example #22
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 3 votes vote down vote up
/**
 * Injects an {@link Emitter} matching the channel name.
 *
 * @param injectionPoint the injection point
 * @param <T> the type of the emitter
 * @return the emitter
 */
@Produces
@Channel("") // Stream name is ignored during type-safe resolution
<T> Emitter<T> produceEmitter(InjectionPoint injectionPoint) {
    Emitter emitter = getEmitter(injectionPoint);
    return cast(emitter);
}
 
Example #23
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 3 votes vote down vote up
/**
 * Injects {@code Flowable<Message<X>>} and {@code Flowable<X>}. It also matches the injection of
 * {@code Publisher<Message<X>>} and {@code Publisher<X>}.
 *
 * NOTE: this injection point is about the deprecated {@link io.smallrye.reactive.messaging.annotations.Channel} annotation.
 *
 * @param injectionPoint the injection point
 * @param <T> the first generic parameter (either Message or X)
 * @return the flowable to be injected
 * @deprecated Use {@link Channel} instead.
 */
@Produces
@Deprecated
@io.smallrye.reactive.messaging.annotations.Channel("")
<T> Flowable<T> producePublisherWithLegacyChannelAnnotation(InjectionPoint injectionPoint) {
    return produceFlowable(injectionPoint);
}
 
Example #24
Source File: ChannelProducer.java    From smallrye-reactive-messaging with Apache License 2.0 2 votes vote down vote up
/**
 * Injects {@code PublisherBuilder<Message<X>>} and {@code PublisherBuilder<X>}
 *
 * NOTE: this injection point is about the deprecated {@link io.smallrye.reactive.messaging.annotations.Channel} annotation.
 *
 * @param injectionPoint the injection point
 * @param <T> the first generic parameter (either Message or X)
 * @return the PublisherBuilder to be injected
 * @deprecated Use {@link Channel} instead.
 */
@Produces
@io.smallrye.reactive.messaging.annotations.Channel("") // Stream name is ignored during type-safe resolution
<T> PublisherBuilder<T> producePublisherBuilderWithLegacyChannelAnnotation(InjectionPoint injectionPoint) {
    return producePublisherBuilder(injectionPoint);
}