Skip to content

Commit c3c69de

Browse files
authored
Merge pull request #101632 from mike-urnun-msft/patch-106
Sample showing retrieval of metadata in SB message
2 parents 65ce02c + 21de232 commit c3c69de

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

articles/azure-functions/functions-bindings-service-bus.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,28 @@ The following Java function uses the `@ServiceBusQueueTrigger` annotation from t
151151
}
152152
```
153153

154+
The following Java function shows retrieval of metadata defined in _User Properties_ of a Service Bus message:
155+
```java
156+
public class ServiceBusQueueTriggerJava {
157+
@FunctionName("ServiceBusQueueTriggerJava")
158+
public void run(
159+
@ServiceBusQueueTrigger(name = "message", queueName = "myqueue", connection = "AzureWebJobsStorage") String message,
160+
@BindingName("UserProperties") UserProperties userProperties,
161+
final ExecutionContext context
162+
) {
163+
context.getLogger().info("Java Service Bus Queue trigger function executed.");
164+
context.getLogger().info(message);
165+
context.getLogger().info(userProperties.key1);
166+
context.getLogger().info(userProperties.key2);
167+
}
168+
}
169+
170+
public class UserProperties {
171+
public String key1;
172+
public String key2;
173+
}
174+
```
175+
154176
Java functions can also be triggered when a message is added to a Service Bus topic. The following example uses the `@ServiceBusTopicTrigger` annotation to describe the trigger configuration.
155177

156178
```java

0 commit comments

Comments
 (0)