本文整理汇总了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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}