cti-kafka-rest-event-interceptor
v1.1.1
Published
Library to intercept Apache Kafka messages for testing purposes
Downloads
4
Readme
cti-kafka-rest-event-interceptor
Library to intercept Apache Kafka messages for testing purposes
Usage
const eventInterceptor = require( 'cti-kafka-rest-event-interceptor' );
const KafkaRestEventPublisher = require( 'cti-kafka-rest-event-publisher' ).KafkaRestEventPublisher;
const options = {
url: 'http://localhost',
topic: 'interceptorTest',
filter: {
body: {
message: 'Test message'
}
},
response: {
code: 200,
body: {
data: 'Test data'
}
}
};
const event = {
message: 'Test message'
};
const interceptedEvent = eventInterceptor.intercept( options );
const eventPublisher = new KafkaRestEventPublisher( options.url );
return eventPublisher.publish( context, options.topic, event )
.then( res => {
console.log( `Event was intercepted: ${ eventInterceptor.wasIntercepted( interceptedEvent ) }` );
console.log( res );
} );