GithubHelp home page GithubHelp logo

sphereio / sphere-message-processing Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 96 KB

This node.js library is designed to provide an easy way to write a SPHERE.IO message processors.

License: MIT License

CoffeeScript 98.01% Shell 0.72% JavaScript 1.27%

sphere-message-processing's People

Contributors

hajoeichler avatar olegilyenko avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

butenkor

sphere-message-processing's Issues

Error during: Locking the message

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()

Message processer method not called in some cases

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.