{
"bindings": [
{
"name": "mySbMsg",
"type": "serviceBusTrigger",
"direction": "in",
"topicName": "mytopic",
"subscriptionName": "mysubscription",
"connection": "marsb1_SERVICEBUS"
},
{
"name": "outputSbQueue",
"type": "serviceBus",
"direction": "out",
"topicName": "myerrortopic",
"subscriptionName": "myerrorsubscription",
"connection": "marsb1_SERVICEBUS"
}
]
}
module.exports = async function(context, mySbMsg) {
context.log('JavaScript ServiceBus topic trigger function processed message', mySbMsg);
context.log('EnqueuedTimeUtc =', context.bindingData.enqueuedTimeUtc);
context.log('DeliveryCount =', context.bindingData.deliveryCount);
context.log('MessageId =', context.bindingData.messageId);
//add logs with GTM+8 timezone
context.log("Before sending to outbinding topic - ", new Date(new Date().getTime() + (new Date().getTimezoneOffset() + 480) * 60000).toLocaleString());
context.bindings.outputSbQueue = "send message to my output binding topic";
await mydelay(60000); //delay 1min after add message to the out binding topic
context.log("after send to outbinding topic - ",new Date(new Date().getTime() + (new Date().getTimezoneOffset() + 480) * 60000).toLocaleString());
await mydelay(120000); //delay 2min at the end of the function execution
context.log("current time at the end of the function execution - ",new Date(new Date().getTime() + (new Date().getTimezoneOffset() + 480) * 60000).toLocaleString());
};
function mydelay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
module.exports = async function(context, mySbMsg) {
context.log('JavaScript ServiceBus topic trigger function processed message', mySbMsg);
context.log('EnqueuedTimeUtc =', context.bindingData.enqueuedTimeUtc);
context.log('DeliveryCount =', context.bindingData.deliveryCount);
context.log('MessageId =', context.bindingData.messageId);
//send message to output binding topic
context.bindings.outputSbQueue = "send message to my output binding topic";
//other parts of the code...
//throw exception at the end of the function
throw "Message failed";
};
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.