How to call ruby from java in cloud foundry? - java

I have a requirement where i need to call/trigger the ruby ETL program from java code in the cloud foundry environment. will cloudfoundry supports 2 different buildpacks to run on single application instance. Is it possible to run java and ruby processes on the single instance in cloud foundry. I'm new to cloud foundry any help is greatly appreciated.

A simple way to have programs written in different programming languages communicate with each other is using REST. Also if asynchronous communication is preferred, you may want to exchange messages via a message broker (e.g. RabbitMQ).
I would recommend deploying two different apps (one written in Ruby and the other written in Java) and have the ruby app expose a REST endpoint that can be triggered by your java app. You could secure this endpoint using some authentication mechanism (e.g. HTTP Basic).
The possibility of running 2 different buildpacks with a single application does, to the best of my knowlege, not exist. Also this does not seem to be a clean approach in my eyes.

Related

Can Azure Application Insights be used as APM via rest API?

Application insights can used to monitor custom application events (such as calls, exceptions, durations etc).
The documentation gives SDKs for .net, and an agent for java. https://learn.microsoft.com/en-us/azure/azure-monitor/app/platforms
We are using java, but its hosting by Adobe (its their cloud CMS called AEM), so we cant run or install any agent. We can include java libraries, and cam make rest calls going out.
The question is, does AI have any sort of rest API to get application monitoring data into AI? Azure as a whole has one (e.g. for querying resource groups) https://learn.microsoft.com/en-us/rest/api/azure/
NOTE: this is not to query AI data, there is a specific API for that, we need an API to write the event and telemetry data into it.
I don't think it is officially published (REST API for ingestion).
At the same time the wire protocol is used by both all SDKs and by many customers who decided to use REST API directly. So, essentially REST API will not change.
One way is to build an app using agent, sniff wire protocol using Fiddler (or similar tool) and then use it as REST API.
Beware that Application Insights SDKs (and agents) take care of many things - starting from auto collection, calculating standard metrics and finishing with proper backoff logic/retries/etc.
On top of it Application Insights SDKs support two channels - Standard and Real-time (Live Metrics/Diagnostics). Implementing the second channel might be quite tricky.

Setting up server for android app

I have developed an android application and i need to set a server for sending and receiving data from clients. The server must also be able to run python script for data mining.I want to code the server in java(for analysing the data obtained from mining and handling the client requests).
what will be the way to set the server for my purpose. I have read that servers can be set up in eclipse or installing apache in linux in a virtual machine. will anyone of them fit my need or is there any other better alternative.
Well, it depends on your needs. If you want to run Python scripts from Java, I don't really see why you would code your server-side logic in Java and then use Python data-mining scripts (you might have some problems with execution of Python scripts through Java and server setup). I know that Python is much better in data-mining, so stick with it. Consider Python for server-side logic. In case you want to run data-mining script manually that doesn't really mater, so you can separate the languages.
In case you want to separate it into two languages, then you must install an application server for Java. There are plenty of options for that, even open-sourced (Wildfly, Glassfish, ...):
https://blog.idrsolutions.com/2015/04/top-10-open-source-java-and-javaee-application-servers/
You can set most of them in Eclipse for development, for production releases they can be installed either on Unix or Windows. The Apache option you mentioned is probably Apache Tomcat application server. You can read more about Java application server set-up in Eclipse:
http://www.eclipse.org/webtools/community/education/web/t320/Configuring_an_Application_Server_in_Eclipse.pdf
Depending upon the requirement, you can setup the server in many ways in any operating system like linux (fedora, ubuntu), windows, mac osx etc. There are many java web frameworks to follow to make your own server and provide API for mobile.
These are some java web frameworks:
playframework
Spring MVC
Grails
You can setup above and other frameworks and can setup in any enviorment. For initial, you can setup in your local system, then later you can upload into your remote server.
For setup, please see the respective framework's documentation.
It would be wise to choose json for communication between mobile and server. You can consume the API in android using default HttpURLConnection or you can follow other opensource http connection library like retrofit, asynchttp etc.

How to do inter process communication(communication b/w 2 JVM's on same server) using vert.x

I need some guidance. I have implemented vert.x(1.3.1.final) using eventbus mode in my web application. Currently, what am I doing is whenever a event is generated on server, the notification sent to the client/clients associated with that unique address.Everything is going fine.
Now, in my web application, some certain process takes all resources of tomcat and than tomcat gives OutOfMemoryError. So, my team decided that the process taking large number of resources will be separated from web application(i.e. outside tomcat).
So now requirement is to communication between two java processes that is executing on separate JVM on same server.
Is it possible with vert.x? I didn't get so much help regarding inter process communication using this. Or I will have to use other methodology like (the techniques using java inter process communication.) ? What would be the best solution in terms of performance.
Two vert.x processes on the same server can communicate using the built-in Event Bus, if you start each process using -cluster and set ports accordingly. See the examples included with the distribution.
You might also consider looking at vertx 2.x rather than 1.3.1...
For specifically your case, I can see that ZeroMQ would be a best fit.
You can also use Java Management Extensions (JMX) to expose methods in a running process through a simple web interface.

Storing String / Text values over 500 Chars with and without GAE

I made a GAE-Project with JPA2 for db access. I store some Strings which are more than 500 Characters, so I use com.google.appengine.api.datastore.Text.
I got an interface Script.java which defines the value as String, and an ScriptImpl.java which has internally a Text member, and converts for getting and setting.
Because one requirement of the project is, that it is still able tu run on an simple tomcat with a database behind. So it must be possible to run inside and outside the google environment.
Is there some realistic way to implement my application so I can switch to a normal tomcat environment (e.g. via a spring configuration to use different beans...).
What else do I have to pay attention to to make this work in both environments and how do I take care of the parts that are seamed thight to GAE?
Update: So far I found the following critic issues: Google User Service & Login Process, Text Class in Domain Models, Wicket-GAE-Initializer (since I use Wicket)
GAE has it's own proprietary API. If you wrote application using this API then if you want to move off of the GAE you have two options:
Rewrite your code, obviously.
Use a API wrapper that implements GAE API but runs on other platforms. An example of such wrappers are AppScale and CapeDwarf. AppScale is older and probably more mature and supports both Java and Python. Also it supports more platforms (private servers + clouds). OTOH, CapeDwarf is targeted at JBossAS7, so it's probably better fit if you use that server (or OpenShift cloud). Also I guess you can expect better support from a mature open-source leader such as RedHat.
While in theory it might be possible to wrap GAE functionality and then delegate it to either app engine or your "normal" environment it's probably a lot of effort.
Possibly another approach would be easier. Are you aware of CapeDwarf?
JBoss CapeDwarf
Deploy and run your Java App Engine applications on your own private
JBoss Application Server (AS7) cluster or on RedHat’s OpenShift cloud.
JBoss CapeDwarf is an implementation of the Google App Engine API,
which allows applications to be deployed on JBoss Application Servers
without modification. Behind the scenes, CapeDwarf uses existing JBoss
APIs such as Infinispan, JGroups, PicketLink, HornetQ and others.
If it really needs to be "simple tomcat with a database" then more information or constraints will be helpful to know.

Java based web application using Node.js?

I am a novice to web application programming trying to build first webapp and read that Node.js can be used for high-performance, highly concurrent and suited for web applications.
My question is that is it possible to hook up Node.js with Java backend?
How does that work?
Thanks
To start off with node.js is a backend. So if you have a misconception of what node.js then you don't need Java.
If you want to integrated node.js into an existing Java application to use it as a real time communication platform then you can get the two talking to each other over TCP sockets.
Take a look at the net docs

Categories

Resources