-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
i got a problem when using moleculer-java-web gateway call service in node.js. i have some code in node.js using moleculer-js and i want to integrate with java by moleculer-java with NATs transporter and i got error below in java console when i use curl at command prompt and it hang.
SEVERE: Unexpected error occurred while invoking "test.verify" action!
Error: Verify Error
at new VerifyError (D:\node\projects\mole5\dist\services\VerifyError.js:22:28)
at Service.verify (D:\node\projects\mole5\dist\services\hello.service.js:23:35)
at D:\node\projects\mole5\node_modules\moleculer\src\utils.js:212:22
at ServiceBroker.timeoutMiddleware (D:\node\projects\mole5\node_modules\moleculer\src\middlewares\timeout.js:31:14)
at ServiceBroker.fallbackMiddleware (D:\node\projects\mole5\node_modules\moleculer\src\middlewares\fallback.js:31:11)
at ServiceBroker.errorHandlerMiddleware (D:\node\projects\mole5\node_modules\moleculer\src\middlewares\error-handler.js:14:10)
at Transit.requestHandler (D:\node\projects\mole5\node_modules\moleculer\src\transit.js:505:30)
at Transit.messageHandler (D:\node\projects\mole5\node_modules\moleculer\src\transit.js:360:17)
at NatsTransporter.wrappedMessageHandler [as messageHandler] (D:\node\projects\mole5\node_modules\moleculer\src\transit.js:66:55)
at NatsTransporter.incomingMessage (D:\node\projects\mole5\node_modules\moleculer\src\transporters\base.js:118:16)
SEVERE: Unable to invoke action!
java.util.concurrent.CompletionException: services.moleculer.error.MoleculerError: Verify Error
at java.base/java.util.concurrent.CompletableFuture.encodeRelay(CompletableFuture.java:367)
at java.base/java.util.concurrent.CompletableFuture.completeRelay(CompletableFuture.java:376)
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1074)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
at io.datatree.Promise.complete(Promise.java:580)
at services.moleculer.service.DefaultServiceRegistry.receiveResponse(DefaultServiceRegistry.java:965)
at services.moleculer.transporter.Transporter.processReceivedMessage(Transporter.java:744)
at services.moleculer.transporter.Transporter.processReceivedMessage(Transporter.java:704)
at services.moleculer.transporter.Transporter.lambda$1(Transporter.java:682)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
Caused by: services.moleculer.error.MoleculerError: Verify Error
at services.moleculer.error.MoleculerErrorUtils.create(MoleculerErrorUtils.java:139)
at services.moleculer.service.DefaultServiceRegistry.receiveResponse(DefaultServiceRegistry.java:962)
... 9 more
this is VerifyError class in ts.
export class VerifyError extends Error {
public readonly code: number;
public readonly state? : string;
constructor(message: string, code: number, state?: string) {
super(message);
this.code = code;
this.state = state;
Object.setPrototypeOf(this, VerifyError.prototype);
}
}i found that when i remove add on properties ex. code & state or using Error class directly it fine.
export class VerifyError extends Error {
constructor(message: string) {
super(message);
Object.setPrototypeOf(this, VerifyError.prototype);
}
}for a class above it's work, i got error message from curl command and java console print out error.
i found on, moleculer-java-1.2.27, moleculer-java-web-1.3.11.
For addition, here is hello.service.ts
import { Context, ServiceSchema } from "moleculer";
import { VerifyError } from "./VerifyError";
const helloService : ServiceSchema = {
name: "test",
actions: {
greet() {
return {message: "greeting"};
},
verify() {
//this not work when using java gateway call node
return Promise.reject(new VerifyError("Verify Error",-99,"error"));
},
}
};
export = helloService;Metadata
Metadata
Assignees
Labels
No labels