[rabbitmq-discuss] RabbitMQ Flex subscriber

Pete Kay petedao at gmail.com
Wed Aug 27 07:24:24 BST 2008


I think I am close to getting my Flex code to subscribe to RabbitMQ, but I
am a bit stuck on just one thing.

When connecting using AMPQ Flex lib, I am getting:

Calling handleForcedShutdown from connection
forceClose called

Is there any way I can turn on some kind of logging to see all the messages
going in and out of RabbitMQ to debug this problem?

Could someone please kindly help me out?

Here is my simple Flex code for getting the published messages from the Java

       public class Subscriber implements BasicConsumer {
      protected var x:String = "";
          protected var q:String = "";
         protected var x_type:String = "topic";
         protected var bind_key:String = "*"
         protected var routing_key:String = "SimpleQueue"
         protected var connection:Connection;
         protected var baseSession:Session;
         protected var sessionManager:SessionManager;
         protected var sessionHandler:SessionStateHandler;

         public function Subscriber() {

   private function init () : void
    var state:ConnectionState = new ConnectionState();

        state.username = "guest";
       state.password = "gutes";
       state.vhostpath = "/";
       state.serverhost = "";
       var connection:Connection = new Connection(state);
       var baseSession:Session = connection.baseSession;
       var sessionManager:SessionManager = connection.sessionManager;
    baseSession.addEventListener(new OpenOk(), onOpenOk);

   public function onOpenOk(event:ProtocolEvent):void {
    sessionHandler = sessionManager.create();
    var open:Open = new Open();
    var accessRequest:Request = new Request();
    accessRequest.realm = "/data";
    accessRequest.passive = true;
    accessRequest.active = true;
    accessRequest.read = true;
    accessRequest.write = true;
    var exchange:org.amqp.methods.exchange.Declare
     = new org.amqp.methods.exchange.Declare();
    exchange.exchange = x;
    exchange.type =x_type;
    var queue:org.amqp.methods.queue.Declare
     = new org.amqp.methods.queue.Declare();
    queue.queue = q;
    var bind:Bind = new Bind();
    bind.exchange = x;
    bind.queue = q;
    bind.routingkey = bind_key;

   sessionHandler.dispatch(new Command(open));
   sessionHandler.dispatch(new Command(accessRequest));
   sessionHandler.dispatch(new Command(exchange));
   sessionHandler.dispatch(new Command(queue));
   sessionHandler.dispatch(new Command(bind));
   sessionHandler.addEventListener(new BindOk(), onBindOk);

  public function onBindOk(event:ProtocolEvent):void{
    trace("onBindOk called");
     var consume:Consume = new Consume();
             consume.queue = q;
             consume.noack = true;
             sessionHandler.register(consume, this);

  public function onConsumeOk(tag:String):void {
            //consumerTag = tag;

       public function onCancelOk(tag:String):void {
        public function onDeliver(method:Deliver,
                                  body:ByteArray):void {
            trace("onDeliver --> " + body.readUTF());

Thank you very much for all your kind help.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20080827/0facf3d2/attachment.htm 

More information about the rabbitmq-discuss mailing list