moleculerjs / moleculer-channels

Reliable messages for Moleculer services via external queue/channel/topic.
MIT License
72 stars 15 forks source link

emitlLocalChannelHandler error when channel is defined with options #59

Closed ujwal-setlur closed 1 year ago

ujwal-setlur commented 1 year ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Current Behavior

When emitlLocalChannelHandler is called on a service with a channel that is defined as an options object, such as:

channels: {
"payment.processed": {
            // Using custom consumer-group
            group: "other",
            handler: async (payload) {
                // Do something with the payload
                // You should throw error if you want to NACK the message processing.
            }
        }
}

then the emitlLocalChannelHandler call fails with:

TypeError: svc.schema[mwOpts.schemaProperty][channelName].call is not a function

If the channel is defined as just a function, such as:

    channels: {
        async "order.created"(payload) {
            return payload
        }
    }

then the emitlLocalChannelHandler call works.

Expected Behavior

emitLocalChannelHandler should work when channel is defined as an options object.

Failure Information

TypeError: svc.schema[mwOpts.schemaProperty][channelName].call is not a function

See https://github.com/moleculerjs/moleculer-channels/pull/34#discussion_r1087590328