-
Notifications
You must be signed in to change notification settings - Fork 55
Samples in Java
Yogesh Jagadeesan edited this page Dec 21, 2020
·
4 revisions
This sample outputs a string to a specified queue in RabbitMQ.
@FunctionName("RabbitMQOutputExample")
public void run(
@TimerTrigger(name = "keepAliveTrigger", schedule = "0 */5 * * * *") String timerInfo,
@RabbitMQOutput(connectionStringSetting = "rabbitMQConnectionAppSetting", queueName = "queue") OutputBinding<String> output,
final ExecutionContext context) {
output.setValue("Some string");
}
The below sample provides an example of getting a String as an input from a rabbitMQ queue.
@FunctionName("RabbitMQTriggerExample")
public void run(
@RabbitMQTrigger(connectionStringSetting = "rabbitMQConnectionAppSetting", queueName = "queue") String input,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request." + input);
}
The example below provides an example of how to get a POJO serialized as a string from rabbitMQ queue.
class SomePojo
{
public int X;
}
@FunctionName("RabbitMQTriggerExample")
public void Run(
@RabbitMQTrigger(connectionStringSetting = "rabbitMQConnectionAppSetting", queueName = "queue") SomePojo input,
final ExecutionContext context) {
context.getLogger().info("Java HTTP trigger processed a request." + input.X);
}