Author Archives: Nathan Horter

Using Amazon SQS as a Messaging Bus

In a previous blog post I wrote about how we use a Message Queue server in a Message Bus design. Since that post was written we’ve moved from ActiveMQ to RabbitMQ and now we are moving to Amazon Web Service Simple Queue Service (SQS). I’m going to cover:

  • What is SQS?
  • The Message Bus design Pattern
  • How we’re using SQS to integrate with outside systems.
  • Bonus: I’ll also include how we’re looking at using SNS for notifications.

Intro to AWS SQS

Amazon Web Services are a suite of hosted services run by Amazon that are available on a pay per use basis. SQS (short for Simple Queue Service) is their messaging queue service. SQS operates much like other Queue servers, you can:

  • Create queues
  • Place messages on queues
  • Read messages off of queues.

One important difference with SQS is that there is no guarantee about the order that messages are delivered in. In most other stand alone queue servers messages are delivered in a First-In, First-Out (FIFO) manner. The primary reason that messages can be delivered out of order with SQS is a feature called message visibility. When a message is read from SQS it is no longer visible on the queue. This prevents multiple clients from getting the same message to process. But unlike some other queues, reading a message from the queue does not remove it. A client must explicitly acknowledge a message for it to be removed from the queue. If a client reads a message, but doesn’t acknowledge it, the message will become visible again a short time later. While the message is not visible other messages can be processed, and thus completed before the message becomes visible again.

What is a Message Bus

A Message Bus is a software design pattern that allows for message senders and receivers to be decoupled. This means that message senders and receivers can be added and removed without effecting other senders and receivers attached to the bus.

While we started with a message bus in our design for using SQS as a queue, we are not currently taking full advantage of the Message Bus design pattern as we use one sender class and one process for reading and distributing messages to the correct subscribers.

How we are using SQS

Now that we’ve covered SQS and the basic concept of a messaging bus, lets look at how we put it all together at MerchantOS.

Generating Messages

We have many different message types that are generated and placed on our queue (Item, Customer, Integration Specific messages, etc). Since we are generating all of these messages within our own application we have simplified our message generation code to one class that is used across our system. Using one central message producer allows us to reduce the overall architectural complexity of generating messages and placing them on the queue. This also allows use to integrate other message generators in the future as we need or want them.

Receiving Messages

On the receiving side we have used a few techniques to improve the reliability of receiving and dispatching of messages

Using a CRON to receive messages

To receive messages we use one CRON process that wakes up and forks child processes. These child processes are each responsible for taking one message off of the queue and forwarding it onto its appropriate destination. We have previously used separate processes for each endpoint that needed a message. The downside to this technique was again complexity of monitoring each process and diagnosing when issues arose.

Reducing Coupling

While using one parent process that creates worker processes has potential pitfalls as a point of failure, we have mitigated those by reducing the coupling of the worker processes to the endpoints that they call. One technique we used was to have the workers call the endpoint (typically an RPC endpoint on our API), post it’s message payload and disconnect without waiting for a response. Each endpoint becomes responsible for logging its success or failure. By keeping the workers short lived we reduce the overall impact of one worker failing.

Routing Messages

Another way that our queue usage has evolved is by consolidating all messages into one queue. Previously we used per account queues, which allowed for segregating accounts that might be generating many queue messages from those that only generate a few. In the long run we found that it failed to give us any practical benefit.

We now use a two queue system where all messages are first placed on a “priority queue”. These messages are read off and dealt with by the worker processes described above. If one account is generating many messages, or if we have determined that the endpoint they are calling is saturated and cannot process any more messages, they are re-routed to a delayed queue. Messages on the delayed queue are read once the message volume has reduced or the endpoint is ready to receive messages again.

This arrangement of a limited number of message producers, sending to a limited number of queues, being read by a limited number of consumers, has helped to reduce our queue complexity, improve the transparency of the message flow through the system, and given us better monitoring of our queue status.

Integrating SNS

