stomp and android

1,460 views
Skip to first unread message

mely

unread,
Jun 6, 2012, 4:18:56 PM6/6/12
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

Chris Barrow

unread,
Jun 7, 2012, 3:42:25 PM6/7/12
to stomp...@googlegroups.com, mely
Hi Mely,

I don't think this is the right forum for your question. This forum is
supposed to be about the STOMP protocol specificiation. It looks more
like a question for ActiveMQ or Android.

Chris

melinda fancsal

unread,
Jun 8, 2012, 3:40:47 AM6/8/12
to stomp...@googlegroups.com
Could you please give me an exaple with stomp topic and queue on android (a project example)?

Rob Davies

unread,
Jun 8, 2012, 5:31:02 AM6/8/12
to stomp...@googlegroups.com

melinda fancsal

unread,
Jun 8, 2012, 12:54:01 PM6/8/12
to stomp...@googlegroups.com
what about rabbitMQ. Have you head about uit? Where can I find more examples with android client?

Rob Davies

unread,
Jun 8, 2012, 12:56:05 PM6/8/12
to stomp...@googlegroups.com
I would recommend you ask that on the RabbitMQ list: https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

thanks,

Rob

mely

unread,
Jun 15, 2012, 9:57:09 AM6/15/12
to stomp...@googlegroups.com
Hi,. Thank you for your example. Cpuld you please help me with a lclient on android and server on eclipse application? I want to have a queue and topic. thx
Reply all
Reply to author
Forward
0 new messages