ActiveMQ : Integration of C.

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ActiveMQ : Integration of C.

vikd
Hi ,

I am new to use this forum .
I have some queries , please find below details

we have to listen a message from AMQ broker and then pass to c function and responded/processed message from c function again send back to AMQ broker using getJMSReplyTo and getJMSCorrelationID.

so please guide me on below.
We have implemented two approaches to call our legacy c code (function)

A) ActiveMQ-CPP (CMS) library and call c code (function).
B) Java (JMS API) and using JNI called c code (function).

however I am interested to know on below points
1) which will be the best option to call c functions and why?
2) if we go above 2nd (B) point Java & C using JNI then will any performance issue or concurrency issue to call shared c library (.so library) from Java?
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ : Integration of C.

artnaseef
This is an uncommon situation.  Here's my thoughts (note that I was a "Unix and C" developer for many years before moving over to Java):

1. Either approach can work
2. Java runs within a virtual machine (the JVM) and is designed that way
    a. It is great for execution of java applications
    b. It kinda stinks for integration into native programs (like those created by compiled "C") as the JVM is not light-weight (not even if you wanted a the simplest library routine)
3. JNI is a good tool when it is absolutely necessary to make use of native code from within the JVM
4. Because of 2b, though, JNI is not a great approach for using Java code from native code

To clarify what I mean in 2b, here's just one potential concern: the JVM uses garbage collection for its memory management while "C" programs use application-managed memory (e.g. malloc and free); splitting memory between the two approaches becomes a challenge for the application, and insight into the handling and performance of JVM memory in the native program will be challenging (JVM OutOfMemory condition is very different than a "C" program's failed malloc call).

So, my personal recommendation: do not go the JNI route for a "C" application unless you must.

On the other hand, if there is a strong desire to use native Java code to interact with ActiveMQ via OpenWire, which is a good practice since it's the primary client interface and is always guaranteed to be maintained ahead of others,  then perhaps a split architecture of the application makes sense.  The ActiveMQ client can be written in Java and use another IPC (inter-process communication) to hand-off the message to the "C" application, and get the results back.

Note that the ActiveMQ-CPP library is good solution in my experience, so going with a native Java application may be overkill.

Hope this helps.
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ : Integration of C.

vikd
thank your for your reply !
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ : Integration of C.

vikd

Dear Artnaseef

I glad to tell you ,
we had a decision first continue with ActiveMQ CPP (CMS) library...

now I have some query on the same to building the ActiveMQ CMS library.

I have checked with activemq-cpp-library-3.9.1-src.tar.gz and some lower version (till activemq-cpp-library-3.8.2-src.tar.gz) but it is not getting build / compile and remaining lower versions are not getting downloads from below URL.

URL : http://activemq.apache.org/cms/download.html

Followed steps are
1) cd activemq-cpp-library-3.8.2-src
2)./configure
3) make

Please guide , which is compatible ActiveMQ-CPP (CMS) library for below mentioned linux server and installed tools?


same above steps are working fine and could build/compile on below linux configuration and installed tools

Linux : Red Hat Enterprise Linux Server release 6.6
APR : apr-1.3.9-5.el6_2.x86_64
OpenSSL : OpenSSL 1.0.1e-fips 11 Feb 2013
autoconf : autoconf (GNU Autoconf) 2.63
automake : automake (GNU automake) 1.11.1
libtool : ltmain.sh (GNU libtool) 2.2.6b


I am not able to download some lower than activemq-cpp-library-3.8.2-src.tar.gz version from below URL to check.
 http://activemq.apache.org/cms/download.html

any other URL so that I can download and check whether CMS libraries are compatible with linux (Red Hat Enterprise Linux Server release 5.9 (Tikanga)) or not ?

Please guide ..

Thanks in advance !!
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ : Integration of C.

artnaseef
Can you provide details of the problems seen?  I haven't used ActiveMQ-CPP myself in a while, but I would expect building it from sources on any modern Linux system to work.
Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ : Integration of C.

vikd
Hi Artnaseef,

Please find details of the problems.

I am getting below error and could not link the .o file against the CMS library aftre execution of below command
g++ -L  $CMS_HOME/src/main/.libs -g -o apex/ticket/TicketReplier apex/ticket/TicketReplier.o -lactivemq-cpp -lssl

Error :
$<HOME_DIR>/activemq-cpp-library-3.8.2/src/main/.libs/libactivemq-cpp.so: undefined reference to `apr_pool_create_unmanaged_ex'
$<HOME_DIR>/activemq-cpp-library-3.8.2/src/main/.libs/libactivemq-cpp.so: undefined reference to `apr_sockaddr_ip_getbuf'

Please guide us why .o file is not getting link against the CMS library.

For more details please find my server machine details
Tools Version Installed
Linux  :    Red Hat Enterprise Linux Server release 5.9 (Tikanga)
APR : apr-1.2.7-11.el5_6.5
OpenSSL : OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
autoconf : autoconf (GNU Autoconf) 2.69
automake : automake (GNU automake) 1.9.6
libtool : ltmain.sh (GNU libtool) 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)

Thanks in advanced !

Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ : Integration of C.

tabish121@gmail.com
You need a version of APR at v1.3 or higher, 1.2 versions won't work.

On 04/23/2016 10:59 AM, vikd wrote:

> Hi Artnaseef,
>
> Please find details of the problems.
>
> I am getting below error and could not link the .o file against the CMS
> library aftre execution of below command
> g++ -L  $CMS_HOME/src/main/.libs -g -o apex/ticket/TicketReplier
> apex/ticket/TicketReplier.o -lactivemq-cpp -lssl
>
> Error :
> $<HOME_DIR>/activemq-cpp-library-3.8.2/src/main/.libs/libactivemq-cpp.so:
> undefined reference to `apr_pool_create_unmanaged_ex'
> $<HOME_DIR>/activemq-cpp-library-3.8.2/src/main/.libs/libactivemq-cpp.so:
> undefined reference to `apr_sockaddr_ip_getbuf'
>
> Please guide us why .o file is not getting link against the CMS library.
>
> For more details please find my server machine details
> Tools Version Installed
> Linux  :    Red Hat Enterprise Linux Server release 5.9 (Tikanga)
> APR : apr-1.2.7-11.el5_6.5
> OpenSSL : OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
> autoconf : autoconf (GNU Autoconf) 2.69
> automake : automake (GNU automake) 1.9.6
> libtool : ltmain.sh (GNU libtool) 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)
>
> Thanks in advanced !
>
>
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-Integration-of-C-tp4709951p4711124.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>


--
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/

Reply | Threaded
Open this post in threaded view
|

Re: ActiveMQ : Integration of C.

vikd

Thank you for your reply !


just discussed with linux administrator to install APR 1.3 or higher , but he is saying APR1.3 and higher version is not supporting to  linux 5.9 (Red Hat Enterprise Linux Server release 5.9 (Tikanga)) and as per our internal policy/dependency, now we can not upgrade on linux 6.x (Red Hat Enterprise Linux Server release 6.x (Santiago))  .

so please guide us any links / steps to install 1.3 or higher version on linux 5.9 machine (Red Hat Enterprise Linux Server release 5.9 (Tikanga)) so I will again discuss with our linux administrator regarding installation of APR1.3 and higher version.

or

if any other alternative to compile ActiveMQ CPP library .