Command bus not working after first call in gRPC-Go

I’m working on my first project in Go Lang and facing an issue that I still cannot solve. The application is in hexagonal architecture using gRPC. When a specific method is called in gRPC, it works properly on the first usage but no longer works in the next requests. If I make 5 requests, none of them reach the handler, only the first one.

In the gRPC port the code is defined this way – take note that all variables are set and the first call works properly.

// defining the command to send to the command bus
protoMessage := productv1.CreateProductCommand{
    Id:            productID,
    ProductInfoId: in.Product.ProductInfoId,
    Product:       in.Product,
}

// creating properly the message and validating the possible errors
msg, err := messageManager.CreateMessage(ctx, &protoMessage)
if err != nil {
    logger.WithContext(ctx).Error(fmt.Sprintf("CreateProduct: error create message %v", err))
    return nil, err
}

// and finally, sending the message for the command bus
err = s.commandBus.Send(ctx, finalMessage)
if err != nil {
    logger.WithContext(ctx).Error(fmt.Sprintf("CreateProduct: error send message %v", err))
    return nil, err
}

The handler is a command that when the command bus processes it, executes its job. Again: on the first call, it works.

func (h CreateProductHandler) Handle(ctx context.Context, c interface{}) error {
    logger.WithContext(ctx).Info(fmt.Sprintf("%s invoked with command = %v", h.HandlerName(), c))

    eventId := uuid.NewString()
    errs := make([]*statuspb.Status, 0)

    if h.eventBus == nil || h.productRepo == nil || h.productInfoRepo == nil {
        err := errors.New("CreateProductHandler not properly initialized. Use NewCreateProductHandler")
        return err
    }
    cmd := c.(*productv1.CreateProductCommand)

    // after this cmd variable, comes the logic for product register, that is working as expected.    

The return clauses are in case of an error where the error itself is returned or nil. Maybe this return nil is a problem???

Even though I said that the handler is reaching only on the first call and it appears to be correct, here is how this command handler is registered.

productv1, err := product.NewApplicationFromSettings(settings)
if err != nil {
    return nil, err
}


cqrsFacade, err := cqrs.NewFacade(newFacadeConfig(
    settings,
    redisstream.JSONMarshaler{},
    *publisher,
    *subscriber,
    watermillLogger,
    router,
    func(commandBus *cqrs.CommandBus, eventBus *cqrs.EventBus) []cqrs.CommandHandler {
        commandHandlers := []cqrs.CommandHandler{}

        // previous command handlers...
        commandHandlers = append(commandHandlers, productv1.CommandHandlers(commandBus, eventBus)...)
        // other command handlers....
        return commandHandlers
    },

So, here is the problem: all variables as set, all commands are working perfectly, only this productv1 is working at the first call, and not to the following. It seems like something is stuck, I don’t know.

If I re-run the application, all “stuck” commands are performed one after another, until the queue is cleared.

Ps: this issue only occurs by running in the server (even the server and local machine both running docker). In my local machine, this error doesn’t exist.

I have been stuck on this for over 3 days and I have no more ideas.

Called gRPC method several times.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật