我们如何使用 Masstransit 从 Azure 服务总线消费 FHIR 类型的消息?

问题描述 投票:0回答:0

我们在本地配置了 NHS 111 适配器,使用 Azure 服务总线推送数据 https://github.com/nhsconnect/integration-adaptor-111 因此,当我们从 NHS 111 测试套件推送数据时,它会将 XML 作为有效负载发送给适配器,适配器将消息转换为 FHIR 类型,我们正在尝试使用消息,但出现错误

Exception on Receiver sb://[AZURESERVICEBUS]/[QUEUENAME] during ProcessMessageCallback ActiveDispatchCount(0) ErrorRequiresRecycle(True)
System.NotSupportedException: Value cannot be retrieved using the Body property.Use GetRawAmqpMessage to access the underlying Amqp Message object.
   at BinaryData Azure.Messaging.ServiceBus.Amqp.AmqpMessageExtensions.GetBody(AmqpAnnotatedMessage message)
   at BinaryData Azure.Messaging.ServiceBus.ServiceBusReceivedMessage.get_Body()
   at new MassTransit.AzureServiceBusTransport.ServiceBusReceiveContext(ServiceBusReceivedMessage message, ReceiveEndpointContext receiveEndpointContext) in /_/src/Transports/MassTransit.Azure.ServiceBus.Core/AzureServiceBusTransport/Contexts/ServiceBusReceiveContext.cs:line 21
   at async Task MassTransit.AzureServiceBusTransport.ServiceBusMessageReceiver.Handle(ServiceBusReceivedMessage message, CancellationToken cancellationToken, Action<ReceiveContext> contextCallback) in /_/src/Transports/MassTransit.Azure.ServiceBus.Core/AzureServiceBusTransport/ServiceBusMessageReceiver.cs:line 49
   at async Task Azure.Messaging.ServiceBus.ServiceBusProcessor.OnProcessM`your text`essageAsync(ProcessMessageEventArgs args)
   at async Task Azure.Messaging.ServiceBus.ReceiverManager.OnMessageHandler(EventArgs args)
   at async Task Azure.Messaging.ServiceBus.ReceiverManager.ProcessOneMessage(ServiceBusReceivedMessage triggerMessage, CancellationToken cancellationToken)

我们的消费看起来像

public sealed class Nhs111ClinicalDocumentConsumer : IConsumer<FhirNhs111InboundMessageRegistration>

FhirNhs111InboundMessageRegistration 是空类,我也尝试创建可以表示与消息相同的数据的类,但它也不起作用

有人可以帮我吗?

我尝试创建具有属性的 FhirNhs111InboundMessageRegistration 类


