Akc.Azure.WebJobs.Extensions.ActiveMQ 0.0.8-preview.1163

This is a prerelease version of Akc.Azure.WebJobs.Extensions.ActiveMQ.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Akc.Azure.WebJobs.Extensions.ActiveMQ --version 0.0.8-preview.1163                
NuGet\Install-Package Akc.Azure.WebJobs.Extensions.ActiveMQ -Version 0.0.8-preview.1163                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Akc.Azure.WebJobs.Extensions.ActiveMQ" Version="0.0.8-preview.1163" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Akc.Azure.WebJobs.Extensions.ActiveMQ --version 0.0.8-preview.1163                
#r "nuget: Akc.Azure.WebJobs.Extensions.ActiveMQ, 0.0.8-preview.1163"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Akc.Azure.WebJobs.Extensions.ActiveMQ as a Cake Addin
#addin nuget:?package=Akc.Azure.WebJobs.Extensions.ActiveMQ&version=0.0.8-preview.1163&prerelease

// Install Akc.Azure.WebJobs.Extensions.ActiveMQ as a Cake Tool
#tool nuget:?package=Akc.Azure.WebJobs.Extensions.ActiveMQ&version=0.0.8-preview.1163&prerelease                

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 queue
  • ActiveMQ: 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)
{

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)
{

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 and ActiveMQOutputMessage.
  • Types available in isolated mode: string and ActiveMQOutputMessage.

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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