Our next steps with SQS and our queue development is to create the ability to generate webhook callbacks that can be notified about messages on the queue. We are currently evaluating Amazon SNS among other options to provide a way to generate notifications. With a general notification framework in place it will allow for more complete workflows that include MerchantOS as one component, including potentially being able to create websockets for a richer client interface.

Wrap-up

Our queueing infrastructure has evolved over time to help us create decoupled integrations while reducing our application complexity. Amazon SQS is an integral piece in our ability to reduce our application complexity while also allowing us to scale as our user base grows and our messages per user increases. We’ve got some exciting changes coming to our queuing infrastructure that will allow for richer interactions with API clients. Watch our blog for more posts as we release these changes.

New Integrated Catalogs

We’re pleased to announce that we have added new vendor catalog integrations for Action Bicycle and Raleigh. These integrations ensure that the catalog information we have available in our system will be up to date and provides availability information for products from these vendors.

We have also added the new J&B distribution center in North Carolina to our availability information.

Feel free to send us your feedback about our vendor integrations to support@merchantos.com. If you have a vendor in mind you’d like to see integrated, please get in contact with them and see if they are willing to integrate with us. We are always looking for new vendors to integrate with and at improving our existing integrations.

Giant Bicycles Real-Time Stock Check

Things have been busy around MerchantOS lately and we’re proud to announce a new feature for our integration with Giant Bicycles. We have added real-time stock checking to purchase orders with Giant when you use our integration with them. Previously we updated stock information once daily. By the time you created your Purchase Order in MerchantOS the stock levels could have been hours out of date.

Real-time stock checking will allow you to see the actual stock availability for the products you are ordering as you are creating your order. This allows you to know if a product would be back ordered or if there are more available for you to purchase for your shop. You can find information about setting up the Giant integration in the MerchantOS Manual.

We are also working on several updates to existing integrations and a few new vendor integrations in several different industries. Check back on our blog for updates as we release them.

MerchantOS API Changes

It’s been one year since we first introduced our API. It’s taken a lot of work to get where we are and it will take even more to get where we want to go with our API. We’ve seen ever increasing use of our API for external integrations like Perkville and internal projects like adding new inventory and generating packing lists. We wouldn’t have been able to make many of the improvements listed below without the valuable feedback of our API users. Thank you for your feedback and suggestions.

We are proud to annouce some changes and improvements to our API that are coming in our next release. Here is a quick overview of what is coming.

API Errors Returned in the Requested Format

Now when the API encounters an error instead of returning an html error page it will return error information in the format that was selected in the request (XML or JSON). This should allow for better error handling by client applications.

Fixes to API Datetimes

There was a bug that was causing some datetimes in the API to be returned incorrectly. Datetimes are now returned as GMT corrected for the timezone set in account.

Add Category and Tags to Receipt Template Items

We had a request to load the Item Category and Tags on the XML returned in the receipt template. This change will give access to those values to people using custom receipt templates.

Load Customer and Employee on Workorders

Another request we had was to load Customer and Employee information on returned Workorder objects. This gives access to the Customer name and address and Employee details for a Workorder without having to make more requests.

Sale Write Access

The biggest change that we have made is open up write access to Sales via the API. This is an important step forward for our API as it exposes more of the functionality of our application via our API. There are some important caveats to the functionality that we have exposed:

  • Refunds and Returns are not yet supported
  • Sales can be Archived (using the Delete method) or Completed, but they cannot be Unarchived or Uncompleted
  • We have made every effort to fully test Sale write access via the API, but proceed with caution. If you find an error or discrepancy please contact us and let us know so we can correct it.

We still have plenty of work to do to improve our point of sale software API, including improving performance and exposing write access to more objects. We’re excited about these changes as they allow us to make big improvements to our product in the future.

If you have an API question, comment, suggestion or issue feel free to contact Nate at nate@merchantos.com.

Exporting UPC’s to Shopify

