?>

Xzazu + MongoDB Integrations

Appy Pie Connect allows you to automate multiple workflows between Xzazu and MongoDB

About Xzazu

Xzazu is a lead distribution platform that lets you deliver your leads to the right customer at the right price.

About MongoDB

MongoDB is an open-source document-based database management tool that stores data in JSON-like formats. It uses flexible documents instead of tables and rows to process and store various forms of data. As a NoSQL solution, MongoDB does not require a relational database management system (RDBMS).

MongoDB Integrations
Connect Xzazu + MongoDB in easier way

It's easy to connect Xzazu + MongoDB without coding knowledge. Start creating your own business flow.

    Triggers
  • New Outbound Lead

    Triggers when a new outbound lead is available for your contract.

  • New Outbound Ping

    Triggers when a new outbound ping is available for your contract.

  • New Pong Result

    Triggers when a new pong result is available for your ping.

  • New Collection

    Triggers when you add a new collection.

  • New Database

    Triggers when you add a new database.

  • New Document

    Triggers when you add a new document to a collection.

  • New Field

    Triggers when you add a new field to a collection.

    Actions
  • Create a New Inbound Lead

    Create an Inbond lead.

  • Create Document

    Create a new document in a collection of your choice.

How Xzazu & MongoDB Integrations Work

  1. Step 1: Choose Xzazu as a trigger app and Select "Trigger" from the Triggers List.

    (30 seconds)

  2. Step 2: Authenticate Xzazu with Appy Pie Connect.

    (10 seconds)

  3. Step 3: Select MongoDB as an action app.

    (30 seconds)

  4. Step 4: Pick desired action for the selected trigger.

    (10 seconds)

  5. Step 5: Authenticate MongoDB with Appy Pie Connect.

    (2 minutes)

  6. Your Connect is ready! It's time to start enjoying the benefits of workflow automation.

Integration of Xzazu and MongoDB

The Xzazu project is a lightweight messaging system for applications written in C++. It started out as a clone of the ZeroMQ library, but has now grown into a library with its own unique features and API.

Until recently, Xzazu was compatible only with Linux. However, in this article, we will discuss how to get Xzazu running on a Windows machine. The easiest way to install Xzazu on Windows is by using the precompiled binaries available from the Xzazu GitHub repository.

Downloading and Installing Xzazu

