-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.transferwise.kafka.tkms.config; | ||
|
||
import java.util.function.Function; | ||
import org.apache.kafka.clients.producer.Producer; | ||
|
||
public interface ITkmsKafkaProducerPostProcessor extends Function<Producer<String, byte[]>, Producer<String, byte[]>> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package com.transferwise.kafka.tkms; | ||
|
||
import com.transferwise.common.baseutils.transactionsmanagement.ITransactionsHelper; | ||
import com.transferwise.kafka.tkms.api.ITransactionalKafkaMessageSender; | ||
import com.transferwise.kafka.tkms.api.TkmsMessage; | ||
import com.transferwise.kafka.tkms.test.BaseIntTest; | ||
import com.transferwise.kafka.tkms.test.ITkmsSentMessagesCollector; | ||
import com.transferwise.kafka.tkms.test.TestProperties; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.stream.StreamSupport; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import static com.transferwise.kafka.tkms.test.TestKafkaProducerPostProcessor.TEST_MESSAGE; | ||
Check warning on line 17 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
Check warning on line 17 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
|
||
import static org.awaitility.Awaitility.await; | ||
Check warning on line 18 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
Check warning on line 18 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
Check warning on line 19 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
Check warning on line 19 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
Check warning on line 20 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
Check warning on line 20 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
|
||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class MessagePostProcessingTest extends BaseIntTest { | ||
|
||
|
||
@Autowired | ||
Check warning on line 26 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 26 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
protected ITkmsSentMessagesCollector tkmsSentMessagesCollector; | ||
@Autowired | ||
Check warning on line 28 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 28 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
private TransactionalKafkaMessageSender transactionalKafkaMessageSender; | ||
@Autowired | ||
Check warning on line 30 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 30 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
private TestProperties testProperties; | ||
@Autowired | ||
Check warning on line 32 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 32 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
private ITransactionsHelper transactionsHelper; | ||
|
||
@BeforeEach | ||
Check warning on line 35 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 35 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
void setupTest() { | ||
tkmsSentMessagesCollector.clear(); | ||
Check warning on line 37 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 37 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
} | ||
Check warning on line 38 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 38 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
|
||
@AfterEach | ||
Check warning on line 40 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 40 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
void cleanupTest() { | ||
tkmsSentMessagesCollector.clear(); | ||
Check warning on line 42 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 42 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
} | ||
Check warning on line 43 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 43 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
|
||
@Test | ||
Check warning on line 45 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 45 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
void messagesAreInstrumentedWithProducerPostProcessor() { | ||
byte[] someValue = TEST_MESSAGE; | ||
Check warning on line 47 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 47 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
|
||
String topic = testProperties.getTestTopic(); | ||
Check warning on line 49 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 49 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
|
||
transactionsHelper.withTransaction().run(() -> | ||
Check warning on line 51 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 51 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
transactionalKafkaMessageSender.sendMessages(new ITransactionalKafkaMessageSender.SendMessagesRequest() | ||
.addTkmsMessage(new TkmsMessage().setTopic(topic).setKey("1").setValue(someValue)) | ||
.addTkmsMessage(new TkmsMessage().setTopic(topic).setKey("2").setValue(someValue)) | ||
)); | ||
|
||
await().until(() -> tkmsSentMessagesCollector.getSentMessages(topic).size() == 2); | ||
Check warning on line 57 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 57 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
var messages = tkmsSentMessagesCollector.getSentMessages(topic); | ||
Check warning on line 58 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 58 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
|
||
assertEquals(2, messages.size()); | ||
Check warning on line 60 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 60 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
checkForHeader(messages.get(0), "wrapTest", "wrapped"); | ||
Check warning on line 61 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 61 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
checkForHeader(messages.get(1), "wrapTest", "wrapped"); | ||
Check warning on line 62 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 62 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
} | ||
Check warning on line 63 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 63 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
|
||
private void checkForHeader(ITkmsSentMessagesCollector.SentMessage sentMessage, String key, String value) { | ||
Check warning on line 65 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 65 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
assertTrue( | ||
Check warning on line 66 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 66 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
StreamSupport.stream(sentMessage.getProducerRecord().headers().spliterator(), false) | ||
.anyMatch(h -> h.key().equals(key) && value.equals(new String(h.value(), StandardCharsets.UTF_8))) | ||
); | ||
Check warning on line 69 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 69 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
} | ||
Check warning on line 70 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
Check warning on line 70 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/MessagePostProcessingTest.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.transferwise.kafka.tkms.test; | ||
|
||
import java.lang.reflect.InvocationHandler; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.lang.reflect.Proxy; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Arrays; | ||
import com.transferwise.kafka.tkms.config.ITkmsKafkaProducerPostProcessor; | ||
Check warning on line 9 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/test/TestKafkaProducerPostProcessor.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
Check warning on line 9 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/test/TestKafkaProducerPostProcessor.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
|
||
import com.transferwise.kafka.tkms.config.TkmsKafkaProducerProvider; | ||
Check warning on line 10 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/test/TestKafkaProducerPostProcessor.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
Check warning on line 10 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/test/TestKafkaProducerPostProcessor.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck
|
||
import org.apache.kafka.clients.producer.Callback; | ||
import org.apache.kafka.clients.producer.Producer; | ||
import org.apache.kafka.clients.producer.ProducerRecord; | ||
import org.springframework.beans.factory.InitializingBean; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
//@TestConfiguration | ||
public class TestKafkaProducerPostProcessor implements ITkmsKafkaProducerPostProcessor, InitializingBean { | ||
|
||
public static final byte[] TEST_MESSAGE = "Testing ProducerPostProcessing".getBytes(StandardCharsets.UTF_8);; | ||
Check warning on line 23 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/test/TestKafkaProducerPostProcessor.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck
Check warning on line 23 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/test/TestKafkaProducerPostProcessor.java GitHub Actions / Checkstyle Report-(3.2.2)com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck
Check warning on line 23 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/test/TestKafkaProducerPostProcessor.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck
Check warning on line 23 in tw-tkms-starter/src/test/java/com/transferwise/kafka/tkms/test/TestKafkaProducerPostProcessor.java GitHub Actions / Checkstyle Report-(3.3.1)com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck
|
||
|
||
private MyInvocationHandler handler; | ||
|
||
@Autowired | ||
TkmsKafkaProducerProvider tkmsKafkaProducerProvider; | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public Producer<String, byte[]> apply(Producer<String, byte[]> producer) { | ||
handler = new MyInvocationHandler(producer); | ||
return (Producer<String, byte[]>) | ||
Proxy.newProxyInstance( | ||
TestKafkaProducerPostProcessor.class.getClassLoader(), | ||
new Class<?>[] {Producer.class}, | ||
handler); | ||
} | ||
|
||
@Override | ||
public void afterPropertiesSet() throws Exception { | ||
tkmsKafkaProducerProvider.addPostProcessor(this); | ||
} | ||
|
||
private static class MyInvocationHandler implements InvocationHandler { | ||
|
||
private final Producer<String, byte[]> producer; | ||
|
||
public MyInvocationHandler(Producer<String, byte[]> producer) { | ||
this.producer = producer; | ||
} | ||
|
||
public Producer<String, byte[]> getProducer() { | ||
return producer; | ||
} | ||
|
||
@Override | ||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { | ||
if ("send".equals(method.getName()) | ||
&& method.getParameterCount() >= 1 | ||
&& method.getParameterTypes()[0] == ProducerRecord.class) { | ||
ProducerRecord<String, byte[]> record = (ProducerRecord<String, byte[]>) args[0]; | ||
if (Arrays.equals(TEST_MESSAGE, record.value())) { | ||
record.headers().add("wrapTest", "wrapped".getBytes()); | ||
} | ||
Callback callback = | ||
method.getParameterCount() >= 2 | ||
&& method.getParameterTypes()[1] == Callback.class | ||
? (Callback) args[1] | ||
: null; | ||
return producer.send(record, callback); | ||
} else { | ||
try { | ||
return method.invoke(producer, args); | ||
} catch (InvocationTargetException exception) { | ||
throw exception.getCause(); | ||
} | ||
} | ||
} | ||
} | ||
} |