...
Our C++ implementation is built on top of the C++ ActiveMQ libraries called CMS (http://activemq.apache.org/cms/). Headers and libraries are provided for Visual Studio 2005 and 2008. VS2008 VS2010 is the currently maintained version.
...
A sample using this implementation is included in \lib\vhmsg\samples\elbench\cpp\elbench.cpp. A condensed version of this sample is shown to give you an idea of what's required:
Code Block | ||
---|---|---|
| ||
#include "vhmsg-tt.h" void tt_client_callback( char * op, char * args ) { printf( "received - '%s %s'\n", op, args ); } int main() { // set up our callback for receiving messages vhmsg::ttu_set_client_callback( tt_client_callback ); // connect to the server err = vhmsg::ttu_open(); if ( err == TTU_ERROR ) { printf( "Connection error!\n" ); return -1; } // register which message we’re interested in receiving err = vhmsg::ttu_register( "elbench" ); // send a message vhmsg::ttu_notify2( "elbench", “Hello World” ); // poll to receive messages. callback function is called for each message received while ( !_kbhit() ) { err = vhmsg::ttu_poll(); if( err == TTU_ERROR ) { printf( "ttu_poll ERR\n" ); } } // cleanup vhmsg::ttu_close(); } |
...
A elbench sample is included in \lib\vhmsg\samples\elbench\cs\elbench.cs. A condensed version of the sample is shown to give you an idea of what's required:
Code Block | ||
---|---|---|
| ||
/// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { elbenchcs e = new elbenchcs(); e.Run(); } public void Run() { VHMsg.Client vhmsg; using ( vhmsg = new VHMsg.Client() ) { vhmsg.OpenConnection(); vhmsg.MessageEvent += new VHMsg.Client.MessageEventHandler( MessageAction ); vhmsg.SubscribeMessage( "elbench" ); vhmsg.SendMessage( "elbench Hello World" ); // Run your app, messages are received via a different thread } } private void MessageAction( object sender, VHMsg.Message args ) { // Note: Messages are received on a different thread. Please lock accordingly, and pay extra careful while calling UI commands. //Ict.ElvinUtility eu = (Ict.ElvinUtility)sender; //Console.WriteLine( "Received Message '" + args.toString() + "'" ); } |
...
An elbench sample is included in \lib\vhmsg\samples\elbench\java\src\elbench.java. A condensed version of the sample is shown to give you an idea of what's required:
Code Block | ||
---|---|---|
| ||
import edu.usc.ict.vhmsg.*; public class elbench implements MessageListener { public static VHMsg vhmsg; public elbench() { vhmsg = new VHMsg(); boolean ret = vhmsg.openConnection(); if ( !ret ) { System.out.println( "Connection error!" ); return; } vhmsg.enableImmediateMethod(); vhmsg.addMessageListener( this ); vhmsg.subscribeMessage( "elbench" ); vhmsg.sendMessage( "elbench Hello World" ); // Run your app, messages are received via a different thread } public void messageAction( MessageEvent e ) { // Note: Messages are received on a different thread. // Please lock accordingly, and pay extra careful while calling UI commands. //System.out.println( "Received Message '" + e.toString() + "'" ); } public static void main( String[] args ) { elbench elbenchObj = new elbench(); } } |
...