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


Java MessageListenerAdapter类代码示例

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


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

示例1: legacyPojoListener

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
public SimpleMessageListenerContainer legacyPojoListener(ConnectionFactory connectionFactory) {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    container.setQueueNames(MAPPED_QUEUE);
    MessageListenerAdapter messageListener = new MessageListenerAdapter(new Object() {

        @SuppressWarnings("unused")
        public void handleMessage(Object object) {
            System.out.println("Got a " + object);
            JsonApp.this.latch.countDown();
        }

    });
    Jackson2JsonMessageConverter jsonConverter = new Jackson2JsonMessageConverter();
    jsonConverter.setClassMapper(classMapper());
    messageListener.setMessageConverter(jsonConverter);
    container.setMessageListener(messageListener);
    return container;
}
 
开发者ID:laidu,项目名称:java-learn,代码行数:20,代码来源:JsonApp.java

示例2: getSimpleMessageListenerContainer

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
private SimpleMessageListenerContainer getSimpleMessageListenerContainer(
    ConnectionFactory connectionFactory,
    @Qualifier("listenerAdapter_vnfmCoreActions") MessageListenerAdapter listenerAdapter,
    String queueName_vnfmCoreActions,
    int minConcurrency,
    int maxConcurrency) {
  SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
  container.setConnectionFactory(connectionFactory);
  container.setQueueNames(queueName_vnfmCoreActions);
  if (minConcurrency <= 0 || maxConcurrency <= 0 || minConcurrency > maxConcurrency) {
    container.setConcurrentConsumers(5);
    container.setMaxConcurrentConsumers(15);
  } else {
    container.setConcurrentConsumers(minConcurrency);
    container.setMaxConcurrentConsumers(maxConcurrency);
  }
  container.setMessageListener(listenerAdapter);
  container.setErrorHandler(
      new ConditionalRejectingErrorHandler(new HandleJsonSyntaxExceptionStrategy()));
  return container;
}
 
开发者ID:openbaton,项目名称:NFVO,代码行数:22,代码来源:RabbitConfiguration.java

示例3: registerListenerEndpoint

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
private void registerListenerEndpoint(RabbitListenerEndpointRegistrar aRegistrar, Queue aQueue, Exchange aExchange, int aConcurrency, Object aDelegate, String aMethodName) {
  admin(connectionFactory).declareQueue(aQueue);
  admin(connectionFactory).declareBinding(BindingBuilder.bind(aQueue)
                                                        .to(aExchange)
                                                        .with(aQueue.getName())
                                                        .noargs());
  
  MessageListenerAdapter messageListener = new MessageListenerAdapter(aDelegate);
  messageListener.setMessageConverter(jacksonAmqpMessageConverter(objectMapper));
  messageListener.setDefaultListenerMethod(aMethodName);

  SimpleRabbitListenerEndpoint endpoint = new SimpleRabbitListenerEndpoint();
  endpoint.setId(aQueue.getName()+"Endpoint");
  endpoint.setQueueNames(aQueue.getName());
  endpoint.setMessageListener(messageListener);

  aRegistrar.registerEndpoint(endpoint,createContainerFactory(aConcurrency));
}
 
开发者ID:creactiviti,项目名称:piper,代码行数:19,代码来源:AmqpMessengerConfiguration.java

示例4: container_logDispatcher

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
SimpleMessageListenerContainer container_logDispatcher(
    ConnectionFactory connectionFactory,
    @Qualifier("listenerAdapter_logDispatch") MessageListenerAdapter listenerAdapter) {
  if (listenerAdapter != null) {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(connectionFactory);
    container.setQueueNames(queueName_logDispatch);
    if (minConcurrency <= 0 || maxConcurrency <= 0 || minConcurrency > maxConcurrency) {
      container.setConcurrentConsumers(5);
      container.setMaxConcurrentConsumers(15);
    } else {
      container.setConcurrentConsumers(minConcurrency);
      container.setMaxConcurrentConsumers(maxConcurrency);
    }
    container.setMessageListener(listenerAdapter);
    return container;
  } else return null;
}
 
