BLOG

X.Commerce Introduction Part 2: Registering a Capability

Thu, 12/15/2011 - 04:48

In my last post I wrote a brief about X.Commerce concepts and my thought about what is going on with it, in this post I am going to show you how to register capabilities, this post is a simple explanation of how to start the Fabric and register capabilities and authorize Tenants.

As X.Commerce its not yet in production, the only way to try it out is starting the Fabric on your own machine or server, there are two ways to start the fabric: Using the developer pack, and using the Eclipse plug in.

Using the developer Pack

The guys at X.Commerce have made a Developer Package that you can download from here, also there is a "Getting Started Guide", this is pretty straightforward so I'm not going to explain it. By the way, this is longest option.

Using the Eclipse Plug in

This is, for me, a faster way to have the Fabric up and running even if you are not familiar with Eclipse. First of all you have to download Eclipse and MongoDB, After all of these are downloaded, you need to install a few plugins in Eclipse to make the X.Commerce work, just open Eclipse -> Help -> Install new Software -> Search for Eclipse Indigo and download as much as you can, in some point you will need them, but the mandatory ones are the web developer tools, also you need to search for the X.Commerce plug in (http://50.56.49.156/xpe/eclipse/3.7/).

After you downloaded the MongoDB, create a directory "data\db" inside the "bin" folder, now you just need to start the database with this simple command "C:\MongoDB\bin\mongod --dbpath data/db" and that's it... mongo is up and running.

Now open your Eclipse, after installing the X.commerce Plug in you will see the new X.Commerce  button, select the option Start Fabric and there you go... X.Commerce Fabric, up and running Laughing

Lessons Learned: if this doesn't work, it is almost 100% sure that the mongo port is incorrect. Just take a look to Mongo's port and set it correctly in the Fabric Settings.

Creating a Capability

What is a capability? Basically it is a piece of funcionality that can receive (subscribe) and send (publish) messages from and to the Fabric, in a production environment. Integration with an existing application would mean just to subscribe for that application messages and code your logic to handle them. Pretty simple and straightforward isn't it?

So how do we stop other applications to receive messages when they are not authorized? Messages corresponds to topics, and when a topic is created, you can configure them to require a tenant, this will tell the fabric to not send these messages to any unauthorized tenant.

Lets create to topics, "/Inventory/Update" and "/Inventory/Update/Success":

Go to the fabric Manager, in the home page, you can add new topics really fast just type in the name and hit the create button.

Now we need to register a Tenant, this mean we are registering a merchant. Just go to the Tenants Tab and type the name of the Merchant "TestMerchant" and hit the create button:

Now the only thing left is to register our capability:

In the Home page, hit the "Create Capability" link and set the name "TwitterPublisher" and the endpoint, the endpoint is the url where my capability will be listening for messages, in my case it is "http://localhost:22125/", just put your local url there.

In the capability home, there are three tabs: Subscriptions, Authorization Info and Routing Info. Subscriptions is the list of topics you have subscribed to and you can subscribe to more topics there; Authorization Info shows the XFabric Bearer Token, the Capability Bearer Token and Tenants Bearer Tokens, these are necessary to communicate and be authorized by the Fabric.

The Next step, would be to subscribe to the topic "/Inventory/Update", we will leave "/Inventory/Update/Success" for a later post (Integration)

Once we are subscribed to the Inventory/Update topic... then we need to authorize our tenant, lets go to the authorization Info Tab, select our "TestMerchant" from the Tenants drop and it will be automatically added and a Bearer Token will be assigned to it.

And that's it, we have our capability Registered and our tenant authorized, this means that our capabilty will be able to send and receive messages for the "/Inventory/Update" topic and every time one of this messages is published, the Fabric will send it to our EndPoint. The way the capability works and handles incoming messages depends on the technology you decide to use and it is out of the scope of this article.

In the Next article I will explain how to make this work in a real scenario using Magento storefront, Java and .Net capabilities.

Please leave your comments!

Series:

X.Commerce Introduction Part 1: The Fabric

X.Commerce Introduction Part 2: Registering a Capability 

X.Commerce Introduction Part 3: Integrate technologies with X.Commerce

.Net Developer
Senior developer interested in multitier architecture, web based, back-end and core app design and development.