当前位置: 首页>>代码示例>>Java>>正文


Java MessageListener类代码示例

本文整理汇总了Java中org.springframework.amqp.core.MessageListener的典型用法代码示例。如果您正苦于以下问题:Java MessageListener类的具体用法?Java MessageListener怎么用?Java MessageListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MessageListener类属于org.springframework.amqp.core包,在下文中一共展示了MessageListener类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInvokeListener

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
protected void doInvokeListener(MessageListener listener, Message message) throws Exception {
    try {
        serverRequestInterceptor.handle(new RabbitServerRequestAdapter(message));
        listener.onMessage(message);
        serverResponseInterceptor.handle(new RabbitServerResponseAdapter());
    } catch (Exception e) {
        throw wrapToListenerExecutionFailedExceptionIfNeeded(e, message);
    }
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:10,代码来源:TracingMessageListenerContainer.java

示例2: replicationMessageListenerContainer

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
@Bean
public MessageListenerContainer replicationMessageListenerContainer(
        ConnectionFactory connectionFactory,
        MessageListener replicationMessageListener
) {
    DirectMessageListenerContainer container = new DirectMessageListenerContainer();
    container.setConnectionFactory(connectionFactory);
    container.setQueueNames(fullQueueName);
    container.setMessageListener(replicationMessageListener);

    return container;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:13,代码来源:AmqpReplicationClientConfig.java

示例3: messageListenerContainer

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
@Bean
public MessageListenerContainer messageListenerContainer(
        ConnectionFactory connectionFactory,
        MessageListener messageListener
) {
    DirectMessageListenerContainer container = new DirectMessageListenerContainer();
    container.setConnectionFactory(connectionFactory);
    container.setQueueNames(resultQueue);
    container.setMessageListener(messageListener);

    return container;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:13,代码来源:AmqpFileClientConfig.java

示例4: outMessageListenerContainer

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
@Bean
public MessageListenerContainer outMessageListenerContainer(
        ConnectionFactory outConnectionFactory,
        MessageListener outMessageListener
) {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(outConnectionFactory);
    container.setQueueNames(resultQueue);
    container.setMessageListener(outMessageListener);

    return container;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:13,代码来源:AmqpBridgeOutputConfig.java

示例5: fileServerMessageListenerContainer

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
@Bean
public MessageListenerContainer fileServerMessageListenerContainer(
        ConnectionFactory serverConnectionFactory,
        MessageListener fileServerMessageListener
) {
    DirectMessageListenerContainer container = new DirectMessageListenerContainer();
    container.setConnectionFactory(serverConnectionFactory);
    container.setQueueNames(fileQueue);
    container.setMessageListener(fileServerMessageListener);

    return container;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:13,代码来源:AmqpServerConfig.java

示例6: onMessage

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
@Override
public void onMessage(Message message, Channel channel) throws Exception {
    // Check whether the delegate is a MessageListener impl itself.
    // In that case, the adapter will simply act as a pass-through.
    Object delegate = getDelegate();
    if (delegate != this) {
        if (delegate instanceof ChannelAwareMessageListener) {
            if (channel != null) {
                ((ChannelAwareMessageListener) delegate).onMessage(message, channel);
                return;
            } else if (!(delegate instanceof MessageListener)) {
                throw new AmqpIllegalStateException(
                        "MessageListenerAdapter cannot handle a "
                                + "ChannelAwareMessageListener delegate if it hasn't been invoked with a Channel itself");
            }
        }
        if (delegate instanceof MessageListener) {
            ((MessageListener) delegate).onMessage(message);
            return;
        }
    }

    String methodName = getListenerMethodName(message, null);
    if (methodName == null) {
        throw new AmqpIllegalStateException("No default listener method specified: "
                + "Either specify a non-null value for the 'defaultListenerMethod' property or "
                + "override the 'getListenerMethodName' method.");
    }

    Method[] methods = delegate.getClass().getMethods();
    for (Method method : methods) {
        if (method.getName().equals(methodName) && method.getParameterTypes().length == 1) {
            Class<?> clazz = method.getParameterTypes()[0];
            String className = clazz.getName();
            setMessageHeader(message.getMessageProperties(),
                    AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, className);

            // 泛型的参数类型
            Type[] types = method.getGenericParameterTypes();
            // 存在泛型
            if (types.length >= 0 && types[0] instanceof ParameterizedType) {
                ParameterizedType pType = (ParameterizedType) types[0];
                // 泛型
                Type[] actualTypeArguments = pType.getActualTypeArguments();

                if (Collection.class.isAssignableFrom(clazz) && actualTypeArguments.length == 1) {
                    // collection
                    setListMessageHeader(message.getMessageProperties(), actualTypeArguments[0]);
                } else if (Map.class.isAssignableFrom(clazz) && actualTypeArguments.length == 2) {
                    // map
                    setMapMessageHeader(message.getMessageProperties(), actualTypeArguments);
                }
            }

            Object convertedMessage = extractMessage(message);
            Object result = method.invoke(delegate, convertedMessage);
            if (result != null) {
                handleResult(result, message, channel);
            }
            return;
        }
    }
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:64,代码来源:LodsveMessageListenerAdapter.java

示例7: MessageListenerProxy

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
public MessageListenerProxy(MessageListener listener, String jobName) {
    this.delegate = listener;
    this.jobName = jobName;
}
 
开发者ID:compasses,项目名称:elastic-rabbitmq,代码行数:5,代码来源:MessageListenerProxy.java

示例8: replicationMessageListener

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
@Bean
public MessageListener replicationMessageListener(ReplicationComponent replicationComponent) {
    return replicationComponent;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:5,代码来源:AmqpReplicationClientConfig.java

示例9: messageListener

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
@Bean
public MessageListener messageListener(AvNetworkComponent avNetworkComponent) {
    return avNetworkComponent;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:5,代码来源:AmqpFileClientConfig.java

示例10: outMessageListener

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
@Bean
public MessageListener outMessageListener(AvNetworkComponent outComponent) {
    return outComponent;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:5,代码来源:AmqpBridgeOutputConfig.java

示例11: fileServerMessageListener

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
@Bean
public MessageListener fileServerMessageListener(AvNetworkComponent fileAvNetworkComponent) {
    return fileAvNetworkComponent;
}
 
开发者ID:dvoraka,项目名称:av-service,代码行数:5,代码来源:AmqpServerConfig.java

示例12: newMessageListenerAdapter

import org.springframework.amqp.core.MessageListener; //导入依赖的package包/类
public MessageListenerAdapter newMessageListenerAdapter(MessageListener messageListener) {
    return new MessageListenerAdapter(messageListener, messageConverter);
}
 
开发者ID:zeroDivisible,项目名称:spring-rabbitmq-example,代码行数:4,代码来源:MessageHandlerFactory.java


注:本文中的org.springframework.amqp.core.MessageListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。