How to Async Job Scedule in EJB Project - web-services

I am writing webservices to run on Jboss-eap-6.2 using EJB and I need to schedule a job inside it with options:
-->Start
-->Pause
-->Resume
-->Stop
N.B: I have Idea about EJB Timer and I know how to work with it but due to Technical problem we don't want to use EJB Timer and Java Timer.
Is there are other way or third party tools that can be used for resolving my problem?

JBoss EAP 6.2 only implements Java EE 6, which does not include JSR 236, which means you are limited to EJB timers or non-EE threading libraries (java.util.Timer, ScheduledExecutorService, or third-party libraries like Quartz). For the non-EE threading libraries, you need to be careful with your use of Java EE APIs since they typically do not work well with threads that are not managed by the application server.

Related

Use Go within a Qt C++ project

Is it possible to use a Go API in a Qt C++ project?
I would like to use the following Google API written in Go: https://cloud.google.com/speech-to-text/docs/reference/libraries#client-libraries-install-go
Is it possible to use a Go API in a Qt C++ project?
It could be possible, but it might not be easy and would be very brittle to run Go and Qt code in the same process, since Go and Qt have very different thread (goroutine) and memory models.
However, Go has (in its standard library) many powerful packages to ease the development of server programs, in particular of HTTP or JSONRPC servers.
Perhaps you might consider running two different processes using inter-process communication facilities. Details are operating system specific. I assume you run Linux. Your Qt application could then start the Go program using QProcess and later communicate with it (behaving as a client to your Go specialized "server"-like program).
Then you could use HTTP or JSONRPC to remotely call your Go functions from your Qt application. You need some HTTP client library in Qt (it is there already under Qt Network, and you might also use libcurl) or some JSONRPC client library. Your Go program would be some specialized HTTP or JSONRPC server (and some Google Speech to Text client) and your Qt program would be its only client (and would start it). So your Go program would be some specialized proxy. You could even use pipe(7)-s, unix(7) sockets, or fifo(7)-s to increase the "privacy" of the communication channel.
If the Google Speech to Text API is huge (but it probably is not) you might use Go reflective or introspective abilities to generate some C++ glue code for Qt: go/ast, go/build, go/parser, go/importer, etc
BTW, it seems that Google Speech to Text protocol is using JSON with HTTP (it seems to be some Web API) and has a documented REST API, so you might directly code in C++ the relevant code doing that (of course you need to understand all the details of the protocol: relevant HTTP requests and JSON formats), without any Go code (or process). If you go that route, I recommend making your Qt (or C++) code for Google Speech to Text some separate free software library (to be able to get feedback and help from outside).

Plugin/module communication method in multi-threaded C++ app

I am designing a C++ app which consists of largely independent plugins or modules which produce from time to time results useful for other plugins. For example, analysis module comes across some useful piece of data and sends it to action modules. Each module will run in its own thread; this is so analysis modules can continue gathering data while action modules handle the data at the rate they can.
I am looking for a suitable message passing architecture/design pattern. This stackoverflow thread gives some suggestions, but I'm not sure a plain interface will work in multi-threaded environment.
I was thinking of having some sort of channel based architecture, where each module broadcasts something on the channel and whichever module is interested in it - listens to. If there are some ready made libraries under liberal licence - the better.
I've been using ACE (Adaptive Communication Environment) for thread management, TCP/UDP communications, mutex relationships and programming.
ACE is a highly portable collection of invocations of platform core patterns. Best of all, it's free, open source, and currently under active development.
http://www.cs.wustl.edu/~schmidt/ACE.html
For your application, I would recommend looking specifically at class "ACE_Task_Base" to provide multi-threading, and "ACE_Reactor" to register all the handlers for your asynchronous callback architecture.
You might be interested to take a look at ZeroMQ library that acts like a concurrency framework also. Using this library your components would communicate with each other by sending messages to named ZeroMQ sockets. There are many sockets types (TCP, IPC, inproc) and several patterns available for request-reply and publish-subscribe messaging.

C++ Framework for creating servers?

What is (are) modern frameworks for async IO, threading, etc. on C++?
I'am familiar with ACE but it was long ago, what is the the weapon of choice now?
What about BOOST libraries? It seems to be the most ubiquitous option right now.
It has threading and ASYNC-IO built in and many, many more libraries.
Poco C++ Framework and its network library:
http://pocoproject.org/documentation/index.html
Try Pulsar Server Framework. Main benefit is it is built over libuv network libary (used by node.js) that uses asynchronous I/O based on event loops. The frame
It’s perfectly scalable. You can just go adding servers as your user
base increases.
It is designed to work with server farm.
Highly configurable and easy to use
Currently it has been built for Windows x64 server.

