sphereio / sphere-message-processing Goto Github PK
View Code? Open in Web Editor NEWThis node.js library is designed to provide an easy way to write a SPHERE.IO message processors.
License: MIT License
This node.js library is designed to provide an easy way to write a SPHERE.IO message processors.
License: MIT License
I get this error when listening for messages
2015-08-18 13:39:13.228 [ERROR] - processing.processor.notify-delivery-added - Error during: Locking the message. Message: <very long message data>
Cause: Error: getaddrinfo ENOTFOUND api.sphere.io
at errnoException (dns.js:44:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
My message processing code:
var {MessageProcessing, LoggerFactory} = require("sphere-message-processing")
var Q = require("q")
var request = require("request")
var crypto = require("crypto")
var querystring = require("querystring")
function processMessage(sourceInfo, msg) {
console.log(msg.type)
if (msg.type === "ParcelAddedToDelivery") {
console.log(sourceInfo)
console.log(msg)
var hash = crypto.createHash("sha512")
hash.update(querystring.stringify(msg))
var d = Q.defer()
request.post(argv.baseUrl+"/messages/parcel-added-to-delivery", {
form: {
message: msg,
hash: hash.digest("hex")
}
}, (err, httpResponse, body) => {
console.log("POST result:", err, body)
if (err) {
return d.reject(new Error("Failed making POST"))
} else {
return d.resolve({processed: true, processingResult: {notifiedShippingEmails: true}})
}
})
return d.promise
} else {
return Q({processed: true, processingResult: {ignored: true}})
}
}
var builder = MessageProcessing.builder()
.processorName("notify-delivery-added")
.optimistDemand("baseUrl")
.optimistExtras((o) => {
o.describe("baseUrl", "Base URL of the shop environment, e.g. https://pure.testserver2.at/de")
})
.messageType("order")
.build((argv, stats, requestQueue, cc, rootLogger) => {
var logger = LoggerFactory.getLogger("notify-delivery-added", rootLogger)
return processMessage
})
var messageProcessor = builder()
messageProcessor.start()
i'm listening for message "ParcelAddedToDelivery". Sometimes the processor method is triggered when i create a parcel in the merchantcenter. But then it suddenly stops working and the processer is not called anymore no matter how much parcel i add. any idea how to track this error down? This cloud also be a problem in the backend or so...sometimes it starts working again when i create a parcel for a different (new) order.
Thx!
Oleg has very important start / stop / management scripts here:
https://github.com/OlegIlyenko/sphere-message-processor-management
I would love to see the relevant functionalities merged into this actual project. (not necessarily code-level), e.g. one approach could be that if the processor is started and detects that it's already running on the port it changes into a status control commandline.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.