开发者ID:openbaton,项目名称:openbaton-libs,代码行数:20,代码来源:RabbitConfiguration.java

示例5: container_eventRegister

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
SimpleMessageListenerContainer container_eventRegister(
    ConnectionFactory connectionFactory,
    @Qualifier("listenerAdapter_nfvoGenericActions") MessageListenerAdapter listenerAdapter) {
  SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
  container.setConnectionFactory(connectionFactory);
  container.setQueueNames(queueName_nfvoGenericActions);
  if (minConcurrency <= 0 || maxConcurrency <= 0 || minConcurrency > maxConcurrency) {
    container.setConcurrentConsumers(5);
    container.setMaxConcurrentConsumers(15);
  } else {
    container.setConcurrentConsumers(minConcurrency);
    container.setMaxConcurrentConsumers(maxConcurrency);
  }
  container.setMessageListener(listenerAdapter);
  return container;
}
 
开发者ID:openbaton,项目名称:openbaton-libs,代码行数:18,代码来源:RabbitConfiguration.java

示例6: serviceListenerContainer

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
SimpleMessageListenerContainer serviceListenerContainer(
        LeadProcessor leadProcessor, @Qualifier(REQUEST_Q) Queue queue,
        LeadGeocodingProcessor leadGeocodingProcessor,
        JdbcTemplate jdbcTemplate, ConnectionFactory rabbitConnectionFactory) {

    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();

    BatchProcessor[] leadProcessors = new BatchProcessor[]{leadProcessor, leadGeocodingProcessor};
    PojoListener pojoListener = new PojoListener(jdbcTemplate, leadProcessors);
    SimpleMessageConverter simpleMessageConverter = new NoOpSimpleMessageConverter();
    container.setMessageListener(new MessageListenerAdapter(pojoListener, simpleMessageConverter));
    container.setConnectionFactory(rabbitConnectionFactory);
    container.setQueues(queue);
    return container;
}
 
开发者ID:joshlong,项目名称:sfdc-cloudfoundry,代码行数:17,代码来源:RabbitConfiguration.java

示例7: MessageListenerAdapter

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Test
public void 回復可能例外の場合はデフォルトの指定回数リトライが実行されて回復可能例外キューに配信される() throws Exception {
    container.setQueues(ctx.getBean("retryTestQueue", Queue.class));
    container.setMessageListener(new MessageListenerAdapter(new ApplicationRecoverableExceptionTestHandler(), ctx.getBean(MessageConverter.class)));
    recoverableContainer.setQueues(ctx.getBean("recoverableExceptionQueue", Queue.class));
    recoverableContainer.setMessageListener(new MessageListenerAdapter(new RecoverableTestHandler(), ctx.getBean(MessageConverter.class)));
    container.start();
    recoverableContainer.start();
    template.convertAndSend("retry.test.exchange", "retry.test.binding", new RetryTestBean("test"));
    assertThat(retry.await(30, TimeUnit.SECONDS), is(true));
    assertThat(retry.getCount(), is(0L));
    assertThat(recover.await(3, TimeUnit.SECONDS), is(true));
    assertThat(recover.getCount(), is(0L));
    container.stop();
    recoverableContainer.stop();
}
 
开发者ID:ctc-g,项目名称:sinavi-jfw,代码行数:17,代码来源:MessageListenerRetryTest.java

示例8: subscribeQueue

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
private void subscribeQueue(MQMessageConsumer consumer) 
	throws MessageException {

       String realQName = getIpQueueName(consumer.getDestinationName());

	Integer cc = MessageConfig.current.get(Integer.class, "concurrent");
	SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
	container.setQueueNames(realQName);
	container.setConnectionFactory(connectionFactory);
	container.setConcurrentConsumers(cc);
	
	MessageListenerAdapter apdapter = new MessageListenerAdapter(consumer);
	apdapter.setMessageConverter(this.messageConverter);
	apdapter.setDefaultListenerMethod("handleMessage");
	
	container.setMessageListener(apdapter);
	
	this.bindingQueue(consumer.getConsumerId());
	
	containerList.add(container);
}
 
