Skip to content
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

Added AnypointMQ, JMS, SNS, Solace, SQS, STOMP, Mercure, IBMMQ, GooglePubSub and Pulsar bindings #33

Merged
merged 5 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions samples/StreetLightsApi/Services/StreetLightsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
await message.AcknowledgeAsync(stoppingToken);
});
await this.MqttClient.SubscribeAsync("onLightMeasured", cancellationToken: stoppingToken).ConfigureAwait(false);
await this.PublishLightMeasured(new() { Id = Guid.NewGuid(), Lumens = 5, SentAt = DateTime.UtcNow }).ConfigureAwait(false);
await this.PublishLightMeasured(new() { Id = Guid.NewGuid(), Lumens = 5, SentAt = DateTime.UtcNow }, stoppingToken).ConfigureAwait(false);
}

[Tag("light", "A tag for light-related operations"), Tag("measurement", "A tag for measurement-related operations")]
[Channel("light/measured"), PublishOperation(OperationId = "NotifyLightMeasured", Summary = "Notifies remote consumers about environmental lighting conditions for a particular streetlight")]
public async Task PublishLightMeasured(LightMeasuredEvent e)
public async Task PublishLightMeasured(LightMeasuredEvent e, CancellationToken cancellationToken = default)
{
var message = new MqttApplicationMessage()
{
Topic = "onLightMeasured",
ContentType = "application/json",
PayloadSegment = Encoding.UTF8.GetBytes(this.Serializer.SerializeToText(e))
};
await this.MqttClient.PublishAsync(message);
await this.MqttClient.PublishAsync(message, cancellationToken);
}

