Skip to content

need a way to retrieve event hub message headers #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
reyang opened this issue Jun 29, 2016 · 11 comments
Closed

need a way to retrieve event hub message headers #465

reyang opened this issue Jun 29, 2016 · 11 comments
Assignees
Milestone

Comments

@reyang
Copy link
Member

reyang commented Jun 29, 2016

For eventHubTrigger, is there a way to get the event hub message headers? Currently only the message payload is provided – while there are a lot of useful information from the headers I wish to retrieve.
Also, it'll be very helpful if there is an example of how to properly handle error - for example, if exception happened while trying to process the event, instead of removing the event from the service bus, leave it and have a chance to retry. This would require access to the retry count, lease time, etc.

@mathewc
Copy link
Member

mathewc commented Jun 29, 2016

In the case of C# functions, you can bind to the raw SB messaging EventData Type as described in the wiki here. I assume EventData has all the information on an event you would require.

What language is your Function written in?

@reyang
Copy link
Member Author

reyang commented Jul 4, 2016

NodeJS, however I will also be interested to know if there is a C# example.

@mathewc
Copy link
Member

mathewc commented Jul 5, 2016

For C#, you'd just change your parameter type to EventData. To do so, you need to add a line #r "Microsoft.ServiceBus" at the top of your function file, and add a using statement for "Microsoft.ServiceBus.Messaging".

For Node, there is no way currently, but we have some existing issues (e.g. #364) tracking the general issue of providing more trigger input data/control to Node functions.

@MikeStall
Copy link
Contributor

@reyang -

  1. "if exception happened while trying to process the event, instead of removing the event from the service bus, leave it and have a chance to retry. " Eventhub is a high throughput system; to keep up with the volume, we receive the events in a batch and checkpoint the entire batch. We don't have support for granular checkpointing. Is this essential for your scenarios?
  2. We can promote some of the properties directly to the "binding data" so that it can be accessible from other languages. We already do this for PartitionContext.
    When you refer to "headers", which properties on EventData / PartitionContext exactly are you interested in accessing?

@xscript
Copy link

xscript commented Sep 11, 2016

@MikeStall to answer your 2nd question, we want to access EventData.SystemProperties. Property keys we want to access are:

  • iothub-connection-device-id
  • iothub-connection-auth-method
  • iothub-connection-auth-generation-id

And I think people might also would like to access EventData.Properties for custom properties in their event data. Although we don't have such requirement yet, it is giving more flexibility to user when dealing with complicated scenarios.

@paulbatum paulbatum modified the milestones: Next - Triaged, Iteration 22 Nov 14, 2016
@mathewc
Copy link
Member

mathewc commented Dec 15, 2016

We also need to add the ability for people to set EventData properties like PartitionKey etc. for output bindings. Currently for languages like Node.js. E.g., support an 'object' binding which will allow users to specify a json object with all the relevant components that we then map to EventData.

@mathewc
Copy link
Member

mathewc commented Mar 22, 2017

Addressed via #1337. You can now access all the EventData properties via context.bindingData. This work will be released in the next couple weeks.

Example for single event: https://github.com/Azure/azure-webjobs-sdk-script/blob/dev/test/WebJobs.Script.Tests.Integration/TestScripts/Node/EventHubTrigger/index.js#L4

Example for multiple events: https://github.com/Azure/azure-webjobs-sdk-script/blob/dev/sample/EventHubTrigger/index.js#L11

@mathewc mathewc closed this as completed Mar 22, 2017
@mathewc
Copy link
Member

mathewc commented Mar 24, 2017

See wiki page here for more info: https://github.com/Azure/azure-webjobs-sdk-script/wiki/Trigger-Binding-Data

@reyang
Copy link
Member Author

reyang commented Mar 24, 2017

Great, thank you! 👍

@vjrantal
Copy link

See wiki page here for more info: https://github.com/Azure/azure-webjobs-sdk-script/wiki/Trigger-Binding-Data

A small improvement proposal to the code in above page. There is line id = input[i].value;, but I believe that should be id = events[i].value; to match the way the argument is named.

Also, should this be already in production? I created a new function, but with a quick look, the bindingData property did not contain propertiesArray and systemPropertiesArray.

@vjrantal
Copy link

Tested again today and now the properties were there - thanks!

@mathewc The small error in the sample code seems to still be there (see my previous comment).

@ghost ghost locked as resolved and limited conversation to collaborators Jan 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants