org.apache.kafka.clients.producer.BufferExhaustedException Java Examples
The following examples show how to use
org.apache.kafka.clients.producer.BufferExhaustedException.
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: OnrampImplTest.java From data-highway with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Test public void sendFails() throws InvalidEventException, InterruptedException, ExecutionException, JsonProcessingException, IOException { when(kafkaProducer.send(any(ProducerRecord.class), any(Callback.class))).thenReturn(future); doThrow(new ExecutionException(new BufferExhaustedException("exhausted"))).when(future).get(); Future<Boolean> result = underTest.sendEvent(mapper.readTree("{\"f\": \"f16\"}")); try { result.get(); } catch (ExecutionException e) { assertThat(e.getCause(), instanceOf(BufferExhaustedException.class)); return; } fail("Expected ExecutionException"); }
Example #2
Source File: BackpressureRetryPolicy.java From hbase-connect-kafka with Apache License 2.0 | 6 votes |
@Override public boolean shouldRetry(RuntimeException e) { if(e instanceof BufferExhaustedException || e instanceof QueueFullException) { // kind of applying back pressure as we make the current thread to sleep. try { Thread.sleep(retryInterval.toMillis()); retries.inc(); } catch (InterruptedException ex) { throw Throwables.propagate(ex); } return true; } else { return false; } }
Example #3
Source File: KafkaTopicRepositoryTest.java From nakadi with MIT License | 6 votes |
@Test public void whenPostEventOverflowsBufferThenUpdateItemStatus() { final BatchItem item = new BatchItem("{}", BatchItem.EmptyInjectionConfiguration.build(1, true), new BatchItem.InjectionConfiguration[BatchItem.Injection.values().length], Collections.emptyList()); item.setPartition("1"); final List<BatchItem> batch = new ArrayList<>(); batch.add(item); when(kafkaProducer.partitionsFor(EXPECTED_PRODUCER_RECORD.topic())).thenReturn(ImmutableList.of( new PartitionInfo(EXPECTED_PRODUCER_RECORD.topic(), 1, NODE, null, null))); Mockito .doThrow(BufferExhaustedException.class) .when(kafkaProducer) .send(any(), any()); try { kafkaTopicRepository.syncPostBatch(EXPECTED_PRODUCER_RECORD.topic(), batch, "random", false); fail(); } catch (final EventPublishingException e) { assertThat(item.getResponse().getPublishingStatus(), equalTo(EventPublishingStatus.FAILED)); assertThat(item.getResponse().getDetail(), equalTo("internal error")); } }
Example #4
Source File: AsynchronousDeliveryStrategy.java From logback-kafka-appender with Apache License 2.0 | 6 votes |
@Override public <K, V, E> boolean send(Producer<K, V> producer, ProducerRecord<K, V> record, final E event, final FailedDeliveryCallback<E> failedDeliveryCallback) { try { producer.send(record, new Callback() { @Override public void onCompletion(RecordMetadata metadata, Exception exception) { if (exception != null) { failedDeliveryCallback.onFailedDelivery(event, exception); } } }); return true; } catch (BufferExhaustedException | TimeoutException e) { failedDeliveryCallback.onFailedDelivery(event, e); return false; } }