C++ How to make two programs communicate?

Question: What is the best way to make two programs (both running on the same computer) communicate and interact? (Windows, C++)
Theoretical situation:
On a Windows PC, I have a 3rd party software that you use to do stuff (like open/edit/save files...it's not really important). This 3rd party software has an available C++ SDK so you can develop plugins for it.
I develop a separate standalone Windows C++ program (most likely using Qt) with a GUI. This program is made to run on the same Windows computer as the 3rd party software. This program would act as a remote control or sender.
Using the 3rd party software's SDK, I develop a tiny plugin for the 3rd party software. This program acts as a receiver, so that my Qt GUI can send commands that this plugin would receive and thus remote control the 3rd party software accordingly.
So for a basic example, I could press a button on my standalone GUI that would communicate with the plugin that would then open a specified file in the 3rd party software.
What I'm essentially looking for is to develop standalone software that would communicate back and forth with a plugin that I would develop for the 3rd party software.
What is the best approach to this? I really have no clue where to start or what to look at. Are there common C++ libraries that make this type of thing easy?
I'm relatively new to C++ and very new to Qt, so please try to elaborate. Please don't just say "Use Shared Memory" or something like that cause I'm not gonna know exactly what you are talking about.
The program would NOT be run on a separate computer, so no network stuff is necessary here I don't think.
Some questions I was thinking about:
What if user has multiple copies of 3rd party software open at the same time. How does my standalone software know which one to communicate with?
If I already have my standalone software running and open the 3rd party software, does the plugin somehow have to register or find my standalone software to communicate with it?
If I already have the 3rd party software running and then open my standalone software does it have to scan for the plugin to see if its running or how does it find it?
Any help would be greatly appreciated. I've done a search on the topic on SO but didn't see many questions for C++ specifically and most of them didn't have many answers or weren't very clear or didn't specifically refer to software communication with a plugin for a 3rd party program.
there are many solutions with many pros and cons. you will have to do some reading on each to work out which is best for you. no solution is best for everyone
here is a good starting place http://msdn.microsoft.com/en-us/library/aa365574(v=vs.85).aspx
Honestly, I'd most likely take the network-based approach. It decouples the standalone software and the plugin and as such, you could easily hook your plugin into any number of other utility programs or scripts as long as the communication protocol matches.
So, I'd probably develop the plugin to act as a server, receiving commands and responding with statuses (hey, you could even follow the HTTP standard if you really wanted to ;)).
And if you ever wanted to do cross-machine communication, it comes for free :)
Of course, depending on the software and the usage, I'd encrypt the communication.
If you're using Qt, I believe it has the notion of Plugin: How to Create Qt Plugins
Otherwise, COM works fine. With C++ , I would use the ATL library, but there is also COM support in Qt.
If you want to go more low level, I would use sockets or named pipes (since you're working with Windows)
I'd go for sockets to establish a communication between your remote control application and the server app.
You'll find lots and lots of information by searching these keywords here on SO: IPC, RPC, sockets.

How to call a .NET web service from Blackberry Simulator?

I have to call a .NET web service (http://192.168.1.14/CG/authentication.asmx) from the Blackberry Simulator. Already i have done it in Android with KSOAP2, but i have no idea about how to do this in Blackberry. Can i use KSOAP2 in Blackberry? If i can please give some code snippets. Also please tell if you know any other ways to do this.
I've not used KSOAP2 before but I know that you can use it for Blackberry.
To call web services I use the Sun Java Wireless Toolkit (WTK) to generate stubs from your webservice's WSDL file, which should probably be http://192.168.1.14/ CG/authentication.asmx?wsdl for you.
You can then import the files that the WTK generates into your project to call your web methods using something along the lines of:
//Generated stub file
Service1Soap_Stub stub = new Service1Soap_Stub();
//Web service method
result = stub.methodName(param1, param2);
Alternatively you can use SAX and the standard J2ME libs.
The following link is a good tutorial on how to accomplish this:
http://www.simplified-tech.com/website/webapp.nsf/webpages/ArticlesBBWebServices
You can look at WSClient++ which generates code that is free from reflection and ideal for mobile platforms.