using Helix.Nhs.Contracts.V1.Commands;
using Microservice.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Helix.Nhs.Contracts.V2
{
    // Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
    public sealed class Action
    {
        public List<Coding> coding { get; set; }
        public string text { get; set; }
    }

    public sealed class Agent
    {
        public string reference { get; set; }
    }

    public sealed class Author
    {
        public string reference { get; set; }
    }

    public sealed class Coding
    {
        public string system { get; set; }
        public string code { get; set; }
        public string display { get; set; }
    }

    public sealed class ConsentingParty
    {
        public string reference { get; set; }
    }

    public sealed class Context
    {
        public string reference { get; set; }
    }

    public sealed class Datum
    {
        public string meaning { get; set; }
        public Reference reference { get; set; }
    }

    public sealed class Destination
    {
        public string endpoint { get; set; }
    }

    public sealed class Encounter
    {
        public string reference { get; set; }
    }

    public sealed class Entry
    {
        public string fullUrl { get; set; }
        public Resource resource { get; set; }
        public string reference { get; set; }
        public Item item { get; set; }
    }

    public sealed class Event
    {
        public string system { get; set; }
        public string code { get; set; }
        public string display { get; set; }
    }

    public sealed class GeneralPractitioner
    {
        public string reference { get; set; }
    }

    public sealed class Identifier
    {
        public Type type { get; set; }
        public string value { get; set; }
    }

    public sealed class Individual
    {
        public string reference { get; set; }
    }

    public sealed class Item
    {
        public string reference { get; set; }
    }

    public sealed class Location
    {
        public Location location { get; set; }
        public string status { get; set; }
        public string reference { get; set; }
    }

    public sealed class ManagingOrganization
    {
        public string reference { get; set; }
    }

    public sealed class Meta
    {
        public DateTime lastUpdated { get; set; }
    }

    public sealed class OccurrencePeriod
    {
        public DateTime start { get; set; }
    }

    public sealed class OnBehalfOf
    {
        public string reference { get; set; }
    }

    public sealed class OrderedBy
    {
        public List<Coding> coding { get; set; }
    }

    public sealed class Participant
    {
        public List<Type> type { get; set; }
        public Individual individual { get; set; }
    }

    public sealed class Patient
    {
        public string reference { get; set; }
    }

    public sealed class Period
    {
        public DateTime start { get; set; }
        public DateTime end { get; set; }
    }

    public sealed class Practitioner
    {
        public string reference { get; set; }
    }

    public sealed class ProvidedBy
    {
        public string reference { get; set; }
    }

    public sealed class Reason
    {
        public List<Coding> coding { get; set; }
    }

    public sealed class ReasonReference
    {
        public string reference { get; set; }
    }

    public sealed class Recipient
    {
        public string reference { get; set; }
    }

    public sealed class Reference
    {
        public string reference { get; set; }
    }

    public sealed class Relationship
    {
        public List<Coding> coding { get; set; }
    }

    public sealed class Requester
    {
        public Agent agent { get; set; }
        public OnBehalfOf onBehalfOf { get; set; }
    }

    public sealed class Resource
    {
        public string resourceType { get; set; }
        public string id { get; set; }
        public Event @event { get; set; }
        public List<Destination> destination { get; set; }
        public DateTime timestamp { get; set; }
        public Source source { get; set; }
        public Reason reason { get; set; }
        public object identifier { get; set; }
        public string status { get; set; }
        public object type { get; set; }
        public Subject subject { get; set; }
        public List<Participant> participant { get; set; }
        public Period period { get; set; }
        public List<Location> location { get; set; }
        public ServiceProvider serviceProvider { get; set; }
        public bool? active { get; set; }
        public object name { get; set; }
        public ManagingOrganization managingOrganization { get; set; }
        public object address { get; set; }
        public List<Telecom> telecom { get; set; }
        public string gender { get; set; }
        public string birthDate { get; set; }
        public List<GeneralPractitioner> generalPractitioner { get; set; }
        public ProvidedBy providedBy { get; set; }
        public string intent { get; set; }
        public string priority { get; set; }
        public Context context { get; set; }
        public OccurrencePeriod occurrencePeriod { get; set; }
        public DateTime? authoredOn { get; set; }
        public Requester requester { get; set; }
        public List<Recipient> recipient { get; set; }
        public List<ReasonReference> reasonReference { get; set; }
        public List<SupportingInfo> supportingInfo { get; set; }
        public bool? doNotPerform { get; set; }
        public object code { get; set; }
        public Encounter encounter { get; set; }
        public DateTime? date { get; set; }
        public List<Author> author { get; set; }
        public string title { get; set; }
        public string confidentiality { get; set; }
        public List<Section> section { get; set; }
        public Patient patient { get; set; }
        public List<ConsentingParty> consentingParty { get; set; }
        public List<Action> action { get; set; }
        public object organization { get; set; }
        public string policyRule { get; set; }
        public List<Datum> data { get; set; }
        public string clinicalStatus { get; set; }
        public string verificationStatus { get; set; }
        public Practitioner practitioner { get; set; }
        public Relationship relationship { get; set; }
        public string model { get; set; }
        public string version { get; set; }
        public string mode { get; set; }
        public OrderedBy orderedBy { get; set; }
        public List<Entry> entry { get; set; }
    }

    public sealed class FhirNhs111InboundMessageRegistration
    {
        public string resourceType { get; set; }
        public Meta meta { get; set; }
        public Identifier identifier { get; set; }
        public string type { get; set; }
        public List<Entry> entry { get; set; }
    }

    public sealed class Section
    {
        public List<Section> section { get; set; }
        public string title { get; set; }
        public List<Entry> entry { get; set; }
        public Text text { get; set; }
    }

    public sealed class ServiceProvider
    {
        public string reference { get; set; }
    }

    public sealed class Source
    {
        public string name { get; set; }
        public string endpoint { get; set; }
        public string reference { get; set; }
    }

    public sealed class Subject
    {
        public string reference { get; set; }
    }

    public sealed class SupportingInfo
    {
        public string reference { get; set; }
    }

    public sealed class Telecom
    {
        public string system { get; set; }
        public string value { get; set; }
        public string use { get; set; }
    }

    public sealed class Text
    {
        public string status { get; set; }
        public string div { get; set; }
    }

    public sealed class Type
    {
        public string text { get; set; }
        public List<Coding> coding { get; set; }
    }


}

我期待着这个,问题可能会得到解决,但它不能。 当我有空课时,我可以手动将消息发布到我的 azure 服务总线队列,并且我能够使用消息。但是,如果我们通过 Nhs 111 测试套件推送消息,则会出错。`

masstransit
© www.soinside.com 2019 - 2024. All rights reserved.