io.openmessaging.interceptor.ProducerInterceptor Java Examples

The following examples show how to use io.openmessaging.interceptor.ProducerInterceptor. 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: AccessPointContainer.java    From joyqueue with Apache License 2.0 6 votes vote down vote up
public List<ProducerInterceptor> getProducerInterceptors() {
    List<ProducerInterceptor> result = new LinkedList<>();
    List<InterceptorContainer> interceptorContainers = new LinkedList<>();
    Map<String, InterceptorContainer> factoryInterceptorContainers = beanFactory.getBeansOfType(InterceptorContainer.class);

    if (!factoryInterceptorContainers.isEmpty()) {
        interceptorContainers.addAll(factoryInterceptorContainers.values());
    }

    if (!this.interceptorContainers.isEmpty()) {
        interceptorContainers.addAll(this.interceptorContainers);
    }

    for (InterceptorContainer interceptorContainer : interceptorContainers) {
        if (((id == null && interceptorContainer.getAccessPoint() == null)
                || (id != null && id.equals(interceptorContainer.getAccessPoint())))
                && (interceptorContainer.getInterceptor() instanceof ProducerInterceptor)) {
            result.add((ProducerInterceptor) interceptorContainer.getInterceptor());
        }
    }
    return result;
}
 
Example #2
Source File: ProducerImpl.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void addInterceptor(ProducerInterceptor interceptor) {
    try {
        Preconditions.checkArgument(interceptor != null, "interceptor can not be null");

        messageProducer.addInterceptor(new ProducerInterceptorAdapter(interceptor));
    } catch (Throwable cause) {
        handleProduceException(cause);
    }
}
 
Example #3
Source File: ProducerImpl.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void removeInterceptor(ProducerInterceptor interceptor) {
    try {
        Preconditions.checkArgument(interceptor != null, "interceptor can not be null");

        messageProducer.removeInterceptor(new ProducerInterceptorAdapter(interceptor));
    } catch (Throwable cause) {
        handleProduceException(cause);
    }
}
 
Example #4
Source File: InterceptorRegistrar.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
protected void registerInterceptor(String beanName, Object bean) {
    if (!(bean instanceof ProducerInterceptor) && !(bean instanceof ConsumerInterceptor)) {
        throw new IllegalArgumentException(String.format("%s (%s) is not ProducerInterceptor or ConsumerInterceptor", beanName, bean.getClass()));
    }

    OMSInterceptor interceptorAnnotation = bean.getClass().getAnnotation(OMSInterceptor.class);
    InterceptorContainer interceptorContainer = new InterceptorContainer(bean);
    accessPointContainer.addInterceptorContainer(interceptorContainer);
}
 
Example #5
Source File: ProducerContainer.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
    if (transactionStateCheckListener == null) {
        transactionStateCheckListener = accessPointContainer.getTransactionStateCheckListener();
    }
    if (transactionStateCheckListener == null) {
        producer = accessPointContainer.getAccessPoint().createProducer();
    } else {
        producer = accessPointContainer.getAccessPoint().createProducer(transactionStateCheckListener);
    }
    for (ProducerInterceptor interceptor : accessPointContainer.getProducerInterceptors()) {
        producer.addInterceptor(interceptor);
    }
    producer.start();
}
 
Example #6
Source File: TransactionProducerImpl.java    From joyqueue with Apache License 2.0 4 votes vote down vote up
@Override
public void addInterceptor(ProducerInterceptor interceptor) {
    delegate.addInterceptor(interceptor);
}
 
Example #7
Source File: TransactionProducerImpl.java    From joyqueue with Apache License 2.0 4 votes vote down vote up
@Override
public void removeInterceptor(ProducerInterceptor interceptor) {
    delegate.removeInterceptor(interceptor);
}
 
Example #8
Source File: ProducerWrapper.java    From joyqueue with Apache License 2.0 4 votes vote down vote up
@Override
public void addInterceptor(ProducerInterceptor interceptor) {
    delegate.addInterceptor(interceptor);
}
 
Example #9
Source File: ProducerWrapper.java    From joyqueue with Apache License 2.0 4 votes vote down vote up
@Override
public void removeInterceptor(ProducerInterceptor interceptor) {
    delegate.removeInterceptor(interceptor);
}
 
Example #10
Source File: ProducerImpl.java    From rocketmq with Apache License 2.0 2 votes vote down vote up
@Override
public void removeInterceptor(ProducerInterceptor interceptor) {

}
 
Example #11
Source File: ProducerImpl.java    From rocketmq-4.3.0 with Apache License 2.0 2 votes vote down vote up
@Override
public void addInterceptor(ProducerInterceptor interceptor) {

}
 
Example #12
Source File: ProducerImpl.java    From rocketmq with Apache License 2.0 2 votes vote down vote up
@Override
public void addInterceptor(ProducerInterceptor interceptor) {

}
 
Example #13
Source File: Producer.java    From openmessaging-java with Apache License 2.0 2 votes vote down vote up
/**
 * Remove a {@code ProducerInterceptor}.
 *
 * @param interceptor a producer interceptor will be removed.
 */
void removeInterceptor(ProducerInterceptor interceptor);
 
Example #14
Source File: Producer.java    From openmessaging-java with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a {@code ProducerInterceptor} to intercept send operations of producer.
 *
 * @param interceptor a producer interceptor.
 */
void addInterceptor(ProducerInterceptor interceptor);
 
Example #15
Source File: ProducerImpl.java    From rocketmq-read with Apache License 2.0 2 votes vote down vote up
@Override
public void removeInterceptor(ProducerInterceptor interceptor) {

}
 
Example #16
Source File: ProducerImpl.java    From rocketmq-read with Apache License 2.0 2 votes vote down vote up
@Override
public void addInterceptor(ProducerInterceptor interceptor) {

}
 
Example #17
Source File: ProducerImpl.java    From rocketmq-4.3.0 with Apache License 2.0 2 votes vote down vote up
@Override
public void removeInterceptor(ProducerInterceptor interceptor) {

}