开发者ID:yamingd,项目名称:argo,代码行数:22,代码来源:RabbitMQServerProvider.java

示例9: messageContainer

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
public SimpleMessageListenerContainer messageContainer(ConnectionFactory connectionFactory, MessageListenerAdapter messageListenerAdapter) {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(this.queue);
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(this.maxConcurrentConsumers);
    container.setConcurrentConsumers(this.concurrentConsumers);
    container.setAcknowledgeMode(AcknowledgeMode.AUTO);
    container.setMessageListener(messageListenerAdapter);
    return container;
}
 
开发者ID:JThink,项目名称:SkyEye,代码行数:12,代码来源:AmqpConfiguration.java

示例10: getMessageListenerContainer

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
public SimpleMessageListenerContainer getMessageListenerContainer(final ConnectionFactory connectionFactory,
                                                                  final Queue commandDrainQueue,
                                                                  final MessageListenerAdapter messageListener) {

    final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(commandDrainQueue);
    container.setMessageListener(messageListener);

    return container;
}
 
开发者ID:sem2nawara,项目名称:acme-solution,代码行数:12,代码来源:RabbitTestConfigurer.java

示例11: messageListenerContainer

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
public SimpleMessageListenerContainer messageListenerContainer(MessageListenerAdapter listenerAdapter) {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(connectionFactory());
    container.setQueueNames(AmqpConfig.QUEUE_NAME);
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(1);
    container.setConcurrentConsumers(1);
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL); //设置确认模式手工确认
    container.setMessageListener(listenerAdapter);
    return container;
}
 
开发者ID:liubo6,项目名称:demo_springboot_rabbitmq,代码行数:13,代码来源:AmqpConfig.java

示例12: container_managerRegister

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
/**
 * ***************************
 *
 * <p>Defining Containers
 *
 * <p>***************************
 */
@Bean
SimpleMessageListenerContainer container_managerRegister(
    ConnectionFactory connectionFactory,
    @Qualifier("listenerAdapter_managerRegister") MessageListenerAdapter listenerAdapter) {
  return getSimpleMessageListenerContainer(
      connectionFactory, listenerAdapter, queueName_managerRegister);
}
 
开发者ID:openbaton,项目名称:NFVO,代码行数:15,代码来源:RabbitConfiguration.java

示例13: container_eventRegister

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
SimpleMessageListenerContainer container_eventRegister(
    ConnectionFactory connectionFactory,
    @Qualifier("listenerAdapter_eventRegister") MessageListenerAdapter listenerAdapter) {
  return getSimpleMessageListenerContainer(
      connectionFactory, listenerAdapter, queueName_eventRegister);
}
 
开发者ID:openbaton,项目名称:NFVO,代码行数:8,代码来源:RabbitConfiguration.java

示例14: container_eventUnregister

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
SimpleMessageListenerContainer container_eventUnregister(
    ConnectionFactory connectionFactory,
    @Qualifier("listenerAdapter_eventUnregister") MessageListenerAdapter listenerAdapter) {
  SimpleMessageListenerContainer container =
      getSimpleMessageListenerContainer(
          connectionFactory, listenerAdapter, queueName_eventUnregister);
  return container;
}
 
开发者ID:openbaton,项目名称:NFVO,代码行数:10,代码来源:RabbitConfiguration.java

示例15: container_vnfmCoreActions

import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter; //导入依赖的package包/类
@Bean
SimpleMessageListenerContainer container_vnfmCoreActions(
    ConnectionFactory connectionFactory,
    @Qualifier("listenerAdapter_vnfmCoreActions") MessageListenerAdapter listenerAdapter) {
  return getSimpleMessageListenerContainer(
      connectionFactory,
      listenerAdapter,
      queueName_vnfmCoreActions,
      minConcurrency,
      maxConcurrency);
}
 
开发者ID:openbaton,项目名称:NFVO,代码行数:12,代码来源:RabbitConfiguration.java


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