本文整理汇总了Java中org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter.setMessageConverter方法的典型用法代码示例。如果您正苦于以下问题:Java MessageListenerAdapter.setMessageConverter方法的具体用法?Java MessageListenerAdapter.setMessageConverter怎么用?Java MessageListenerAdapter.setMessageConverter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter
的用法示例。
在下文中一共展示了MessageListenerAdapter.setMessageConverter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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));
}
示例3: 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);
}