Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Logging bad message receive

  • Loading branch information...
commit 09e54dc1bf60bec4d31d1eba1df34932f6616da5 1 parent c456972
@christav christav authored
Showing with 26 additions and 0 deletions.
  1. +4 −0 lib/servicebusconnector.js
  2. +22 −0 test/logging-tests.js
View
4 lib/servicebusconnector.js
@@ -119,6 +119,10 @@ ServiceBusConnector.prototype.unpackMessage = function(message) {
return result;
} catch (ex) {
// Issue unpacking the message, assume it's bad and toss it
+ this.log && this.log.warn('Service Bus bad message received',
+ 'CorrelationId:' + message.brokerProperties.CorrelationId,
+ 'Label:' + message.brokerProperties.Label,
+ 'SequenceNumber:' + message.brokerProperties.SequenceNumber);
return result;
}
}
View
22 test/logging-tests.js
@@ -84,9 +84,31 @@ describe('logging', function () {
logger.debug.calledWith('Service Bus poll: no message').should.be.true;
});
+ it('should log when a bad message is received', function () {
+ var message = {
+ brokerProperties: {
+ CorrelationId: 'sourceNode',
+ Label: 'aMessage',
+ SequenceNumber: 1
+ },
+ body: 'This will not deserialize'
+ };
+
+ recv(message);
+ logger.warn.calledWith('Service Bus bad message received',
+ 'CorrelationId:sourceNode', 'Label:aMessage', 'SequenceNumber:1')
+ .should.be.true;
+ });
+
// Helpers for sending messages
function recvNothing() {
var recvFunc = recvFuncs.shift();
recvFunc('No messages to receive');
}
+
+ function recv(message) {
+ var recvFunc = recvFuncs.shift();
+ recvFunc(null, message);
+ }
+
});
Please sign in to comment.
Something went wrong with that request. Please try again.