public static void rollbackIfNecessary(Channel channel) { Assert.notNull(channel, "Channel must not be null"); try { channel.txRollback(); } catch (IOException ex) { throw new AmqpIOException(ex); } }
public static void rollbackIfNecessary(Channel channel) { Assert.notNull(channel, "Channel must not be null"); try { channel.txRollback(); } catch (IOException ex) { throw new AmqpIOException(ex); } }
/** * Commit the Channel if not within a JTA transaction. * @param channel the RabbitMQ Channel to commit */ public static void commitIfNecessary(Channel channel) { Assert.notNull(channel, "Channel must not be null"); try { channel.txCommit(); } catch (IOException ex) { throw new AmqpIOException(ex); } }
/** * Commit the Channel if not within a JTA transaction. * @param channel the RabbitMQ Channel to commit */ public static void commitIfNecessary(Channel channel) { Assert.notNull(channel, "Channel must not be null"); try { channel.txCommit(); } catch (IOException ex) { throw new AmqpIOException(ex); } }
@Override public void addQueues(Queue... queues) { Assert.notNull(queues, "'queues' cannot be null"); Assert.noNullElements(queues, "'queues' cannot contain null elements"); try { addQueues(Arrays.stream(queues).map(Queue::getName)); } catch (AmqpIOException e) { throw new AmqpIOException("Failed to add " + Arrays.toString(queues), e); } super.addQueues(queues); }
@Override public void addQueues(Queue... queues) { Assert.notNull(queues, "'queues' cannot be null"); Assert.noNullElements(queues, "'queues' cannot contain null elements"); try { addQueues(Arrays.stream(queues).map(Queue::getName)); } catch (AmqpIOException e) { throw new AmqpIOException("Failed to add " + Arrays.toString(queues), e); } super.addQueues(queues); }
@Override public void addQueueNames(String... queueNames) { Assert.notNull(queueNames, "'queueNames' cannot be null"); Assert.noNullElements(queueNames, "'queueNames' cannot contain null elements"); try { addQueues(Arrays.stream(queueNames)); } catch (AmqpIOException e) { throw new AmqpIOException("Failed to add " + Arrays.toString(queueNames), e); } super.addQueueNames(queueNames); }
@Override public void addQueueNames(String... queueNames) { Assert.notNull(queueNames, "'queueNames' cannot be null"); Assert.noNullElements(queueNames, "'queueNames' cannot contain null elements"); try { addQueues(Arrays.stream(queueNames)); } catch (AmqpIOException e) { throw new AmqpIOException("Failed to add " + Arrays.toString(queueNames), e); } super.addQueueNames(queueNames); }
public void rollbackAll() { for (Channel channel : this.channels) { if (logger.isDebugEnabled()) { logger.debug("Rolling back messages to channel: " + channel); } RabbitUtils.rollbackIfNecessary(channel); if (this.deliveryTags.containsKey(channel)) { for (Long deliveryTag : this.deliveryTags.get(channel)) { try { channel.basicReject(deliveryTag, this.requeueOnRollback); } catch (IOException ex) { throw new AmqpIOException(ex); } } // Need to commit the reject (=nack) RabbitUtils.commitIfNecessary(channel); } } }
public void rollbackAll() { for (Channel channel : this.channels) { if (logger.isDebugEnabled()) { logger.debug("Rolling back messages to channel: " + channel); } RabbitUtils.rollbackIfNecessary(channel); if (this.deliveryTags.containsKey(channel)) { for (Long deliveryTag : this.deliveryTags.get(channel)) { try { channel.basicReject(deliveryTag, this.requeueOnRollback); } catch (IOException ex) { throw new AmqpIOException(ex); } } // Need to commit the reject (=nack) RabbitUtils.commitIfNecessary(channel); } } }
@Override public Message postProcessMessage(Message message) throws AmqpException { ByteArrayOutputStream zipped = new ByteArrayOutputStream(); try { OutputStream zipper = getCompressorStream(zipped); FileCopyUtils.copy(new ByteArrayInputStream(message.getBody()), zipper); MessageProperties messageProperties = message.getMessageProperties(); String currentEncoding = messageProperties.getContentEncoding(); messageProperties .setContentEncoding(getEncoding() + (currentEncoding == null ? "" : ":" + currentEncoding)); if (this.autoDecompress) { messageProperties.setHeader(MessageProperties.SPRING_AUTO_DECOMPRESS, true); } byte[] compressed = zipped.toByteArray(); if (this.logger.isTraceEnabled()) { this.logger.trace("Compressed " + message.getBody().length + " to " + compressed.length); } return new Message(compressed, messageProperties); } catch (IOException e) { throw new AmqpIOException(e); } }
throw new AmqpIOException(e);
throw new AmqpIOException(e);
Throwable targetEx = ex.getTargetException(); if (targetEx instanceof IOException) { throw new AmqpIOException((IOException) targetEx); // NOSONAR lost stack trace
Throwable targetEx = ex.getTargetException(); if (targetEx instanceof IOException) { throw new AmqpIOException((IOException) targetEx); // NOSONAR lost stack trace
private void setQosAndreateConsumers() { if (!this.acknowledgeMode.isAutoAck() && !cancelled()) { // Set basicQos before calling basicConsume (otherwise if we are not acking the broker // will send blocks of 100 messages) try { this.channel.basicQos(this.prefetchCount); } catch (IOException e) { this.activeObjectCounter.release(this); throw new AmqpIOException(e); } } try { if (!cancelled()) { for (String queueName : this.queues) { if (!this.missingQueues.contains(queueName)) { consumeFromQueue(queueName); } } } } catch (IOException e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } }
private void setQosAndreateConsumers() { if (!this.acknowledgeMode.isAutoAck() && !cancelled()) { // Set basicQos before calling basicConsume (otherwise if we are not acking the broker // will send blocks of 100 messages) try { this.channel.basicQos(this.prefetchCount); } catch (IOException e) { this.activeObjectCounter.release(this); throw new AmqpIOException(e); } } try { if (!cancelled()) { for (String queueName : this.queues) { if (!this.missingQueues.contains(queueName)) { consumeFromQueue(queueName); } } } } catch (IOException e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } }
return new AmqpIOException((IOException) ex);
return new AmqpIOException((IOException) ex);