當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleMessageListenerContainer類代碼示例

本文整理匯總了Java中org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer的典型用法代碼示例。如果您正苦於以下問題:Java SimpleMessageListenerContainer類的具體用法?Java SimpleMessageListenerContainer怎麽用?Java SimpleMessageListenerContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SimpleMessageListenerContainer類屬於org.springframework.amqp.rabbit.listener包,在下文中一共展示了SimpleMessageListenerContainer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: legacyPojoListener

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的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: messageContainer

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleMessageListenerContainer messageContainer() {
    SimpleMessageListenerContainer container =
            new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(queue());
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(2);
    container.setConcurrentConsumers(1);
    //設置確認模式手工確認
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> {
        byte[] messageBody = message.getBody();
        LOGGER.debug("motan 框架接收到的消息");
        //確認消息成功消費
        final Boolean success = mythMqReceiveService.processMessage(messageBody);
        if (success) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    });
    return container;
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:23,代碼來源:AmqpConfig.java

示例3: getSimpleMessageListenerContainer

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的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

示例4: messageContainer

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleMessageListenerContainer messageContainer() {
    SimpleMessageListenerContainer container =
            new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(queue());
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(1);
    container.setConcurrentConsumers(1);
    //設置確認模式手工確認
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> {
        byte[] messageBody = message.getBody();
        //確認消息成功消費
        final Boolean success = mythMqReceiveService.processMessage(messageBody);
        if (success) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    });
    return container;
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:22,代碼來源:AmqpConfig.java

示例5: messageContainer

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleMessageListenerContainer messageContainer() {
    SimpleMessageListenerContainer container =
            new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(queue());
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(3);
    container.setConcurrentConsumers(1);
    //設置確認模式手工確認
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> {
        byte[] messageBody = message.getBody();
        LogUtil.debug(LOGGER,()->"springcloud  account服務  amqp接收消息");
        //確認消息成功消費
        final Boolean success = mythMqReceiveService.processMessage(messageBody);
        if (success) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    });
    return container;
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:23,代碼來源:AmqpConfig.java

示例6: verifyContainer

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的package包/類
private SimpleMessageListenerContainer verifyContainer(Lifecycle endpoint) {
	SimpleMessageListenerContainer container;
	RetryTemplate retry;
	container = TestUtils.getPropertyValue(endpoint, "messageListenerContainer",
			SimpleMessageListenerContainer.class);
	assertThat(container.getAcknowledgeMode()).isEqualTo(AcknowledgeMode.NONE);
	assertThat(container.getQueueNames()[0]).startsWith("foo.props.0");
	assertThat(TestUtils.getPropertyValue(container, "transactional", Boolean.class)).isFalse();
	assertThat(TestUtils.getPropertyValue(container, "concurrentConsumers")).isEqualTo(2);
	assertThat(TestUtils.getPropertyValue(container, "maxConcurrentConsumers")).isEqualTo(3);
	assertThat(TestUtils.getPropertyValue(container, "defaultRequeueRejected", Boolean.class)).isFalse();
	assertThat(TestUtils.getPropertyValue(container, "prefetchCount")).isEqualTo(20);
	assertThat(TestUtils.getPropertyValue(container, "txSize")).isEqualTo(10);
	retry = TestUtils.getPropertyValue(endpoint, "retryTemplate", RetryTemplate.class);
	assertThat(TestUtils.getPropertyValue(retry, "retryPolicy.maxAttempts")).isEqualTo(23);
	assertThat(TestUtils.getPropertyValue(retry, "backOffPolicy.initialInterval")).isEqualTo(2000L);
	assertThat(TestUtils.getPropertyValue(retry, "backOffPolicy.maxInterval")).isEqualTo(20000L);
	assertThat(TestUtils.getPropertyValue(retry, "backOffPolicy.multiplier")).isEqualTo(5.0);

	List<?> requestMatchers = TestUtils.getPropertyValue(endpoint, "headerMapper.requestHeaderMatcher.matchers",
			List.class);
	assertThat(requestMatchers).hasSize(1);
	assertThat(TestUtils.getPropertyValue(requestMatchers.get(0), "pattern")).isEqualTo("foo");

	return container;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-stream-binder-rabbit,代碼行數:27,代碼來源:RabbitBinderTests.java

示例7: container_logDispatcher

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的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

示例8: container_eventRegister

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的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

示例9: serviceListenerContainer

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的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

示例10: messageListenerContainer

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的package包/類
/**
 * {@link SimpleMessageListenerContainer}のインスタンスを生成します。
 * このインスタンスを生成後にRabbitMQへのコネクション{@link #factory()}の設定や
 * メッセージ受信側での例外ハンドラ{@link #errorHandler()}の設定、
 * リトライ処理{@link #advice()}の設定を行います。
 * @return {@link SimpleMessageListenerContainer}のインスタンス
 */
protected SimpleMessageListenerContainer messageListenerContainer() {
    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(factory());
    container.setErrorHandler(errorHandler());
    container.setAdviceChain(advice());
    return container;
}
 
開發者ID:ctc-g,項目名稱:sinavi-jfw,代碼行數:15,代碼來源:ExceptionQueueContextConfig.java

示例11: subscribeQueue

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的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

示例12: ticketingServiceListenerContainer

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的package包/類
/**
 * This bean instantiates and returns the Simple message
 * listener container.
 *
 * @return Simple message listener container
 */
@Bean
SimpleMessageListenerContainer ticketingServiceListenerContainer()
{
    final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    container.setConnectionFactory(rabbitConnectionFactory);
    container.setAcknowledgeMode(AcknowledgeMode.AUTO);
    container.setQueues(ticketServiceRequestQueue);
    container.setMessageListener(ticketingServiceListener());
    container.setErrorHandler(new DefaultContainerErrorHandler("ticketingServiceListenerContainer"));
    return container;
}
 
開發者ID:dellemc-symphony,項目名稱:ticketing-service-paqx-parent-sample,代碼行數:18,代碼來源:TicketingServiceConsumerConfig.java

示例13: messageContainer

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的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

示例14: inbound

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的package包/類
@Bean
public AmqpInboundGateway inbound(SimpleMessageListenerContainer listenerContainer) {
	AmqpInboundGateway gateway = new AmqpInboundGateway(listenerContainer);

	gateway.setRequestChannel(inboundRequests());
	gateway.setRequestTimeout(60000000l);

	gateway.afterPropertiesSet();

	return gateway;
}
 
開發者ID:mminella,項目名稱:java-remote-partitioning,代碼行數:12,代碼來源:JobConfiguration.java

示例15: commandLineRunner

import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入依賴的package包/類
@Bean
public CommandLineRunner commandLineRunner(SimpleMessageListenerContainer simpleMessageListenerContainer) {
    return new CommandLineRunner() {
        @Override
        public void run(String... args) throws Exception {
            simpleMessageListenerContainer.start();
        }
    };
}
 
開發者ID:flowable,項目名稱:flowable-examples,代碼行數:10,代碼來源:ListenerApplication.java


注:本文中的org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。