io.openmessaging.interceptor.ConsumerInterceptor Java Examples

The following examples show how to use io.openmessaging.interceptor.ConsumerInterceptor. 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<ConsumerInterceptor> getConsumerInterceptors() {
    List<ConsumerInterceptor> 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 ConsumerInterceptor)) {
            result.add((ConsumerInterceptor) interceptorContainer.getInterceptor());
        }
    }
    return result;
}
 
Example #2
Source File: ConsumerContainer.java    From joyqueue with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() {
    Consumer consumer = accessPointContainer.getAccessPoint().createConsumer();
    consumer.start();

    for (ConsumerInterceptor interceptor : accessPointContainer.getConsumerInterceptors()) {
        consumer.addInterceptor(interceptor);
    }
    Object messageListener = applicationContext.getBean(messageListenerId);
    if (messageListener instanceof MessageListener) {
        consumer.bindQueue(queueName, (MessageListener) messageListener);
    } else if (messageListener instanceof BatchMessageListener) {
        consumer.bindQueue(queueName, (BatchMessageListener) messageListener);
    } else {
        throw new IllegalArgumentException("listener type error, need MessageListener or BatchMessageListener");
    }

    this.consumer = consumer;
}
 
Example #3
Source File: ConsumerImpl.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void addInterceptor(ConsumerInterceptor interceptor) {
    try {
        Preconditions.checkArgument(interceptor != null, "interceptor can not be null");

        messageConsumer.addInterceptor(new ConsumerInterceptorAdapter(interceptor));
    } catch (Throwable cause) {
        throw handleConsumeException(cause);
    }
}
 
Example #4
Source File: ConsumerImpl.java    From joyqueue with Apache License 2.0 5 votes vote down vote up
@Override
public void removeInterceptor(ConsumerInterceptor interceptor) {
    try {
        Preconditions.checkArgument(interceptor != null, "interceptor can not be null");

        messageConsumer.removeInterceptor(new ConsumerInterceptorAdapter(interceptor));
    } catch (Throwable cause) {
        throw handleConsumeException(cause);
    }
}
 
Example #5
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 #6
Source File: ConsumerWrapper.java    From joyqueue with Apache License 2.0 4 votes vote down vote up
@Override
public void addInterceptor(ConsumerInterceptor interceptor) {
    delegate.addInterceptor(interceptor);
}
 
Example #7
Source File: ConsumerWrapper.java    From joyqueue with Apache License 2.0 4 votes vote down vote up
@Override
public void removeInterceptor(ConsumerInterceptor interceptor) {
    delegate.removeInterceptor(interceptor);
}
 
Example #8
Source File: PushConsumerImpl.java    From rocketmq-4.3.0 with Apache License 2.0 2 votes vote down vote up
@Override
public void addInterceptor(ConsumerInterceptor interceptor) {

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

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

}
 
Example #11
Source File: PushConsumerImpl.java    From rocketmq-read with Apache License 2.0 2 votes vote down vote up
@Override
public void removeInterceptor(ConsumerInterceptor interceptor) {

}
 
Example #12
Source File: Consumer.java    From openmessaging-java with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a {@code ConsumerInterceptor} instance to this consumer.
 *
 * @param interceptor an interceptor instance.
 */
void addInterceptor(ConsumerInterceptor interceptor);
 
Example #13
Source File: Consumer.java    From openmessaging-java with Apache License 2.0 2 votes vote down vote up
/**
 * Removes an interceptor from this consumer.
 *
 * @param interceptor an interceptor to be removed.
 */
void removeInterceptor(ConsumerInterceptor interceptor);
 
Example #14
Source File: PushConsumerImpl.java    From rocketmq with Apache License 2.0 2 votes vote down vote up
@Override
public void addInterceptor(ConsumerInterceptor interceptor) {

}
 
Example #15
Source File: PushConsumerImpl.java    From rocketmq with Apache License 2.0 2 votes vote down vote up
@Override
public void removeInterceptor(ConsumerInterceptor interceptor) {

}