-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Labels
bugSomething isn't workingSomething isn't workingneeds reproducible exampleNeeds reproducible repositoryNeeds reproducible repositoryscope: messagingRelates to @marblejs/messaging packageRelates to @marblejs/messaging package
Description
Describe the bug
Following the Marble docs for creating an amqp publisher I receive the following error on app start-up
(node:90349) UnhandledPromiseRejectionWarning: TypeError: rabbitMqClient.send is not a function
because the resolved rabbitMQ client is still a Promise even though it was eagerly bounded to the context
To Reproduce
Amqp publisher
export const AmqpClientToken = createContextToken<MessagingClient>('MessagingClient');
export const amqpClient = messagingClient({
transport: Transport.AMQP,
options: {
host: 'amqp://localhost:5672',
queue: 'hello_queue'
},
});
Http effect
export const getRoot$ = r.pipe(
r.matchPath('/'),
r.matchType('GET'),
r.useEffect((req$, ctx) => {
const rabbitMqClient = useContext(AmqpClientToken)(ctx.ask);
return req$.pipe(
mergeMapTo(rabbitMqClient.send({ type: 'HELLO', payload: 'John' })),
mapTo({ status: HttpStatus.ACCEPTED }),
);
}),
);
App
const httpServerListener = httpListener({
middlewares: [
logger$({ silent: isTestEnv() }),
bodyParser$(),
],
effects: [
getRoot$
],
});
export const server = createServer({
port: getPortEnv(),
listener: httpServerListener,
dependencies: [
bindEagerlyTo(AmqpClientToken)(amqpClient),
],
});
export const main: IO.IO<void> = async () =>
await (await server)();
Expected behavior
App starts up.
Desktop (please complete the following information):
- OS: Ubuntu
- Package + Version: Marble ^3.4.9
- Node version: 14.15.4
Additional context
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds reproducible exampleNeeds reproducible repositoryNeeds reproducible repositoryscope: messagingRelates to @marblejs/messaging packageRelates to @marblejs/messaging package