List of usage examples for com.rabbitmq.client Channel waitForConfirmsOrDie
void waitForConfirmsOrDie() throws IOException, InterruptedException;
From source file:org.axonframework.eventhandling.amqp.spring.SpringAMQPTerminal.java
License:Apache License
@Override public void publish(EventMessage... events) { final Channel channel = connectionFactory.createConnection().createChannel(isTransactional); try {//from w w w. jav a2 s . co m if (waitForAck) { channel.confirmSelect(); } for (EventMessage event : events) { AMQPMessage amqpMessage = messageConverter.createAMQPMessage(event); doSendMessage(channel, amqpMessage); } if (CurrentUnitOfWork.isStarted()) { CurrentUnitOfWork.get().registerListener(new ChannelTransactionUnitOfWorkListener(channel)); } else if (isTransactional) { channel.txCommit(); } else if (waitForAck) { channel.waitForConfirmsOrDie(); } } catch (IOException e) { if (isTransactional) { tryRollback(channel); } throw new EventPublicationFailedException("Failed to dispatch Events to the Message Broker.", e); } catch (ShutdownSignalException e) { throw new EventPublicationFailedException("Failed to dispatch Events to the Message Broker.", e); } catch (InterruptedException e) { logger.warn("Interrupt received when waiting for message confirms."); Thread.currentThread().interrupt(); } finally { if (!CurrentUnitOfWork.isStarted()) { tryClose(channel); } } }