mely
unread,Jun 6, 2012, 4:18:56 PM6/6/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to stomp-spec
I want to create an android client that sens on a queue a text
message. I have the following code:
package andro.stomp;
import java.io.IOException;
import java.net.UnknownHostException;
import org.apache.activemq.transport.stomp.Stomp.Headers.Subscribe;
import org.apache.activemq.transport.stomp.StompConnection;
import org.apache.activemq.transport.stomp.StompFrame;
import android.app.Activity;
import android.os.Bundle;
public class AndroidStompActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
StompConnection connection = new StompConnection();
try {
connection.open("localhost", 61613);
connection.connect("system", "manager");
connection.begin("tx1");
connection.send("/queue/test", "message1");
connection.send("/queue/test", "message2");
connection.commit("tx1");
connection.subscribe("/queue/test", Subscribe.AckModeValues.CLIENT);
connection.begin("tx2");
StompFrame message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");
message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");
connection.commit("tx2");
connection.disconnect();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
When I run it I have a lot of error messages:
06-06 23:17:14.129: E/AndroidRuntime(25198): FATAL EXCEPTION: main
06-06 23:17:14.129: E/AndroidRuntime(25198):
java.lang.NoClassDefFoundError:
org.apache.activemq.transport.stomp.StompConnection
06-06 23:17:14.129: E/AndroidRuntime(25198): at
andro.stomp.AndroidStompActivity.onCreate(AndroidStompActivity.java:
19)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1047)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
1615)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
1667)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
android.os.Handler.dispatchMessage(Handler.java:99)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
android.os.Looper.loop(Looper.java:130)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
android.app.ActivityThread.main(ActivityThread.java:3687)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
java.lang.reflect.Method.invokeNative(Native Method)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
java.lang.reflect.Method.invoke(Method.java:507)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:867)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
06-06 23:17:14.129: E/AndroidRuntime(25198): at
dalvik.system.NativeStart.main(Native Method)
Need some help. Appreciate. Thx