using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.Composition;
using xxx.Core.Interface;
using xxx.Core.Entity;
using xxx.Core;
using xxx.Core.Client;
namespace xxx.Business
{
[Export(typeof(IMappingNotify))]
public class EventHubMappingNotify : IMappingNotify
{
private EventHubClientMapping _eventHubClient = new EventHubClientMapping();
public void Notify(string cookie)
{
_eventHubClient.AddMessage(cookie);
}
}
}
View Code 在azure core中config.cs文件中加入config信息:
//EventHub链接
public static string MappingDataFlowEventHubConnection
{
get
{
var config = CloudConfigurationManager.GetSetting("MappingDataFlowEventHubConnection");
if (string.IsNullOrEmpty(config))
throw new Exception("MappingDataFlowEventHubConnection hasn't configured!");
return config;
}
}
EventHub链接
//EventHub存储配置
public static string MappingDataFlowEventHubName
{
get
{
var config = CloudConfigurationManager.GetSetting("MappingDataFlowEventHubName");
if (string.IsNullOrEmpty(config))
{
return "mapping-response-eventhub";
}
return config;
}
}
EventHub存储配置
//EventHub消费者组
public static string MappingDataFlowEventHubConsumer
{
get
{
var config = CloudConfigurationManager.GetSetting("MappingDataFlowEventHubConsumer");
if (string.IsNullOrEmpty(config))
throw new Exception("MappingDataFlowEventHubConsumer hasn't configured!");
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
using xxx.Core.Entity;
using xxx.Core;
using xxx.Core.Interface;
namespace xxx.Core.Client
{
public class EventHubClientMapping
{
private Microsoft.ServiceBus.Messaging.EventHubClient _eventHubClient;
public EventHubClientMapping()
{
var factory = MessagingFactory.CreateFromConnectionString(DANDaasConfig.MappingDataFlowEventHubConnection);
_eventHubClient = factory.CreateEventHubClient(DANDaasConfig.MappingDataFlowEventHubName);