Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

丁松杰 / Pole

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • Pole
  • src
  • Pole.EventBus.Rabbitmq
  • Producer
  • RabbitProducer.cs
Find file
BlameHistoryPermalink
  • 丁松杰's avatar
    完成 consumer 消费时 调用 orleans grain , grain 的id 由 eventid 决定,每一个类型的 event 每毫秒支持生成… · 988776d9
    完成 consumer 消费时 调用 orleans grain , grain 的id 由 eventid 决定,每一个类型的 event 每毫秒支持生成 64个 event ,并且在 k8s集群里 全局唯一
    丁松杰 committed 5 years ago
    988776d9
RabbitProducer.cs 747 Bytes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
using Pole.Core;
using Pole.Core.EventBus;
using System.Threading.Tasks;

namespace Pole.EventBus.RabbitMQ
{
    public class RabbitProducer : IProducer
    {
        readonly RabbitEventBus publisher;
        readonly IRabbitMQClient rabbitMQClient;
        public RabbitProducer(
            IRabbitMQClient rabbitMQClient,
            RabbitEventBus publisher)
        {
            this.publisher = publisher;
            this.rabbitMQClient = rabbitMQClient;
        }
        public ValueTask Publish(byte[] bytes)
        {
            using var channel = rabbitMQClient.PullChannel();
            channel.Publish(bytes, publisher.Exchange, string.Empty, publisher.Persistent);
            return Consts.ValueTaskDone;
        }
    }
}