Akc.Azure.WebJobs.Extensions.ActiveMQ
0.0.10
dotnet add package Akc.Azure.WebJobs.Extensions.ActiveMQ --version 0.0.10
NuGet\Install-Package Akc.Azure.WebJobs.Extensions.ActiveMQ -Version 0.0.10
<PackageReference Include="Akc.Azure.WebJobs.Extensions.ActiveMQ" Version="0.0.10" />
paket add Akc.Azure.WebJobs.Extensions.ActiveMQ --version 0.0.10
#r "nuget: Akc.Azure.WebJobs.Extensions.ActiveMQ, 0.0.10"
// Install Akc.Azure.WebJobs.Extensions.ActiveMQ as a Cake Addin #addin nuget:?package=Akc.Azure.WebJobs.Extensions.ActiveMQ&version=0.0.10 // Install Akc.Azure.WebJobs.Extensions.ActiveMQ as a Cake Tool #tool nuget:?package=Akc.Azure.WebJobs.Extensions.ActiveMQ&version=0.0.10
ActiveMQ Extension for Azure Functions
Introduction
This repository contains the bindings and extension for ActiveMQ in Azure Functions. It's based on the Apache.NMS library.
These extensions has been tested with Artemis ActiveMQ.
There are two types of bindings in this extension:
ActiveMQTrigger
: This binding allows you to listen to a queueActiveMQ
: This binding allows you to send messages to a queue
Usage
ActiveMQTrigger
The ActiveMQTrigger
binding allows you to listen to a queue.
Note: The
ActiveMQTrigger
binding is not supported in the Consumption plan. You can use it in the Premium plan or the Dedicated (App Service) plan.
Note: Scaling out to multiple instances is not yet implemented
Configuration
queueName
: The name of the queue to listen to. Settings placeholders are supported, eg.%MyQueue%
Connection
: The raw endpoint (eg. amqp://localhost:5672/) or the name of the setting that contains it (eg.ActiveMQ:Endpoint
)UserName
: The username to use when connecting to the ActiveMQ server, or the setting that contains it (eg.ActiveMQ:UserName
)Password
: The password to use when connecting to the ActiveMQ server, or the setting that contains it (eg.ActiveMQ:Password
)
Available parameter types
string
Custom
: the content of the message is deserialized to the specified type
Example
The following example shows a function that listens to a queue, by using a string input
[FunctionName("ActiveMQTrigger")]
public static void Run(
[ActiveMQTrigger("myqueue", Connection = "ActiveMQ:Endpoint", UserName = "ActiveMQ:UserName", Password = "ActiveMQ:Password")] string message)
{
Console.WriteLine(message);
}
The following example shows a function that listens to a queue, by using a custom input
[FunctionName("ActiveMQTrigger")]
public static void Run(
[ActiveMQTrigger("myqueue", Connection = "ActiveMQ:Endpoint", UserName = "ActiveMQ:UserName", Password = "ActiveMQ:Password")] Order order)
{
Console.WriteLine(message);
}
ActiveMQ
The ActiveMQ
binding allows you to send messages to a queue.
Configuration
queueName
: The name of the queue to listen to. Settings placeholders are supported, eg.%MyQueue%
Connection
: The raw endpoint (eg. amqp://localhost:5672/) or the name of the setting that contains it (eg.ActiveMQ:Endpoint
)UserName
: The username to use when connecting to the ActiveMQ server, or the setting that contains it (eg.ActiveMQ:UserName
)Password
: The password to use when connecting to the ActiveMQ server, or the setting that contains it (eg.ActiveMQ:Password
)
Available parameter types
- Types available in-process:
string
,NmsTextMessage
,NmsBytesMessage
andActiveMQOutputMessage
. - Types available in isolated mode:
string
andActiveMQOutputMessage
.
The ActiveMQOutputMessage
is a type provided by the extension, and allows the client to set the content of the message and its properties
Example
The following examples shows a function that sends a message to a queue in an Azure Function in-process:
[FunctionName("MyFunction")]
public static void Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
[ActiveMQ("myqueue", Connection = "ActiveMQ:Endpoint", UserName = "ActiveMQ:UserName", Password = "ActiveMQ:Password")] out string text)
{
text = "Hello, world!";
}
[FunctionName("MyFunction")]
[return: ActiveMQ("myqueue", Connection = "ActiveMQ:Endpoint", UserName = "ActiveMQ:UserName", Password = "ActiveMQ:Password")]
public static string Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req)
{
return "Hello, world!";
}
[FunctionName("MyFunction")]
[return: ActiveMQ("myqueue", Connection = "ActiveMQ:Endpoint", UserName = "ActiveMQ:UserName", Password = "ActiveMQ:Password")]
public static NmsTextMessage Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
INmsMessageFactory messageFactory)
{
var message = messageFactory.CreateTextMessage("Hello, world!");
message.Properties.SetString("OrderId", Guid.NewGuid().ToString());
return message;
}
[FunctionName("MyFunction")]
public static void Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
[ActiveMQ("myqueue", Connection = "ActiveMQ:Endpoint", UserName = "ActiveMQ:UserName", Password = "ActiveMQ:Password")] out NmsBytesMessage message,
INmsMessageFactory messageFactory)
{
var message = messageFactory.CreateBytesMessage("Hello, world!");
message.Properties.SetString("OrderId", Guid.NewGuid().ToString());
}
[Function("MyFunction")]
[return: ActiveMQOutput("%ActiveMQ:Queue%", Connection = "ActiveMQ:Endpoint", UserName = "ActiveMQ:UserName", Password = "ActiveMQ:Password")]
public ActiveMQOutputMessage Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req)
{
var json = JsonSerializer.Serialize(new { Text = "Hello, world!" });
return new ActiveMQOutputMessage
{
Text = json,
Properties = { { "OrderId", Guid.NewGuid().ToString() } }
};
}
The following examples shows a function that sends a message to a queue in an Azure Function isolated:
[Function("MyFunction")]
[ActiveMQOutput("%ActiveMQ:Queue%", Connection = "ActiveMQ:Endpoint", UserName = "ActiveMQ:UserName", Password = "ActiveMQ:Password")]
public string Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req)
{
return JsonSerializer.Serialize(new { Text = "Hello, world!" });
}
[Function("MyFunction")]
[ActiveMQOutput("%ActiveMQ:Queue%", Connection = "ActiveMQ:Endpoint", UserName = "ActiveMQ:UserName", Password = "ActiveMQ:Password")]
public ActiveMQOutputMessage Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req)
{
var json = JsonSerializer.Serialize(new { Text = "Hello, world!" });
return new ActiveMQOutputMessage
{
Text = json,
Properties = { { "OrderId", Guid.NewGuid().ToString() } }
};
}
Extension Configuration
The extension can be configured using the host.json
file. Here is an example of the configuration:
{
"version": "2.0",
"extensions": {
"activeMQ": {
"transportTimeout": 5000,
"transportStartupMaxReconnectAttempts": 1
}
}
}
Contributing
This project welcomes contributions and suggestions.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Apache.NMS.AMQP (>= 2.2.0)
- Microsoft.Azure.Functions.Worker.Core (>= 1.18.0)
- Microsoft.Azure.WebJobs (>= 3.0.39)
- System.Threading.Channels (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.10 | 105 | 10/16/2024 |
0.0.9 | 188 | 9/17/2024 |
0.0.8 | 255 | 5/26/2024 |
0.0.8-preview.1163 | 57 | 5/26/2024 |
0.0.7 | 117 | 5/24/2024 |