Using the Shopify integration, MerchantOS can keep your product descriptions, cost, and inventory in sync between the physical inventory in your store and your E-commerce storefront. We’ve had several requests from our customers to send more information, like the product’s UPC, over to Shopify.

With our latest release we are now sending product UPCs, EANs, manufacturer product numbers, and custom SKUs to Shopify in what are known as Metafields. Metafields are a special object on Shopify that allow us to store information that otherwise isn’t supported in the Shopify API. Metafields are not visible in the Shopify interface, but they can be accessed using the Liquid templating language.

Metafields have a namespace and are attached to specific resources in Shopify. We are using the “merchantos” namespace to send our Metafield information and are attaching it to variants.

So to display the UPC information for all of a product’s variants in your Liquid template you could use code similar to:

 {% for variant in product.variants %} {{variant.metafields.merchantos.upc}} {% endfor %} 

You must save a product in MerchantOS for the new Metafields data to be exported.

We are always looking for ways to improve our integrations, and appreciate your feedback. We are working on more improvements to our Shopify integration and will be posting more information when it becomes available.

If you have any questions feel free to contact us.

API Updates

We’ve been getting lots of great feed back about our API. There are several projects that have been using it and we’ve been working with them to answer their questions and solve some problems that they have been running into.

In our latest release we’ve made a few adjustments to how the API works. None of these changes should break compatibility.

Reduced API Rate Limit Penalty

We had a penalty included in our API for when an application went over their call limit. We had found that this penalty was too harsh and we’ve reworked it to allow applications using our API to hit the call limit occasionally without penalizing them.

Return 503 When Over Rate Limit

Previously we had been returning a 500 error when an application went over it’s call limit. We’ve changed that to a 503 Service Unavailable error as that better reflects the error.

JSON input and output

We’ve also been working on adding JSON input and output for requests. Previously we could output JSON, but now we can accept JSON for requests that require a request body.

Disabled WWW-Authenticate header for AJAX Requests

If you are sending an AJAX request we will no longer be sending the WWW-Authenticate header as this causes UI issues with browsers. All other clients will still receive the WWW-Authenticate header when their request could not be authenticated.

Setting a Default Limit on Listing Requests

