本文整理匯總了Java中org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.setConcurrentConsumers方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleMessageListenerContainer.setConcurrentConsumers方法的具體用法?Java SimpleMessageListenerContainer.setConcurrentConsumers怎麽用?Java SimpleMessageListenerContainer.setConcurrentConsumers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
的用法示例。
在下文中一共展示了SimpleMessageListenerContainer.setConcurrentConsumers方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例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(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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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);
}
示例8: 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;
}
示例9: messageListenerContainer
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入方法依賴的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;
}
示例10: container_emsRegistrator
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入方法依賴的package包/類
@Bean
SimpleMessageListenerContainer container_emsRegistrator() {
if (listenerAdapter_emsRegistrator != null) {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConnectionFactory(emsConnectionFactory);
container.setQueueNames(queueName_emsRegistrator);
container.setConcurrentConsumers(1);
container.setMaxConcurrentConsumers(15);
container.setMessageListener(listenerAdapter_emsRegistrator);
return container;
} else return null;
}
示例11: createMessageListenerContainer
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入方法依賴的package包/類
public SimpleMessageListenerContainer createMessageListenerContainer(MessageListenerAdapter messageListener, Queue... queuesToListenOn) {
validateInput(messageListener, queuesToListenOn);
SimpleMessageListenerContainer simpleMessageListenerContainer = new SimpleMessageListenerContainer(connectionFactory);
simpleMessageListenerContainer.setQueues(queuesToListenOn);
simpleMessageListenerContainer.setMessageListener(messageListener);
simpleMessageListenerContainer.setConcurrentConsumers(messagingConfiguration.getConcurrentConsumers());
return simpleMessageListenerContainer;
}
開發者ID:zeroDivisible,項目名稱:spring-rabbitmq-example,代碼行數:11,代碼來源:SimpleMessageListenerContainerFactory.java
示例12: controlContainer
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入方法依賴的package包/類
/**
* SimpleMessageListenerContainerのインスタンスをDIコンテナに登録します。
* @return SimpleMessageListenerContainerのインスタンス
*/
@Bean
public SimpleMessageListenerContainer controlContainer() {
SimpleMessageListenerContainer container = makeContainer();
container.setQueues(resourceConsumerQueue());
container.setMessageListener(consumerAdapter());
container.setConcurrentConsumers(10);
return container;
}
示例13: listenerContainer
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入方法依賴的package包/類
@Bean
public SimpleMessageListenerContainer listenerContainer() {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
container.setConcurrentConsumers(5);
container.setConnectionFactory(connectionFactory());
container.setQueues(responseQueue());
container.setMessageListener(rabbitTemplate());
return container;
}
示例14: createConsumerEndpoint
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; //導入方法依賴的package包/類
@Override
protected MessageProducer createConsumerEndpoint(ConsumerDestination consumerDestination, String group,
ExtendedConsumerProperties<RabbitConsumerProperties> properties) {
Assert.state(!HeaderMode.embeddedHeaders.equals(properties.getHeaderMode()),
"the RabbitMQ binder does not support embedded headers since RabbitMQ supports headers natively");
String destination = consumerDestination.getName();
SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(
this.connectionFactory);
listenerContainer.setAcknowledgeMode(properties.getExtension().getAcknowledgeMode());
listenerContainer.setChannelTransacted(properties.getExtension().isTransacted());
listenerContainer.setDefaultRequeueRejected(properties.getExtension().isRequeueRejected());
int concurrency = properties.getConcurrency();
concurrency = concurrency > 0 ? concurrency : 1;
listenerContainer.setConcurrentConsumers(concurrency);
int maxConcurrency = properties.getExtension().getMaxConcurrency();
if (maxConcurrency > concurrency) {
listenerContainer.setMaxConcurrentConsumers(maxConcurrency);
}
listenerContainer.setPrefetchCount(properties.getExtension().getPrefetch());
listenerContainer.setRecoveryInterval(properties.getExtension().getRecoveryInterval());
listenerContainer.setTxSize(properties.getExtension().getTxSize());
listenerContainer.setTaskExecutor(new SimpleAsyncTaskExecutor(consumerDestination.getName() + "-"));
listenerContainer.setQueueNames(consumerDestination.getName());
listenerContainer.setAfterReceivePostProcessors(this.decompressingPostProcessor);
listenerContainer.setMessagePropertiesConverter(
RabbitMessageChannelBinder.inboundMessagePropertiesConverter);
listenerContainer.setExclusive(properties.getExtension().isExclusive());
listenerContainer.setMissingQueuesFatal(properties.getExtension().getMissingQueuesFatal());
if (properties.getExtension().getQueueDeclarationRetries() != null) {
listenerContainer.setDeclarationRetries(properties.getExtension().getQueueDeclarationRetries());
}
if (properties.getExtension().getFailedDeclarationRetryInterval() != null) {
listenerContainer.setFailedDeclarationRetryInterval(
properties.getExtension().getFailedDeclarationRetryInterval());
}
listenerContainer.afterPropertiesSet();
AmqpInboundChannelAdapter adapter = new AmqpInboundChannelAdapter(listenerContainer);
adapter.setBeanFactory(this.getBeanFactory());
adapter.setBeanName("inbound." + destination);
DefaultAmqpHeaderMapper mapper = DefaultAmqpHeaderMapper.inboundMapper();
mapper.setRequestHeaderNames(properties.getExtension().getHeaderPatterns());
adapter.setHeaderMapper(mapper);
ErrorInfrastructure errorInfrastructure = registerErrorInfrastructure(consumerDestination, group, properties);
if (properties.getMaxAttempts() > 1) {
adapter.setRetryTemplate(buildRetryTemplate(properties));
if (properties.getExtension().isRepublishToDlq()) {
adapter.setRecoveryCallback(errorInfrastructure.getRecoverer());
}
}
else {
adapter.setErrorMessageStrategy(errorMessageStrategy);
adapter.setErrorChannel(errorInfrastructure.getErrorChannel());
}
return adapter;
}
開發者ID:spring-cloud,項目名稱:spring-cloud-stream-binder-rabbit,代碼行數:57,代碼來源:RabbitMessageChannelBinder.java