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

Can not send message for string type #17

Closed
xbfspace opened this issue Jul 25, 2017 · 3 comments

Comments

@xbfspace
Copy link

commented Jul 25, 2017

1、无法发布订阅字符串类型消息

        [Route("~/publish")]
        public IActionResult PublishMessage()
        {
            //_capBus.Publish("sample.kafka.sqlserver", "消息内容"); //不能直接发布string类型的消息 得搞个实体
            _capBus.Publish("sample.kafka.sqlserver", new MyMessage { Title = "your dd" });

            return Ok();
        }
 [NonAction]
        [CapSubscribe("sample.kafka.sqlserver")]
        //订阅消息,消息参数为string无法接收
        public void ReceiveMessage1(string data)
        {
            Console.WriteLine($"receive data{data}");
            Debug.WriteLine($"receive debug data{data}");
        }

2、先注释掉订阅的action,运行程序,然后发布一条消息a。重新启用订阅action,运行程序,消息a无法被消费

3、core 2.0 还无法使用,异常:

An error occurred while starting the application.
MissingMethodException: Method not found: 'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.

DotNetCore.CAP.MySqlCapOptionsExtension.TempBuildService(IServiceCollection services)

    MissingMethodException: Method not found: 'System.IServiceProvider Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(Microsoft.Extensions.DependencyInjection.IServiceCollection)'.
        DotNetCore.CAP.MySqlCapOptionsExtension.TempBuildService(IServiceCollection services)
        DotNetCore.CAP.MySqlCapOptionsExtension.AddServices(IServiceCollection services)
        Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.AddCap(IServiceCollection services, Action<CapOptions> setupAction)
        Core2Website.Startup.ConfigureServices(IServiceCollection services) in Startup.cs

                services.AddCap(c =>

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Jul 26, 2017

Thanks for your feedback. I'll check it. CAP unsupported .NET Core 2.0 now. Can you provide your
environment? Mysql or sql server? RabbitMQ or Kafka?

@xbfspace

This comment has been minimized.

Copy link
Author

commented Jul 26, 2017

.net core 1.1 , mysql , rabbitmq.
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext();

        services.AddCap(x =>
        {
            x.UseEntityFramework<AppDbContext>();
            // x.UseKafka("localhost:9092");
            x.UseRabbitMQ(options =>
            {
                options.HostName = "localhost";
                options.Port = 9203;
                options.UserName = "guest";
                options.Password = "guest";
                options.VirtualHost = "/";
               
            });
        });

        services.AddMvc();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        loggerFactory.AddConsole();
        loggerFactory.AddDebug();

        app.UseMvc();

        app.UseCap();
    }

public class AppDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseMySql("server=localhost;userid=root;pwd=123456;port=3306;database=Sample;sslmode=none;");
}
}
@yuleyule66

yang-xiaodong added a commit that referenced this issue Jul 26, 2017
@yang-xiaodong

This comment has been minimized.

Copy link
Member

commented Aug 4, 2017

Fixed at v1.1.0

@yang-xiaodong yang-xiaodong changed the title 无法发布、订阅字符串类型消息 Can not send message for string type Feb 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.