1

I've found stomp.py to fall behind when the volume is around 200k messages per hour & jython is not an option, so with a java message listener i'm looking to have a python script 'subscribe' to messages / events that would be generated from this java application. I have the basic gateway working & can make a call to a 'getMessage()' as follows:

def do_gateway():

    java_gateway = JavaGateway()
    try:
        app = java_gateway.entry_point
        message = app.getMsg()
        len(message) > 0:
        print_message(message)

...

Where the java method is:

public String getMsg(){
        System.out.println("stack size: " + stack.size());
        return stack.size() > 0 ? stack.pop() : ""; 
    }

What I really need is to 'subscribe' to the getMsg() method & have those messages 'pushed' as events. a low rent alternative of the above is:

  app = java_gateway.entry_point
        while True:
            message = app.getMsg()
            if len(message) > 0:
                print_message(message)

I see some callback_server detail where an interface on the java side is required - i have it set up on the java side & as much as i could follow on the python side but clearly i'm missing the good stuff & it's not doing much:

****java***

public class SubscriberEntryPoint implements MessageListener, ISubscriberEntryPoint,

    SubscriberEntryPoint app = new SubscriberEntryPoint();
    GatewayServer gatewayServer = new GatewayServer(app);
    gatewayServer.start();
    System.out.println("Gateway Server Started");


public interface ISubscriberEntryPoint {

    public String getMsg();

}

****python***

def do_callback():
    try:

        gateway = JavaGateway(start_callback_server=True)

        class Java:
            implements = ['mqtest.ISubscriberEntryPoint']

        message = gateway.entry_point.getMsg()
        print_message(message)

thanks in advance!

0 Answers0