org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar Java Examples

The following examples show how to use org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmqpMessageBrokerConfiguration.java    From piper with Apache License 2.0 6 votes vote down vote up
@Override
public void configureRabbitListeners(RabbitListenerEndpointRegistrar aRegistrar) {
  CoordinatorProperties coordinatorProperties = properties.getCoordinator();
  WorkerProperties workerProperties = properties.getWorker();
  if(coordinatorProperties.isEnabled()) {
    registerListenerEndpoint(aRegistrar, Queues.COMPLETIONS, coordinatorProperties.getSubscriptions().getCompletions() , coordinator, "complete");
    registerListenerEndpoint(aRegistrar, Queues.ERRORS, coordinatorProperties.getSubscriptions().getErrors(), coordinator, "handleError");
    registerListenerEndpoint(aRegistrar, Queues.EVENTS, coordinatorProperties.getSubscriptions().getEvents(), eventListener, "onApplicationEvent");
    registerListenerEndpoint(aRegistrar, Queues.JOBS, coordinatorProperties.getSubscriptions().getJobs(), coordinator, "start");
    registerListenerEndpoint(aRegistrar, Queues.SUBFLOWS, coordinatorProperties.getSubscriptions().getSubflows(), coordinator, "create");
  }
  if(workerProperties.isEnabled()) {
    Map<String, Object> subscriptions = workerProperties.getSubscriptions();
    subscriptions.forEach((k,v) -> registerListenerEndpoint(aRegistrar, k, Integer.valueOf((String)v), worker, "handle"));
    registerListenerEndpoint(aRegistrar, controlQueue(), controlExchange(), 1, worker, "handle");
  }
}
 
Example #2
Source File: AmqpMessageBrokerConfiguration.java    From piper with Apache License 2.0 6 votes vote down vote up
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));
}
 
Example #3
Source File: RabbitConfiguration.java    From heimdall with Apache License 2.0 5 votes vote down vote up
@Override
public void configureRabbitListeners(final RabbitListenerEndpointRegistrar registrar) {

     registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory());
}
 
Example #4
Source File: AmqpMessageBrokerConfiguration.java    From piper with Apache License 2.0 5 votes vote down vote up
private void registerListenerEndpoint(RabbitListenerEndpointRegistrar aRegistrar, String aQueueName, int aConcurrency, Object aDelegate, String aMethodName) {
  logger.info("Registring AMQP Listener: {} -> {}:{}", aQueueName, aDelegate.getClass().getName(), aMethodName);

  Map<String, Object> args = new HashMap<String, Object>();
  args.put("x-dead-letter-exchange", "");
  args.put("x-dead-letter-routing-key", Queues.DLQ);
  
  Queue queue = new Queue(aQueueName, true, false, false, args);
  
  registerListenerEndpoint(aRegistrar, queue, tasksExchange(), aConcurrency, aDelegate, aMethodName);
}
 
Example #5
Source File: RabbitConfiguration.java    From heimdall with Apache License 2.0 4 votes vote down vote up
@Override
public void configureRabbitListeners(final RabbitListenerEndpointRegistrar registrar) {

     registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory());
}
 
Example #6
Source File: RabbitConfig.java    From POC with Apache License 2.0 4 votes vote down vote up
@Override
public void configureRabbitListeners(RabbitListenerEndpointRegistrar registrar) {
	registrar.setMessageHandlerMethodFactory(messageHandlerMethodFactory());
}