Previously we did not page results by default. This was causing issues with very large result sets. Now listing requests (such as requesting all items) will by default return 100 objects per request. This behavior can be over-ridden using the limit and offset query parameters (see the API search manual page: https://manual.merchantos.com/index.php/API_Searching). We are also returning the total count of objects, the current offset and limit for a request as attributes on the outer object tag when we automatically limit a request.

Tagging

We have added the ability to write tags through our API. Objects supporting tags (currently only Items) will have a Tags element containing the tags on the object if there are any. The count of the tags will be returned as an attribute of the Tags element.

Tags can be added to an Object by adding xml similar to below:

<Tags>
    <Tag>
        <name>foobar</name>
    </Tag>
</Tags>

The tag does not have to already exist in the account you are accessing, it will be generated when your object is submitted.

All Tags can be accesses through the new Account/<AccountNumber>/Tag endpoint. This will show you how many tags there are as well as what objects are associated with that tag.

Bug fix to IN queries

We fixed a bug that was preventing queries with the IN search operator from executing properly. Queries like the following should now execute:
https://api.merchantos.com/Account/<AccountNumber>/Item?itemID=IN,[2,4,6,8]

More Improvements to Come!

We’re open to your feed back. If you have any questions about the changes we’re introducing please feel free to contact us. If you are having a problem with our API let us know and we will work with you to resolve it. Thanks again to all of the developers using our API for their valuable feedback. We’re working on even more improvements and we will post again when they are released.

Specialized Purchase Order Upload

A few months ago in our update about vendor integrations I talked about what kind of integrations we have with vendors and the current status of those integrations.

Today I’m proud to announce that we have completed our purchase order upload integration with Specialized Bicycles. This integration will allow MerchantOS users to submit their orders directly to Specialized for fulfillment from within our system.

After your Specialized purchase order is created in MerchantOS it is as simple as selecting the location you would like shipped to and the shipping method and your order is sent to Specialized by our servers. We have more information about setting up the Specialized integration in our manual.

We’ve heard from several vendors since our vendor update and are working with them to integrate them into MerchantOS. If you are a MerchantOS user and have a vendor you would like to see integrate, or are a vendor who would like to integrate you can contact Nate at nate@merchantos.com or 866-554-2453 x95.

Updates from Vendor Integration Land

One of the more unique and powerful features of MerchantOS are Vendor Integrations. They allow MerchantOS to receive product data from vendors that make up our Product Catalogs. They also provide our retailers with streamlined tools for placing orders and receiving invoice information. Here is a quick overview of the types of Vendor Integrations that we support:

  • Catalog: A Catalog integration allows us to get updates to a Vendor’s catalog on a nightly basis, keeping that information fresh in our system for retailers to use for placing orders and selling products.Note: We also support importing catalog files for non-integrated vendors. We have hundreds of catalogs for vendors who are not integrated. If you have a catalog you would like to see in MerchantOS email it to catalogs@merchantos.com
  • Stock Level: Stock Level integration usually goes hand in hand with our Catalog integrations. They provide product availability to retailers when creating purchase orders allowing them to avoid back orders.
  • Purchase Order: Purchase Order integration allows us to format and transmit purchase orders on a retailers behalf to a vendor. Because we have exact catalog information and the exact purchase order information from the retailer this reduces ordering errors and speeds up purchase order creation and acceptance.
  • Invoice: Invoice integration compliments Purchase Order integration. Once a Purchase Order has been fulfilled by a vendor, the Invoice for the order may differ from the Purchase Order (products may be out of stock, costs may have changed, etc). Invoice integration allows retailers to link their Invoices to Purchase Orders in MerchantOS ensuring that they have the correct quanity and cost information reducing receiving errors.
  • Labelling: Some vendors have the ability to pre-print or pre-label products before sending them to retailers. Labelling integration allows the retailer to send the information they want on the label quickly from within MerchantOS. This information can include descriptions and prices, as well as barcode information. Labelling integration ensures that a retailer can start selling products as soon as they are received.
  • Sell Through: Sell Through Integration allows a retailer to report product sales information back to a vendor. This information is useful for a vendor to manage supply chain ordering as well as tracking how quickly different products are selling. MerchantOS provides retailers with the option to provide this data to vendors who support it. The type of information requested by each vendor is unique, but is usually confined to product information and stock quantity or sale dates. If you have questions about Sell Through data please contact MerchantOS support.

MerchantOS supports all of these types of Vendor Integrations, however not all vendors have the ability for us to implement every integration. Many vendors start with a Catalog integration, since other integrations rely on it and it can be finished quickly, before adding other functionality. Here is a list of vendors that have at least one integration with MerchantOS and any news on new integrations that we are working on with them.

Current Integrations

Bicycle Technologies International

Vendor Catalog Sync P.O. Upload Invoice Download Stock Levels Multiple Locations Labelling Sell Through
Bicycle Technologies International ? x x ? n/a x x

We currently have Catalog and Stock Level integration with BTI. We are in discussion with them to implement full Purchase Order Integration. For now retailers can use the Email Purchase Order feature in MerchantOS to send their orders to BTI. Enter orders@bti-usa.com into the Email 1 field in your Bicycle Technology International vendor record. Now when you create a Purchase Order you can click the Email tab on the left side of the screen and the correct email address will be entered for you to send your order to BTI.

DownEast Bicycles

Vendor Catalog Sync P.O. Upload Invoice Download Stock Levels Multiple Locations Labelling Sell Through
Downeast ? x x ? n/a x x

We currently have Catalog and Stock Level integration with DownEast. We are actively working on a Purchase Order integration that will allow for retailers to send their orders directly.

Giant Bicycles

Vendor Catalog Sync P.O. Upload Invoice Download Stock Levels Multiple Locations Labelling Sell Through
Giant ? ? x ? ? x ?

We currently have Catalog, Stock Level, Purchase Order and Sell Through integration with Giant. We’ve been in discussion with Giant about implementing Labelling integration, however we are very early in discussions and do not have any timeline for if or when that integration may be completed.

If you are a Giant Dealer, Giant is requesting that you turn on Sell Through data sharing. This can be done in your Giant vendor record in MerchantOS. If you have questions about what information we would be sending to Giant, or need assistance turning on Sell Through data sharing please contact MerchantOS. If you have questions about how Giant will be using that information please contact your Giant Sales Representative.

Hans Johnsen

Vendor Catalog Sync P.O. Upload Invoice Download Stock Levels Multiple Locations Labelling Sell Through
Hans Johnsen ? x x ? n/a x x

We currently have Catalog and Stock Level integration with Han Johnsen.

Hawley

Vendor Catalog Sync P.O. Upload Invoice Download Stock Levels Multiple Locations Labelling Sell Through
Hawley ? ? x ?* n/a x x

We currently have Catalog, Stock Level and Purchase Order integration with Hawley. Stock Level checking with Hawley is done in real-time. We are currently working with them to implement Invoice Download.

J&B Importers

Vendor Catalog Sync P.O. Upload Invoice Download Stock Levels Multiple Locations Labelling Sell Through
J&B Importers ? ? x ? ? x x

We currently have Catalog, Stock Level and Purchase Order integration with J&B. Our Purchase Order integration with J&B is relatively new, so if you order from J&B check it out.

Quality Bicycle Products

Vendor Catalog Sync P.O. Upload Invoice Download Stock Levels Multiple Locations Labelling Sell Through
QBP ? ? ? ?* ? ? x

We currently have Catalog, Stock Level, Purchase Order, Invoice and Labelling integration with QBP. If you order from the QBP Utah distribution center you can now select that in the QBP vendor record to see Stock Level information from there. Stock Level information from QBP is checked in real-time.

Seatle Bike Supply

Vendor Catalog Sync P.O. Upload Invoice Download Stock Levels Multiple Locations Labelling Sell Through
Seattle Bike Supply ? x x ? ? x x

We currently have Catalog and Stock Level integration with Seattle Bike Supply. We are in the early planning stages for Purchase Order integration.

Specialized

Vendor Catalog Sync P.O. Upload Invoice Download Stock Levels Multiple Locations Labelling Sell Through
Specialized ? x ? ? ? x ?

We currently have Catalog, Stock Level, Invoice and Sell Through integration with Specialized. We are currently actively working on Purchase Order integration with Specialized.

Upcoming Vendor Integrations

We are in active discussions with the following vendors to get them integrated. The specifics about what kind of integrations we are pursuing and when they will be available to MerchantOS users are in constant flux. But we are working to provide as complete an integration with each vendor as possible as quickly as possible.

Why So Many Bikes?

You may have noticed that all of our integrated vendors are in the bicycle industry. While this is an important industry for us, we are not limited to just bikes! We will integrate with a vendor in any industry who has the ability to integrate. We’ve been in contact with vendors in the Pet industry and Hobby industry about the possibility of integrating. When those talks have progressed to where we have something to announce we will let you know.

Want to Integrate?

If you are a product vendor who thinks they and retailers who order from them could benefit from an integration with MerchantOS, please contact us! You can contact Nate at 866-554-2453 x95 or nate@merchantos.com to get started. He can answer your questions about how to get started integrating.

Want a Vendor To Integrate?

If you are a retailer who would like to see your favorite vendor integrate with MerchantOS we would recommend that you contact the vendor directly and ask them to integrate. We’ve found that this is much more successful than us contacting vendors. As a retailer you already have a relationship with a vendor and you can argue more effectively for why integrating with MerchantOS would save you time and money. If a vendor is interested have them contact us and we will work with them to get the integration started.

See a complete list of our vendor catalogs.