Issues with ActiveMQ 3.8.3 (CPP) priorityBackup not working - c++

I am a little new to active MQ so please bear with me.
I am trying to take advantage of the ActiveMQ priority backup feature for some of my Java and CPP applications. I have two brokers on two different servers (local and remote), and I want the following behavior for my apps.
Always connect to local broker on startup
If local broker goes down, connect to remote
While connected to remote, if local comes back up, we then reconnect to local.
I have had success with testing it on the java apps by simply adding priorityBackup to my uri options
i.e.
failover:(tcp://local:61616,tcp://remote:61616)?randomize=false&priorityBackup=true
However stuff isn't going as smoothly on the CPP side.
The following works fine on the CPP apps (with basic working failover functionality - aka jumping to remote when local goes down )
failover:(tcp://local:61616,tcp://remote:61616)?randomize=false
But updating the uri options with priorityBackup seems to break failover functionality completely (my apps never failover to the remote broker, they just stay in some kind of broker-less/limbo state when their local broker goes down)
failover:(tcp://local:61616,tcp://remote:61616)?randomize=false&priorityBackup=true
Is there anything I am missing here? Extra uri options that I should have included?
UPDATE: Transport connector info
<transportConnectors>
<transportConnector name="ClientOpenwire" uri="tcp://0.0.0.0:61616?wireFormat.maxInactivityDuration=7000"/>
<transportConnector name="Broker2BrokerOpenwire" uri="tcp://0.0.0.0:62627?wireFormat.maxInactivityDuration=5000"/>
<transportConnector name="stompConnector" uri="stomp://0.0.0.0:62623"/>
</transportConnectors>

backup and priorityBackup parameters are handled in completely different way in Java and C++ implementation of the library.
Java implementation works well but unfortunately C++ implementation is broken. There are no extra options that can fix this issue. Serious changes in library are required to resolve this issue.
I was testing this issue using activemq-cpp-library-3.8.3, and brokers in various versions (5.10.0, 5.11.1). Issue is not fixed in 3.8.4 release.

Related

What is required to get a BSD-sockets-based program to do LAN networking under Emscripten?

Background: I've got an C++/Qt-based application that communicates with servers on the user's LAN. It uses non-blocking TCP and UDP sockets, and the networking is implemented via calls to the BSD sockets API (i.e. socket()/send()/recv()/select()/etc). It all works well.
The other day, just for fun, I decided to recompile the application using emscripten, so that it could run as a WebAssembly app inside a web browser.
This worked surprisingly well -- within an hour or two, I had my app up and running inside Google Chrome. However, the app's usefulness in this configuration is severely limited by the fact that it isn't able to connect to any servers -- presumably this is because it is running in a restricted/sandboxed environment.
If I wanted to pursue this line of development beyond the clever-hack-demo stage and try to make it useful, I would need to find a way for my program to discover and connect to servers on the user's LAN.
My question is: is that functionality at all possible for a Emscripten/WebAssembly-based app to perform? If so, what steps would I need to take? (i.e. would it require upgrading the LAN's servers to handle WebSocket-based connections? Would it require adding some sort of proxy server to run on the web server that the web page was served from? Is UDP even a thing in a web-app context? Are there other hoops that would also have to be jumped through?)

Is there an HTTP server for Chapel?

A little background: I would like to build my API in Chapel as a docker container on Azure (or AppEngine) using a Crate.io database and ODBC drivers.
Is there an HTTP server I can use with Chapel?
Currently, there is no official HTTP server support in Chapel, but the Chapel
team does plan to work on this in the future.
The project "Write a web server in Chapel" is listed as a suggested
project idea on Chapel's Google Summer of Code (GSoC) page. For GSoC 2016, Chapel had several applicants for this specific project, one of
which even coded up a toy web server in Chapel. However, this project was not
selected for GSoC 2016.
Hopefully this is a project that will get more attention in the near future.
We are working in an simple http server (based on libevent2) at https://github.com/marcoscleison/chapel-http .
The project is in inital commits but you can see and have an idea how to create an http server.
One more note - see https://github.com/briangu/chearch/ for an example program that rolls its own server in Chapel. Also, note that ZeroMQ support is in progress in this pull request: https://github.com/chapel-lang/chapel/pull/3592. Hopefully you can find alternative solutions from one of those resources, although I don't think there's really anything wrong with using stdout and CGI.

Realtime server push with Socket IO (or Strophe.js), XMPP and Django

I have a couple of Android and iOS native mobile application that I wrote which connect directly to an XMPP server that I host. They push and pull realtime data through XMPP. I also use some of the XMPP XEP extensions. For other operations, I have a django application running on the same server which all the mobile applications consume through an HTTP REST interface. I use Celery and Redis for the django side to do some operations asynchronously (like doing heavy batched writes to my db).
This all works fine and dandy. Yay.
But now I want to write a web front-end to all of this, so I started researching my options and well - there are so many ways to skin the cat that I wanted to check with the SO community first.
The idea to have a js library that gives me a unified API for socket communications (i.e try different implementations of web sockets or fall back to flash) appeals to me hence why I mention Socket IO. The idea of having to run a nodejs server, well, not so much (one more thing to learn), but if I have to, I definitely will. I know that some people use gevent as a replacement of the node server. Others, decide to write a small nodejs which they connect to the rest of their stack. I would probably do this.
Another option, is to use an js XMPP library like Strophe which I don't think has a flash fallback. Also, I would need to research what this means for my server.
I have read several of the Stackoverflow answer on how to do comet and django - hence why it seems that there are several options.
The question is:
If I want to have the advantage of Socket IO behavior (with the fallbacks) and I want to push realtime data to the web client (which is being fed to the server through XMPP), and use Django what is my best option?
Update: The XMPP server that I use is ejabberd, which also supports BOSH. I realize that I could use Strophe.js and thus my communication would go over a type of long polling http connection instead of websockets. As far as I can tell, there are some XMPP over Websockets open source library, but AFAIK the community is not as active as the SocketIO one.
Update 2: Browsers that I need to support are only modern browsers. I guess this means that Flash fallback will not be that important, which is leaning me towards strophe.js.
I think once you get your hands dirty with some node you'll find that straying from Node for socket.io is going to be much harder. There are very easy to use xmpp modules in node ready to go (see https://github.com/astro/node-xmpp). Remember, node is all javascript, so you're probably familiar with programming in it already.
Personally, I've had some memory leak issues using node 0.6 or higher. Node 0.4 worked without those issues. If you are new to github (as I was before playing with Node) here is how you would get going with a node server.
Getting Node
Login to your linux box and favorite directory (I'll assume /)
git clone https://github.com/joyent/node.git
cd /node
git tag -l (this will list all available version of node)
git checkout v0.6.16 (this will checkout 0.6.16 version of node, you could replace that with v0.4.12 for example if you have memory issues)
./configure
make
make install
You'll need certain development tools to build it such as g++, but at this point you'll have a working node command.
Installing Node Modules like xmpp
Node has a nice amount of modules where most things have already been written for you. There is a search facility at http://search.npmjs.org or you can access all modules directly from your shell by using the npm command. NPM is nodes tool for installing and managing node modules. You can type npm search xmpp to search for all xmpp modules, for instance. To install a basic xmpp library for node you would do npm install node-xmpp. By the way, most github node module pages will include instructions on the front page readme file.
Keeping Node Running in Production
This threw me when I first started out. If you have any errors that are not caught node will simply die. So, you can either
1. Make sure there are no errors whatsoever or they are all caught (unlikely because even Node itself will error)
2. Use the uncaughtException handler to catch these problems. You would use code like this in your program
process.addListener("uncaughtException", function (err) {
util.log("Uncaught exception: " + err);
console.log(err.stack);
console.log(typeof(this));
// maybe email me?
});
Be Extra Safe and Use Forever
Even with the uncaughtException issue your program in production might die. Memory running out, segfaults, who knows what. That's where it pays to use something like the wonderful Node module called "Forever" (see https://github.com/nodejitsu/forever). You can type npm install forever -g to install forever. Note the -g option which puts forever in the GLOBAL node module directory. Without -g it puts the node module in the current working directory. You'll then be able to type something like (assuming your node program was called my_program.js) forever start my_program.js and then the Forever program will make sure that if it dies it gets restarted.
Not sure why you'd need Flash fallback if you're going to do BOSH (XEP-0124, XEP-0206), which is what strophe.js does. If you don't need to support IE7, you can do CORS from strophe.js, and you don't even need a proxy for same-origin. IE6 will work because it's insecure, and IE8+ support a just-barely-working form of CORS.
To get information from django through XMPP to your client, make a component connection (XEP-0114) to your server using your favorite Python XMPP library, such as SleekXMPP from your Django app. Arrange for that connection to be relatively long-lived, for performance (i.e. don't create a new one for each client connection). Send protocol as needed.
You didn't mention what XMPP server you're using. XMPP servers that don't support BOSH are getting rare, but if you've got one, you might need Punjab as a BOSH-to-XMPP proxy, or you might want to switch to a newer server, such as Prosody.
First of all, full disclosure: I work for a company called PubNub, which I'm going to mention shortly.
There are a whole range of hosted bidirectional messaging services (sometimes called IaaS - Infrastructure as a Service) that I think are worth considering. They are Pusher, Firebase, Flotype, PubNub, and others. I'm reasonably confident you could use any of them for what you want to accomplish. Firebase has a built-in database that ties right into their service, which is a pretty cool feature, but probably not useful for your particular use case (I assume you already have a database on your backend).
I can't speak too heavily about our competitors, but as far as you wanting a JavaScript library on the frontend that communicates with your Python backend, we (PubNub) provide a very similar api in both languages and that communicate on the same databus in the cloud. So you can send messages with Python and catch them with JavaScript, or vice-versa. We even wrote a PubNub-hosted version of socket.io, which you could use instead of our vanilla JavaScript api, and would still tie into your Django backend in about 10 lines of code.
Finally, the nice thing about using an IaaS (or at least us; again I'm not certain about the others) is that we handle that tricky scaling problem for you. If you reach the point of a million simultaneous users and need to push something to them in real-time, you'll find that's no problem.
We are using real-time push as well with Django and Celery. When I first created the architecture, I also researched my options. Eventually, I decided that I'd rather focus on getting the app just right rather then on fiddling around with devops work. There are several services out there that offer hosted real-time push technology that can be easily integrated with any app.
I chose PubNub and I couldn't be happier. They support socket.io for the client side and have a Python lib I use from Django and Celery workers. They also have SDKs you could use from native mobile apps.
I know, you already have a working setup in place. But I'm betting that the time it will take you to replace your current setup with such a hosted solution would be less than the time it will take you to find a good solution for what you're looking for and implement it. Also keep in mind maintenance costs down the road (esp if you opt for a lib which is not well maintained).
True, you will be paying for the service, but they price is very reasonable and you will be getting a solid service with nice perks like colocation.
I'm not affiliated with that company, just a happy customer. There are other similar services out there.

Which one can I choose? SSH or AMQP?

My application runs in Windows and is implemented using C++/Qt.
The application will invoke another application deployed in the Linux server which in turn will invoke some third party tools. The Linux server application will send some status updates based on the running of third party tools. Usually the third party application will run for hours and the updates will be sent at various stages. The Linux server may also has to send some files in addition to the status updates and the Windows client will also send some files required for the running of those third party tools.
I planned to implement this in libssh2 since file transfers can be done and applications can be executed as well using libssh2_channel_exec(). Updates can be sent and received through non-blocking socket transfers. Also the transfers must be secured and they are password authenticated, so I thought SSH will conform my requirements.
I also looked into Qpid of apache which implements the AMQP. The messaging seems to be a more appropriate one for my status updates since the updates are less frequent. But I am not so sure about the secured connection, password authentication and also the application invocation.
So, which one can I choose between these two? Or is there any other better option available? I am not quite used to network programming so any pointers, links regarding this are welcome..
Have you considered some web-based solutions like XML-RPC, REST, SOAP or other? Note that you can either have constant network connection and stream updates or just make your client ask for update as often as it needs.
Also, I think that building solution based on some of these protocols will give you easier coding - no need for some low-level solutions when you have great libraries. As for security part, I would consider SSL that is part of HTTPS protocol to be secure enough. Of course you can also do it hybrid style, for example SSH tunel to secure server and use SSH key authorization.
But if you are sure youwant SSH or AMQP then use first one - I think it has better security. Also, try not using username/passowrd. Instead use mentioned above keys.
Start with SSH, and then consider layering other protocols on top. You can use SSH port forwarding to create a VPN connection to a server, and maybe that will make it easier to use something like AMQP or 0MQ.

HornetQ and ActiveMQ CMS don't work together!

I'm trying to implement a solution using HornetQ. Since I need to access it through a C++ application, that raises me a problem. I'm compiling the activemq-cpp builtin example, and changing it to work with stomp instead of openwire (HornetQ doesn't understand openwire). The application refuses to produce messages on the intended queue. Seems that a lot of people are having the same issue, but no one has the answer. (someone said it's a bug on the cms API)
Anyone has a pratical example of HornetQ working with a C++ app?
PS: Obviously the activemq-cpp example works with an activemq server using openwire.
HornetQ is probably mapping destination names differently then the ActiveMQ C++ Stomp client, for instance in ActiveMQ a topic destination is prefixed with /topic/ and a queue is /queue/. I beleive this is different in HornetQ but not really sure. You may want to look in their docs for what they use, if its configurable then you could alter it to match what the CMS client is sending. You could also modify your local copy of CMS to send the destination name using the HornetQ prefix.
Regards
Tim.
www.fusesource.com
The only solution I have seen is a HornetQ to ActiveMQ bridge written in java then have the C++ app work with ActiveMQ. You might be able to do something with JNI to handle marshaling messages into your app.