[Tag("light", "A tag for light-related operations"), Tag("measurement", "A tag for measurement-related operations")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<RepositoryUrl>https://github.com/neuroglia-io/asyncapi</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>neuroglia asyncapi async api asp ui</PackageTags>
<Version>2.6.5</Version>
<Version>2.6.6</Version>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<RepositoryUrl>https://github.com/neuroglia-io/asyncapi</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>neuroglia asyncapi async api asp</PackageTags>
<Version>2.6.5</Version>
<Version>2.6.6</Version>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<RepositoryUrl>https://github.com/neuroglia-io/asyncapi</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>neuroglia asyncapi async api cloud-event</PackageTags>
<Version>2.6.5</Version>
<Version>2.6.6</Version>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
26 changes: 26 additions & 0 deletions src/Neuroglia.AsyncApi.Core/Attributes/ExcludeAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2021-Present Neuroglia SRL. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Neuroglia.AsyncApi;

/// <summary>
/// Represents an <see cref="Attribute"/> used to exclude a parameter from the schema of an Async API message
/// </summary>
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = false)]
public class ExcludeAttribute
: Attribute
{



}
22 changes: 8 additions & 14 deletions src/Neuroglia.AsyncApi.Core/Attributes/OperationAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,16 @@ namespace Neuroglia.AsyncApi;
/// <summary>
/// Represents an <see cref="Attribute"/> used to mark a method as an <see cref="OperationDefinition"/>
/// </summary>
/// <remarks>
/// Initializes a new <see cref="OperationAttribute"/>
/// </remarks>
/// <param name="operationType">The <see cref="OperationDefinition"/>'s type</param>
/// <param name="messageType">The <see cref="OperationDefinition"/>'s message type</param>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public abstract class OperationAttribute
public abstract class OperationAttribute(OperationType operationType, Type? messageType)
: Attribute
{

/// <summary>
/// Initializes a new <see cref="OperationAttribute"/>
/// </summary>
/// <param name="operationType">The <see cref="OperationDefinition"/>'s type</param>
/// <param name="messageType">The <see cref="OperationDefinition"/>'s message type</param>
protected OperationAttribute(OperationType operationType, Type? messageType)
{
this.OperationType = operationType;
this.MessageType = messageType;
}

/// <summary>
/// Initializes a new <see cref="OperationAttribute"/>
/// </summary>
Expand All @@ -43,12 +37,12 @@ protected OperationAttribute(OperationType operationType) : this(operationType,
/// <summary>
/// Gets the <see cref="OperationDefinition"/>'s type
/// </summary>
public virtual OperationType OperationType { get; }
public virtual OperationType OperationType { get; } = operationType;

/// <summary>
/// Gets the <see cref="OperationDefinition"/>'s message type
/// </summary>
public virtual Type? MessageType { get; }
public virtual Type? MessageType { get; } = messageType;

/// <summary>
/// Gets/sets the <see cref="OperationDefinition"/>'s operation id
Expand Down
2 changes: 1 addition & 1 deletion src/Neuroglia.AsyncApi.Core/Neuroglia.AsyncApi.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<RepositoryUrl>https://github.com/neuroglia-io/asyncapi</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>neuroglia asyncapi async api core</PackageTags>
<Version>2.6.5</Version>
<Version>2.6.6</Version>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand Down
18 changes: 17 additions & 1 deletion src/Neuroglia.AsyncApi.Core/v2/AsyncApiProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public static class AsyncApiProtocol
/// </summary>
public const string Kafka = "kafka";
/// <summary>
/// Gets the anypointmq Async API protocol
/// </summary>
public const string AnypointMQ = "anypointmq";
/// <summary>
/// Gets the amqp Async API protocol
/// </summary>
public const string Amqp = "amqp";
Expand All @@ -48,6 +52,10 @@ public static class AsyncApiProtocol
/// </summary>
public const string AmqpV1 = "amqp1";
/// <summary>
/// Gets the googlepubsub Async API protocol
/// </summary>
public const string GooglePubSub = "googlepubsub";
/// <summary>
/// Gets the mqtt Async API protocol
/// </summary>
public const string Mqtt = "mqtt";
Expand All @@ -60,6 +68,10 @@ public static class AsyncApiProtocol
/// </summary>
public const string Nats = "nats";
/// <summary>
/// Gets the pulsar Async API protocol
/// </summary>
public const string Pulsar = "pulsar";
/// <summary>
/// Gets the jms Async API protocol
/// </summary>
public const string Jms = "jms";
Expand All @@ -68,6 +80,10 @@ public static class AsyncApiProtocol
/// </summary>
public const string Sns = "sns";
/// <summary>
/// Gets the solace Async API protocol
/// </summary>
public const string Solace = "solace";
/// <summary>
/// Gets the sqs Async API protocol
/// </summary>
public const string Sqs = "sqs";
Expand All @@ -86,6 +102,6 @@ public static class AsyncApiProtocol
/// <summary>
/// Gets the ibmmq Async API protocol
/// </summary>
public const string Ibmmq = "ibmmq";
public const string IbmMQ = "ibmmq";

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Neuroglia.AsyncApi.v2;
using Neuroglia.AsyncApi.v2.Bindings;

namespace Neuroglia.AsyncApi.v2.Bindings.AmqpV1;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Neuroglia.AsyncApi.v2.Bindings;

namespace Neuroglia.AsyncApi.v2.Bindings.AmqpV1;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright © 2021-Present Neuroglia SRL. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ;

/// <summary>
/// Represents the base record for all Anypoint MQ implementations of the <see cref="IBindingDefinition"/> interface
/// </summary>
[DataContract]
public abstract record AnypointMQBindingDefinition
: IBindingDefinition
{

/// <inheritdoc/>
[IgnoreDataMember, JsonIgnore, YamlIgnore]
public IEnumerable<string> Protocols
{
get
{
yield return AsyncApiProtocol.AnypointMQ;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright © 2021-Present Neuroglia SRL. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ;

/// <summary>
/// Represents the object used to configure an Anypoint MQ channel binding
/// </summary>
[DataContract]
public record AnypointMQChannelBindingDefinition
: AnypointMQBindingDefinition, IChannelBindingDefinition
{

/// <summary>
/// Gets/sets the destination (queue or exchange) name for this channel. SHOULD only be specified if the channel name differs from the actual destination name, such as when the channel name is not a valid destination name in Anypoint MQ.
/// </summary>
[DataMember(Order = 1, Name = "destination"), JsonPropertyOrder(1), JsonPropertyName("destination"), YamlMember(Order = 1, Alias = "destination")]
public virtual string? Destination { get; set; }

/// <summary>
/// Gets/sets the type of destination, which MUST be either exchange or queue or fifo-queue. SHOULD be specified to document the messaging model (publish/subscribe, point-to-point, strict message ordering) supported by this channel.
/// </summary>
[DataMember(Order = 2, Name = "destinationType"), JsonPropertyOrder(2), JsonPropertyName("destinationType"), YamlMember(Order = 2, Alias = "destinationType")]
public virtual AnypointMQDestinationType DestinationType { get; set; } = AnypointMQDestinationType.Queue;

/// <summary>
/// Gets/sets the version of this binding.
/// </summary>
[DataMember(Order = 3, Name = "bindingVersion"), JsonPropertyOrder(3), JsonPropertyName("bindingVersion"), YamlMember(Order = 3, Alias = "bindingVersion")]
public virtual string BindingVersion { get; set; } = "latest";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright © 2021-Present Neuroglia SRL. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Json.Schema;

namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ;

/// <summary>
/// Represents the object used to configure an Anypoint MQ message binding
/// </summary>
[DataContract]
public record AnypointMQMessageBindingDefinition
: AnypointMQBindingDefinition, IMessageBindingDefinition
{

/// <summary>
/// Gets/sets a schema object containing the definitions for Anypoint MQ-specific headers (so-called protocol headers). This schema MUST be of type object and have a properties key. Examples of Anypoint MQ protocol headers are messageId and messageGroupId
/// </summary>
[DataMember(Order = 1, Name = "headers"), JsonPropertyOrder(1), JsonPropertyName("headers"), YamlMember(Order = 1, Alias = "headers")]
public virtual JsonSchema? Headers { get; set; }

/// <summary>
/// Gets/sets the version of this binding.
/// </summary>
[DataMember(Order = 2, Name = "bindingVersion"), JsonPropertyOrder(2), JsonPropertyName("bindingVersion"), YamlMember(Order = 2, Alias = "bindingVersion")]
public virtual string BindingVersion { get; set; } = "latest";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2021-Present Neuroglia SRL. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ;

/// <summary>
/// Represents the object used to configure an Anypoint MQ operation binding
/// </summary>
[DataContract]
public record AnypointMQOperationBindingDefinition
: AnypointMQBindingDefinition, IOperationBindingDefinition
{



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright © 2021-Present Neuroglia SRL. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"),
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Neuroglia.AsyncApi.v2.Bindings.AnypointMQ;

/// <summary>
/// Represents the object used to configure an Anypoint MQ server binding
/// </summary>
[DataContract]
public record AnypointMQServerBindingDefinition
: AnypointMQBindingDefinition, IServerBindingDefinition
{



}
Loading
Loading