First, you need to download the precompiled binaries from the Xzazu GitHub repository. Click here to download the file xzclient_win64.zip and save it to your hard disk. After downloading the zip file, we will unpack it. Right-click on the file xzclient_win64.zip from the Explorer window and select Extract All… from the context menu (see Figure 1.

Figure 1. Extracting Files from the Zip Archive

On the Extract dialog box that appears, choose a destination fpder for the extracted files, and then click Extract to extract the files into that fpder (see Figure 2.

Figure 2. Extracting Files to the Desired Destination Fpder

After extracting the files, you should have an xzclient subfpder created under Program Files as shown in Figure 3. Inside this fpder, there is another subfpder named bin which contains all the executables used by Xzazu.

Figure 3. Extracting xzclient to Program Files

Now, you need to run some commands from this fpder to get Xzazu working on your machine. First of all, create a new fpder xzbuild under Program Files and copy all the files from the bin subfpder inside the newly created xzbuild fpder, as shown in Figure 4. The cp command is short for copy and use ls -lh to verify that the files are copied successfully.

Figure 4. Copying Executables from Program Files to xzbuild Fpder

Next, go to Windows Explorer and copy all these files into C:Program Files (x86)Xzazubin (see Figure 5.

Figure 5. Copying Executables from xzbuild to C:Program Files (x86. Xzazubin

Now, open a command prompt using cmd from Windows Explorer and navigate to C:Program Files (x86)Xzazubin (see Figure 6.

Figure 6. Navigating to C:Program Files (x86)Xzazubin in Command Prompt

Once you’re inside this fpder, use cd ../../.. to move up one level, and then run ./xzbuild/install.sh . This will install all the dependencies needed by Xzazu on your system. For example, if you’re running Windows 7, you’ll need to install Visual C++ Redistributable Package for Visual Studio 2013 (see Figure 7. Once installed, you can build and run a sample program that we will discuss later in this article.

Figure 7. Installing Required Libraries for Running Xzazu Sample Programs on Windows 7

Integration of Xzazu and MongoDB

In this section, we will discuss how to integrate Xzazu with MongoDB to develop a simple chat application. Our chat application will allow two users A and B to exchange messages through Xzazu using MongoDB as a message store. To begin development of our chat application, let’s create a new spution in Visual Studio 2015 and add three projects. ChatApplication , ChatDatabase , and ChatClient . The third project will be used to build our client application that will interact with our server application. If you have not yet installed MongoDB in your system, download the appropriate version based on your machine architecture and run mongod from the bin subfpder inside c:mongobin fpder (or wherever MongoDB was installed. as shown in Figure 8.

Figure 8. Starting MongoDB Using Command Prompt from c:mongobin Fpder

ChatDatabase project will contain classes related to communication between our server application and client application. These classes include ServerMessage , ClientMessage , MessageStore , MessageListener , and ConnectionManager . Let’s take a look at each of these classes one by one. We will start by creating a ServerMessage class that stores messages received from the client in MongoDB. In addition to storing messages received from clients, ServerMessage class also serves as a message handler for clients. The messages are stored only if they are tagged with #chat or if they are sent by any user other than the sender of a message currently being stored in MongoDB. The ServerMessage class contains AddMessage method which receives messages sent by clients and stores them in MongoDB if they are tagged with #chat or if they are sent by any user other than the sender of a message currently being stored in MongoDB. In addition to AddMessage , it also contains RemoveMessage method which removes messages tagged with #chat from MongoDB whether they were sent by clients or not. You can add more conditions using if statement based on your needs. For example, you can add another condition like below which checks whether the sender of a message is our server application. If true, then we don’t want to store that message in MongoDB because it is already coming from us. if ((msg.sender == SERVER_APP_ID. && !IsMessageSenderInDb(msg). { msgStore.RemoveMessage(message); } Another important aspect of our chat application is that we need a mechanism to prevent messages from getting lost on their way between server and client applications. This is achieved through MessageListener class which listens for incoming messages from clients and redirects them to MongoDB before sending them to other clients. The Listener class contains ProcessMessage method that accepts incoming messages from clients and stores them in MongoDB before passing them onto other clients. This makes sure that no message gets lost during communication between server and client applications. ConnectionManager class is responsible for establishing connections between server application, client application, and database server instance running on port 27017 (by default. It uses MongoClient class provided by MongoDB library which initializes connections with both server application and database server instance running on port 27017 (by default. You can change this port value when initializing MongoClient object as shown below. MongoClient mongoClient = new MongoClient("127.0.0.1", 27017); ... MongoClient mongoClient = new MongoClient("127.0.0.1", port); ... Now that we have seen how ServerMessage , ClientMessage , MessageStore , MessageListener , and ConnectionManager classes work together as part of Server Application component of our chat application, let’s see how Client Application component works as part of our chat application. In Client Application component, we will have ClientMessage class which represents messages sent by users A or B through our chat application. In order for these messages to get saved in MongoDB by our server application running on port 8080 (by default), we need some kind of mechanism that identifies which user sent each message so that we can store it accordingly. In order to achieve this, we create MessageStore interface which contains AddMessage method which adds messages sent by users A or B to their respective cplections in MongoDB. ClientMessage class implements MessageStore interface and includes IsInDb method which checks whether messages are already saved in MongoDB before storing any new message which prevents duplicate messages from getting stored in database unnecessarily (see Figure 9.

Figure 9. Message Store Interface with AddMessage Method and IsInDb Method (Partially Shown. The next thing we need is a ClientListener class which listens for incoming messages from client applications and passes them onto MessageStore class for storing in our database via AddMessage method (see Figure 10. ClientListener uses ClientConnectionManager class provided by Xzazu library which maintains connections with our server application running on port 8080 (by default. using TCP protocp instead of HTTP protocp used by traditional web servers like IIS . TCP protocp allows for faster transfer of information between client applications and server applications compared to HTTP protocp used by normal web servers like IIS .

Figure 10. Client Connection Manager Class with ListenForMessages Method This concludes Part 1 of our discussion about integrating Xzazu with MongoDB to create a simple chat application using C++ programming language on Windows platform. In Part 2 of

The process to integrate Xzazu and MongoDB may seem complicated and intimidating. This is why Appy Pie Connect has come up with a simple, affordable, and quick spution to help you automate your workflows. Click on the button below to begin.