Android Question RabbitMQ and JavaObject

Discussion in 'Android Questions' started by jndaniels1, Feb 9, 2015.

  1. jndaniels1

    jndaniels1 Member Licensed User

    Hello B4A Family.

    I have taken a leap to try to understand the JavaObject in B4a
    I have read Erels' tutorial for the JavaObject using Picasso over and over.

    Now I know the leap i've taken is probably huge but I want to see if I can integrate the RabbitMQ
    with a project I have. So here is my question.

    I got all the Jars' in B4A - tested all sorts of invocations and objects and JavaObjects just to get myself a bit more confused. If I could just get an example of how the below could be done in B4A I would appreciate it IMMENSELY !

    ConnectionFactory factory = new ConnectionFactory();
    factory.setUsername(userName);
    factory.setPassword(password);
    factory.setVirtualHost(virtualHost);
    factory.setHost(hostName);
    factory.setPort(portNumber);
    Connection conn = factory.newConnection();
    Preferably i like to use

    ConnectionFactory factory = new ConnectionFactory();
    factory.setUri("amqp://userName:password@hostName:portNumber/virtualHost");
    Connection conn = factory.newConnection();
    Im able to get the "class" initializedStatic but when I try to run any of the methods to set the properties i get the error

    java.lang.IllegalArgumentException: expected receiver of type com.rabbitmq.client.ConnectionFactory, but got java.lang.Class<com.rabbitmq.client.ConnectionFactory>
    It goes without saying I am not a Java person - but what better way to learn than to jump in the deep end.

    The javadoc is located at :
    http://www.rabbitmq.com/releases/rabbitmq-java-client/v3.4.3/rabbitmq-java-client-javadoc-3.4.3/com/rabbitmq/client/ConnectionFactory.html

    Again to anybody that could give me boost i would be so greatful!

    Kindest regards
    JEFFD
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Please post your code.

    You should use InitializeNewInstance not static.
     
  3. rboeck

    rboeck Well-Known Member Licensed User

  4. jndaniels1

    jndaniels1 Member Licensed User

    @Erel - Thanks for the reply - I tried that and got it working.

    @rboeck - Thank you for the link! Looks like this will be a solution for my project!

    Thanks so much!
    Cheers
    JEFFD
     
  5. jndaniels1

    jndaniels1 Member Licensed User

    well, i spoke too soon

    @Erel. I zipped my test code and attached.

    I hope you can help as i really want to learn as much as possible.

    regards
    JEFFD
     

    Attached Files:

  6. Erel

    Erel Administrator Staff Member Licensed User

    Which error do you get?
     
  7. jndaniels1

    jndaniels1 Member Licensed User

    logs shows:

    Code:
    java.lang.reflect.InvocationTargetException


    I know im not passing factory object over to the connection object. But this exception comes up.

    attached is the error log.

    Regards
    JEFFD


    P.S im a 4.3 user now.
     

    Attached Files:

  8. DonManfred

    DonManfred Expert Licensed User

    You got a Network on Mainthread Exception...
    See here.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice